Project

General

Profile

« Previous | Next » 

Revision 0333f968

Added by Phil Davis over 12 years ago

Add DynDNS No-IP Free account support

The free No-IP account requires the IP address to be changed within every 30 days. If there is no change, the "last updated" date at No-IP does not get updated and the account lapses.
This change implements a double-update when the cache age reaches 25 days, or the user does "Save & Force Update" on the GUI. It updates the IP to a dummy address (192.168.1.1) and then 10 seconds later puts it back the way it was. After this process, the "last updated" date on the No-IP site updates.
To get this behavious, users have to select "No-IP (free)" as their DynDNS service type.

View differences:

etc/inc/dyndns.class
97 97
		var $_dnsRequestIf;
98 98
		var $_dnsRequestIfIP;
99 99
		var $_dnsMaxCacheAgeDays;
100
		var $_dnsDummyUpdateDone;
101
		var $_forceUpdateNeeded;
100 102
		
101 103
		/* 
102 104
		 * Public Constructor Function (added 12 July 05) [beta]
......
162 164
			log_error("DynDNS ({$this->_dnsHost}): running get_failover_interface for {$dnsRequestIf}. found {$this->_dnsRequestIf}");
163 165
			$this->_dnsRequestIfIP = get_interface_ip($dnsRequestIf);
164 166
			$this->_dnsMaxCacheAgeDays = 25;
165

  
167
			$this->_dnsDummyUpdateDone = false;
168
			$this->_forceUpdateNeeded = $forceUpdate;
169
			
166 170
			// Ensure that we were able to lookup the IP
167 171
			if(!is_ipaddr($this->_dnsIP)) {
168 172
				log_error("DynDNS ({$this->_dnsHost}) There was an error trying to determine the public IP for interface - {$dnsIf}({$this->_if}). Probably interface is not a WAN interface.");
......
182 186
				case 'dyndns-custom':
183 187
				case 'dhs':
184 188
				case 'noip':
189
				case 'noip-free':
185 190
				case 'easydns':
186 191
				case 'hn':
187 192
				case 'zoneedit':
......
198 203
				case 'selfhost':
199 204
				case 'he-net-tunnelbroker':
200 205
				case 'route53':
201
					$this->_update();	
206
					$this->_update();
207
					if($this->_dnsDummyUpdateDone == true) {
208
						// If a dummy update was needed, then sleep a while and do the update again to put the proper address back.
209
						// Some providers (e.g. No-IP free accounts) need to have at least 1 address change every month.
210
						// If the address has not changed recently, or the user did "Force Update", then the code does
211
						// a dummy address change for providers like this.
212
						sleep(10);
213
						$this->_update();
214
					}
202 215
					break;
203 216
				default:
204 217
					$this->_error(6);
......
271 284
					curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
272 285
					break;
273 286
				case 'noip':
287
				case 'noip-free':
274 288
					$needsIP = TRUE;
275 289
					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
276 290
					$server = "http://dynupdate.no-ip.com/ducupdate.php";
......
279 293
						$server = $this->_dnsServer;
280 294
					if($this->_dnsPort)
281 295
						$port = ":" . $this->_dnsPort;
282
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $this->_dnsIP);
296
					if(($this->_dnsService == "noip-free") && 
297
					   ($this->_forceUpdateNeeded == true) && 
298
					   ($this->_dnsDummyUpdateDone == false)) {
299
						// Update the IP to a dummy value to force No-IP free accounts to see a change.
300
						$iptoset = "192.168.1.1";
301
						$this->_dnsDummyUpdateDone = true;
302
						log_error("DynDNS ({$this->_dnsHost}): Processing dummy update on No-IP free account. IP temporarily set to " . $iptoset);
303
					} else {
304
						$iptoset = $this->_dnsIP;
305
					}
306
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $iptoset);
283 307
					break;
284 308
				case 'easydns':
285 309
					$needsIP = TRUE;
......
629 653
				case 'dhs':
630 654
					break;
631 655
				case 'noip':
656
				case 'noip-free':
632 657
					list($ip,$code) = explode(":",$data);
633 658
					switch ($code) {
634 659
						case 0:
......
1061 1086
			}
1062 1087
			if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
1063 1088
				$needs_updating = true;
1089
				$this->_forceUpdateNeeded = true;
1064 1090
				$update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days.  Updating. ";
1065 1091
				$update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
1066 1092
			}

Also available in: Unified diff