Changeset 427261
- Timestamp:
- 08/22/2011 06:49:28 PM (15 years ago)
- Location:
- xmpp-auth/trunk
- Files:
-
- 2 edited
-
dns.php (modified) (4 diffs)
-
xmpp_stream.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
xmpp-auth/trunk/dns.php
r426617 r427261 37 37 $targets = array(); 38 38 $recs = array (); 39 // 1 week in second. Too long ttls should be avoided. 40 // See RFC-1035, section 7.3 (Processing Responses). 41 $ttl = 604800; 39 42 foreach ($records as $rr) 40 43 { … … 46 49 $rec['port'] = $rr['port']; 47 50 $rec['weight'] = $rr['weight']; 48 $rec['ttl'] = $rr['ttl'];51 //$rec['ttl'] = $rr['ttl']; 49 52 $recs[$rr['pri']][] = $rec; 53 // I want to use a single ttl for all records, which is the minimum ttl. 54 // I indeed consider that if one record terminate, I should probably check the whole query again. 55 $ttl = min($ttl, $rr['ttl']); 50 56 } 57 $ttl += time(); // Convert the ttl from relative to absolute for caching. 51 58 52 59 ksort($recs); … … 55 62 if (count($rrs) == 1) 56 63 $targets[] = array( 57 'port' => $rrs[0]['port'], 58 'server' => $rrs[0]['target']); 64 'port' => $rrs[0]['port'], 65 'server' => $rrs[0]['target'], 66 'ttl' => $ttl); 59 67 else 60 68 { … … 89 97 'port' => $rr['port'], 90 98 'server' => $rr['target'], 91 'ttl' => $ rr['ttl']);99 'ttl' => $ttl); 92 100 unset($rrs[$k]); 93 101 break; -
xmpp-auth/trunk/xmpp_stream.php
r427193 r427261 80 80 if (empty($port) && empty($server)) 81 81 { 82 if (class_exists("NET_DNS_Resolver")) 82 $cache = get_option('imauth_dns_srv_cache'); 83 if (isset($cache[$domain]) && $cache[$domain][0]['ttl'] >= time()) 84 { 85 // I make the check of the domain, because the domain may have changed. 86 // Also I know (from the way I built the cache) that if it exists, it will always have at least one value, 87 // at index 0, and that if there are several values, the 'ttl' will be the same for all of them. 88 $this->targets = $cache[$domain]; 89 } 90 elseif (class_exists("NET_DNS_Resolver")) 83 91 { 84 92 $resolver = new Net_DNS_Resolver(); 85 93 $response = $resolver->query('_xmpp-client._tcp.' . $this->domain, 'SRV'); 86 if ( $response)94 if (!empty($response)) 87 95 { 88 96 $recs = array (); … … 102 110 } 103 111 $this->targets = dns_srv_sort($recs); 112 $cache = array($domain => $this->targets); 113 update_option('imauth_dns_srv_cache', $cache); 104 114 } 105 115 else … … 111 121 { 112 122 $response = dns_get_record('_xmpp-client._tcp.' . $this->domain, DNS_SRV); 113 if ($response) 123 if (!empty($response)) 124 { 114 125 $this->targets = dns_srv_sort($response); 126 $cache = array($domain => $this->targets); 127 update_option('imauth_dns_srv_cache', $cache); 128 } 115 129 else 116 130 $this->targets[] = array(
Note: See TracChangeset
for help on using the changeset viewer.