1
|
<?php
|
2
|
/*
|
3
|
* PHP.updateDNS (pfSense version)
|
4
|
*
|
5
|
* +====================================================+
|
6
|
* Services Supported:
|
7
|
* - DynDns (dyndns.org) [dynamic, static, custom]
|
8
|
* - No-IP (no-ip.com)
|
9
|
* - EasyDNS (easydns.com)
|
10
|
* - DHS (www.dhs.org)
|
11
|
* - HN (hn.org) -- incomplete checking!
|
12
|
* - DynS (dyns.org)
|
13
|
* - ZoneEdit (zoneedit.com)
|
14
|
* - FreeDNS (freedns.afraid.org)
|
15
|
* - Loopia (loopia.se)
|
16
|
* - StaticCling (staticcling.org)
|
17
|
* - DNSexit (dnsexit.com)
|
18
|
* - OpenDNS (opendns.com)
|
19
|
* - Namecheap (namecheap.com)
|
20
|
* - HE.net (dns.he.net)
|
21
|
* - HE.net IPv6 (dns.he.net)
|
22
|
* - HE.net Tunnelbroker IP update (ipv4.tunnelbroker.net)
|
23
|
* - SelfHost (selfhost.de)
|
24
|
* - Amazon Route 53 (aws.amazon.com)
|
25
|
* - DNS-O-Matic (dnsomatic.com)
|
26
|
* - Custom DDNS (any URL)
|
27
|
* - Custom DDNS IPv6 (any URL)
|
28
|
* - CloudFlare (www.cloudflare.com)
|
29
|
* - Eurodns (eurodns.com)
|
30
|
* - GratisDNS (gratisdns.dk)
|
31
|
* - City Network (citynetwork.se)
|
32
|
* - GleSYS (glesys.com)
|
33
|
* - DNSimple (dnsimple.com)
|
34
|
* - Google Domains (domains.google.com)
|
35
|
* - DNS Made Easy (www.dnsmadeeasy.com)
|
36
|
* - SPDNS (spdns.de)
|
37
|
* - SPDNS IPv6 (spdns.de)
|
38
|
* +----------------------------------------------------+
|
39
|
* Requirements:
|
40
|
* - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library
|
41
|
* +----------------------------------------------------+
|
42
|
* Public Functions
|
43
|
* - updatedns()
|
44
|
*
|
45
|
* Private Functions
|
46
|
* - _update()
|
47
|
* - _checkStatus()
|
48
|
* - _error()
|
49
|
* - _detectChange()
|
50
|
* - _debug()
|
51
|
* - _checkIP()
|
52
|
* +----------------------------------------------------+
|
53
|
* DynDNS Dynamic - Last Tested: 12 July 2005
|
54
|
* DynDNS Static - Last Tested: NEVER
|
55
|
* DynDNS Custom - Last Tested: NEVER
|
56
|
* No-IP - Last Tested: 20 July 2008
|
57
|
* HN.org - Last Tested: 12 July 2005
|
58
|
* EasyDNS - Last Tested: 20 July 2008
|
59
|
* DHS - Last Tested: 12 July 2005
|
60
|
* ZoneEdit - Last Tested: NEVER
|
61
|
* Dyns - Last Tested: NEVER
|
62
|
* ODS - Last Tested: 02 August 2005
|
63
|
* FreeDNS - Last Tested: 23 Feb 2011
|
64
|
* Loopia - Last Tested: NEVER
|
65
|
* StaticCling - Last Tested: 27 April 2006
|
66
|
* DNSexit - Last Tested: 20 July 2008
|
67
|
* OpenDNS - Last Tested: 4 August 2008
|
68
|
* Namecheap - Last Tested: 31 August 2010
|
69
|
* HE.net - Last Tested: 7 July 2013
|
70
|
* HE.net IPv6 - Last Tested: 7 July 2013
|
71
|
* HE.net Tunnel - Last Tested: 28 June 2011
|
72
|
* SelfHost - Last Tested: 26 December 2011
|
73
|
* Amazon Route 53 - Last tested: 01 April 2012
|
74
|
* DNS-O-Matic - Last Tested: 9 September 2010
|
75
|
* CloudFlare - Last Tested: 30 May 2013
|
76
|
* Eurodns - Last Tested: 27 June 2013
|
77
|
* GratisDNS - Last Tested: 15 August 2012
|
78
|
* OVH DynHOST - Last Tested: NEVER
|
79
|
* City Network - Last Tested: 13 November 2013
|
80
|
* GleSYS - Last Tested: 3 February 2015
|
81
|
* DNSimple - Last Tested: 09 February 2015
|
82
|
* Google Domains - Last Tested: 27 April 2015
|
83
|
* DNS Made Easy - Last Tested: 27 April 2015
|
84
|
* SPDNS - Last Tested: 04 December 2015
|
85
|
* SPDNS IPv6 - Last Tested: 04 December 2015
|
86
|
* +====================================================+
|
87
|
*
|
88
|
* @author E.Kristensen
|
89
|
* @link http://www.idylldesigns.com/projects/phpdns/
|
90
|
* @version 0.8
|
91
|
* @updated 13 October 05 at 21:02:42 GMT
|
92
|
*
|
93
|
* DNSexit/OpenDNS support and multiwan extension for pfSense by Ermal Luçi
|
94
|
* Custom DNS support by Matt Corallo
|
95
|
*
|
96
|
*/
|
97
|
|
98
|
class updatedns {
|
99
|
var $_cacheFile;
|
100
|
var $_cacheFile_v6;
|
101
|
var $_debugFile;
|
102
|
var $_UserAgent = 'User-Agent: phpDynDNS/0.7';
|
103
|
var $_errorVerbosity = 0;
|
104
|
var $_dnsService;
|
105
|
var $_dnsUser;
|
106
|
var $_dnsPass;
|
107
|
var $_dnsHost;
|
108
|
var $_dnsIP;
|
109
|
var $_dnsWildcard;
|
110
|
var $_dnsMX;
|
111
|
var $_dnsBackMX;
|
112
|
var $_dnsServer;
|
113
|
var $_dnsPort;
|
114
|
var $_dnsUpdateURL;
|
115
|
var $_dnsZoneID;
|
116
|
var $_dnsTTL;
|
117
|
var $status;
|
118
|
var $_debugID;
|
119
|
var $_if;
|
120
|
var $_dnsResultMatch;
|
121
|
var $_dnsRequestIf;
|
122
|
var $_dnsRequestIfIP;
|
123
|
var $_dnsVerboseLog;
|
124
|
var $_curlIpresolveV4;
|
125
|
var $_curlSslVerifypeer;
|
126
|
var $_dnsMaxCacheAgeDays;
|
127
|
var $_dnsDummyUpdateDone;
|
128
|
var $_forceUpdateNeeded;
|
129
|
var $_useIPv6;
|
130
|
|
131
|
/*
|
132
|
* Public Constructor Function (added 12 July 05) [beta]
|
133
|
* - Gets the dice rolling for the update.
|
134
|
* - $dnsResultMatch should only be used with $dnsService = 'custom'
|
135
|
* - $dnsResultMatch is parsed for '%IP%', which is the IP the provider was updated to,
|
136
|
* - it is otherwise expected to be exactly identical to what is returned by the Provider.
|
137
|
* - $dnsUser, and $dnsPass indicate HTTP Auth for custom DNS, if they are needed in the URL (GET Variables), include them in $dnsUpdateURL.
|
138
|
* - $For custom requests, $dnsUpdateURL is parsed for '%IP%', which is replaced with the new IP.
|
139
|
*/
|
140
|
function updatedns ($dnsService = '', $dnsHost = '', $dnsUser = '', $dnsPass = '',
|
141
|
$dnsWildcard = 'OFF', $dnsMX = '', $dnsIf = '', $dnsBackMX = '',
|
142
|
$dnsServer = '', $dnsPort = '', $dnsUpdateURL = '', $forceUpdate = false,
|
143
|
$dnsZoneID ='', $dnsTTL='', $dnsResultMatch = '', $dnsRequestIf = '',
|
144
|
$dnsID = '', $dnsVerboseLog = false, $curlIpresolveV4 = false, $curlSslVerifypeer = true) {
|
145
|
|
146
|
global $config, $g;
|
147
|
|
148
|
$this->_cacheFile = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.cache";
|
149
|
$this->_cacheFile_v6 = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}_v6.cache";
|
150
|
$this->_debugFile = "{$g['varetc_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.debug";
|
151
|
|
152
|
$this->_curlIpresolveV4 = $curlIpresolveV4;
|
153
|
$this->_curlSslVerifypeer = $curlSslVerifypeer;
|
154
|
$this->_dnsVerboseLog = $dnsVerboseLog;
|
155
|
if ($this->_dnsVerboseLog) {
|
156
|
log_error("DynDns: updatedns() starting");
|
157
|
}
|
158
|
|
159
|
$dyndnslck = lock("DDNS".$dnsID, LOCK_EX);
|
160
|
|
161
|
if (!$dnsService) $this->_error(2);
|
162
|
switch ($dnsService) {
|
163
|
case 'freedns':
|
164
|
if (!$dnsHost) $this->_error(5);
|
165
|
break;
|
166
|
case 'namecheap':
|
167
|
if (!$dnsPass) $this->_error(4);
|
168
|
if (!$dnsHost) $this->_error(5);
|
169
|
break;
|
170
|
case 'route53':
|
171
|
if (!$dnsZoneID) $this->_error(8);
|
172
|
if (!$dnsTTL) $this->_error(9);
|
173
|
break;
|
174
|
case 'custom':
|
175
|
if (!$dnsUpdateURL) $this->_error(7);
|
176
|
break;
|
177
|
default:
|
178
|
if (!$dnsUser) $this->_error(3);
|
179
|
if (!$dnsPass) $this->_error(4);
|
180
|
if (!$dnsHost) $this->_error(5);
|
181
|
}
|
182
|
|
183
|
switch ($dnsService) {
|
184
|
case 'he-net-v6':
|
185
|
case 'custom-v6':
|
186
|
case 'spdns-v6':
|
187
|
$this->_useIPv6 = true;
|
188
|
break;
|
189
|
default:
|
190
|
$this->_useIPv6 = false;
|
191
|
}
|
192
|
$this->_dnsService = strtolower($dnsService);
|
193
|
$this->_dnsUser = $dnsUser;
|
194
|
$this->_dnsPass = $dnsPass;
|
195
|
$this->_dnsHost = $dnsHost;
|
196
|
$this->_dnsServer = $dnsServer;
|
197
|
$this->_dnsPort = $dnsPort;
|
198
|
$this->_dnsWildcard = $dnsWildcard;
|
199
|
$this->_dnsMX = $dnsMX;
|
200
|
$this->_dnsZoneID = $dnsZoneID;
|
201
|
$this->_dnsTTL = $dnsTTL;
|
202
|
$this->_if = get_failover_interface($dnsIf);
|
203
|
$this->_checkIP();
|
204
|
$this->_dnsUpdateURL = $dnsUpdateURL;
|
205
|
$this->_dnsResultMatch = $dnsResultMatch;
|
206
|
$this->_dnsRequestIf = get_failover_interface($dnsRequestIf);
|
207
|
if ($this->_dnsVerboseLog) {
|
208
|
log_error("DynDNS ({$this->_dnsHost}): running get_failover_interface for {$dnsRequestIf}. found {$this->_dnsRequestIf}");
|
209
|
}
|
210
|
$this->_dnsRequestIfIP = get_interface_ip($dnsRequestIf);
|
211
|
$this->_dnsMaxCacheAgeDays = 25;
|
212
|
$this->_dnsDummyUpdateDone = false;
|
213
|
$this->_forceUpdateNeeded = $forceUpdate;
|
214
|
|
215
|
// Ensure that we were able to lookup the IP
|
216
|
if (!is_ipaddr($this->_dnsIP)) {
|
217
|
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.");
|
218
|
unlock($dyndnslck);
|
219
|
return;
|
220
|
}
|
221
|
|
222
|
$this->_debugID = rand(1000000, 9999999);
|
223
|
|
224
|
if ($forceUpdate == false && $this->_detectChange() == false) {
|
225
|
$this->_error(10);
|
226
|
} else {
|
227
|
switch ($this->_dnsService) {
|
228
|
case 'glesys':
|
229
|
case 'dnsomatic':
|
230
|
case 'dyndns':
|
231
|
case 'dyndns-static':
|
232
|
case 'dyndns-custom':
|
233
|
case 'dhs':
|
234
|
case 'noip':
|
235
|
case 'noip-free':
|
236
|
case 'easydns':
|
237
|
case 'hn':
|
238
|
case 'zoneedit':
|
239
|
case 'dyns':
|
240
|
case 'ods':
|
241
|
case 'freedns':
|
242
|
case 'loopia':
|
243
|
case 'staticcling':
|
244
|
case 'dnsexit':
|
245
|
case 'custom':
|
246
|
case 'custom-v6':
|
247
|
case 'opendns':
|
248
|
case 'namecheap':
|
249
|
case 'he-net':
|
250
|
case 'he-net-v6':
|
251
|
case 'selfhost':
|
252
|
case 'he-net-tunnelbroker':
|
253
|
case 'route53':
|
254
|
case 'cloudflare':
|
255
|
case 'eurodns':
|
256
|
case 'gratisdns':
|
257
|
case 'ovh-dynhost':
|
258
|
case 'citynetwork':
|
259
|
case 'dnsimple':
|
260
|
case 'googledomains':
|
261
|
case 'dnsmadeeasy':
|
262
|
case 'spdns':
|
263
|
case 'spdns-v6':
|
264
|
$this->_update();
|
265
|
if ($this->_dnsDummyUpdateDone == true) {
|
266
|
// If a dummy update was needed, then sleep a while and do the update again to put the proper address back.
|
267
|
// Some providers (e.g. No-IP free accounts) need to have at least 1 address change every month.
|
268
|
// If the address has not changed recently, or the user did "Force Update", then the code does
|
269
|
// a dummy address change for providers like this.
|
270
|
sleep(10);
|
271
|
$this->_update();
|
272
|
}
|
273
|
break;
|
274
|
default:
|
275
|
$this->_error(6);
|
276
|
break;
|
277
|
}
|
278
|
}
|
279
|
|
280
|
unlock($dyndnslck);
|
281
|
}
|
282
|
|
283
|
/*
|
284
|
* Private Function (added 12 July 05) [beta]
|
285
|
* Send Update To Selected Service.
|
286
|
*/
|
287
|
function _update() {
|
288
|
|
289
|
if ($this->_dnsVerboseLog) {
|
290
|
log_error("DynDNS ({$this->_dnsHost}): DynDns _update() starting.");
|
291
|
}
|
292
|
|
293
|
if (strstr($this->_dnsRequestIf, "_vip")) {
|
294
|
$parentif = link_carp_interface_to_parent($this->_dnsRequestIf);
|
295
|
$realparentif = convert_friendly_interface_to_real_interface_name($parentif);
|
296
|
} else {
|
297
|
$realparentif = $this->_dnsRequestIf;
|
298
|
}
|
299
|
|
300
|
$ch = curl_init();
|
301
|
|
302
|
if ($this->_useIPv6 == false) {
|
303
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
304
|
}
|
305
|
|
306
|
if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53 ') {
|
307
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
308
|
curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent);
|
309
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
310
|
curl_setopt($ch, CURLOPT_INTERFACE, 'if!' . $realparentif);
|
311
|
curl_setopt($ch, CURLOPT_TIMEOUT, 120); // Completely empirical
|
312
|
}
|
313
|
|
314
|
switch ($this->_dnsService) {
|
315
|
case 'glesys':
|
316
|
$needsIP = TRUE;
|
317
|
if ($this->_dnsVerboseLog) {
|
318
|
log_error("DynDNS: ({$this->_dnsHost}) DNS update() starting.");
|
319
|
}
|
320
|
$server = 'https://api.glesys.com/domain/updaterecord/format/json';
|
321
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
322
|
$post_data['recordid'] = $this->_dnsHost;
|
323
|
$post_data['data'] = $this->_dnsIP;
|
324
|
curl_setopt($ch, CURLOPT_URL, $server);
|
325
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
326
|
break;
|
327
|
case 'dyndns':
|
328
|
case 'dyndns-static':
|
329
|
case 'dyndns-custom':
|
330
|
$needsIP = FALSE;
|
331
|
if ($this->_dnsVerboseLog) {
|
332
|
log_error("DynDNS: ({$this->_dnsHost}) DNS update() starting.");
|
333
|
}
|
334
|
if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") {
|
335
|
$this->_dnsWildcard = "ON";
|
336
|
}
|
337
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
338
|
$server = "https://members.dyndns.org/nic/update";
|
339
|
$port = "";
|
340
|
if ($this->_dnsServer) {
|
341
|
$server = $this->_dnsServer;
|
342
|
}
|
343
|
if ($this->_dnsPort) {
|
344
|
$port = ":" . $this->_dnsPort;
|
345
|
}
|
346
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
|
347
|
break;
|
348
|
case 'dhs':
|
349
|
// DHS is disabled in the GUI because the following doesn't work.
|
350
|
$needsIP = TRUE;
|
351
|
$post_data['hostscmd'] = 'edit';
|
352
|
$post_data['hostscmdstage'] = '2';
|
353
|
$post_data['type'] = '4';
|
354
|
$post_data['updatetype'] = 'Online';
|
355
|
$post_data['mx'] = $this->_dnsMX;
|
356
|
$post_data['mx2'] = '';
|
357
|
$post_data['txt'] = '';
|
358
|
$post_data['offline_url'] = '';
|
359
|
$post_data['cloak'] = 'Y';
|
360
|
$post_data['cloak_title'] = '';
|
361
|
$post_data['ip'] = $this->_dnsIP;
|
362
|
$post_data['domain'] = 'dyn.dhs.org';
|
363
|
$post_data['hostname'] = $this->_dnsHost;
|
364
|
$post_data['submit'] = 'Update';
|
365
|
$server = "https://members.dhs.org/nic/hosts";
|
366
|
$port = "";
|
367
|
if ($this->_dnsServer) {
|
368
|
$server = $this->_dnsServer;
|
369
|
}
|
370
|
if ($this->_dnsPort) {
|
371
|
$port = ":" . $this->_dnsPort;
|
372
|
}
|
373
|
curl_setopt($ch, CURLOPT_URL, $server . $port);
|
374
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
375
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
376
|
break;
|
377
|
case 'noip':
|
378
|
case 'noip-free':
|
379
|
$needsIP = TRUE;
|
380
|
$server = "https://dynupdate.no-ip.com/ducupdate.php";
|
381
|
$port = "";
|
382
|
if ($this->_dnsServer) {
|
383
|
$server = $this->_dnsServer;
|
384
|
}
|
385
|
if ($this->_dnsPort) {
|
386
|
$port = ":" . $this->_dnsPort;
|
387
|
}
|
388
|
if (($this->_dnsService == "noip-free") &&
|
389
|
($this->_forceUpdateNeeded == true) &&
|
390
|
($this->_dnsDummyUpdateDone == false)) {
|
391
|
// Update the IP to a dummy value to force No-IP free accounts to see a change.
|
392
|
$iptoset = "192.168.1.1";
|
393
|
$this->_dnsDummyUpdateDone = true;
|
394
|
log_error("DynDNS ({$this->_dnsHost}): Processing dummy update on No-IP free account. IP temporarily set to " . $iptoset);
|
395
|
} else {
|
396
|
$iptoset = $this->_dnsIP;
|
397
|
}
|
398
|
curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $iptoset);
|
399
|
break;
|
400
|
case 'easydns':
|
401
|
$needsIP = TRUE;
|
402
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
403
|
$server = "https://members.easydns.com/dyn/dyndns.php";
|
404
|
$port = "";
|
405
|
if ($this->_dnsServer) {
|
406
|
$server = $this->_dnsServer;
|
407
|
}
|
408
|
if ($this->_dnsPort) {
|
409
|
$port = ":" . $this->_dnsPort;
|
410
|
}
|
411
|
curl_setopt($ch, CURLOPT_URL, $server . $port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard=' . $this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=' . $this->_dnsBackMX);
|
412
|
break;
|
413
|
case 'hn':
|
414
|
$needsIP = TRUE;
|
415
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
416
|
$server = "http://dup.hn.org/vanity/update";
|
417
|
$port = "";
|
418
|
if ($this->_dnsServer) {
|
419
|
$server = $this->_dnsServer;
|
420
|
}
|
421
|
if ($this->_dnsPort) {
|
422
|
$port = ":" . $this->_dnsPort;
|
423
|
}
|
424
|
curl_setopt($ch, CURLOPT_URL, $server . $port . '?ver=1&IP=' . $this->_dnsIP);
|
425
|
break;
|
426
|
case 'zoneedit':
|
427
|
$needsIP = FALSE;
|
428
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
429
|
|
430
|
$server = "https://dynamic.zoneedit.com/auth/dynamic.html";
|
431
|
$port = "";
|
432
|
if ($this->_dnsServer) {
|
433
|
$server = $this->_dnsServer;
|
434
|
}
|
435
|
if ($this->_dnsPort) {
|
436
|
$port = ":" . $this->_dnsPort;
|
437
|
}
|
438
|
curl_setopt($ch, CURLOPT_URL, "{$server}{$port}?host=" .$this->_dnsHost);
|
439
|
break;
|
440
|
case 'dyns':
|
441
|
$needsIP = FALSE;
|
442
|
$server = "https://www.dyns.cx/postscript011.php";
|
443
|
$port = "";
|
444
|
if ($this->_dnsServer) {
|
445
|
$server = $this->_dnsServer;
|
446
|
}
|
447
|
if ($this->_dnsPort) {
|
448
|
$port = ":" . $this->_dnsPort;
|
449
|
}
|
450
|
curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&password=' . $this->_dnsPass . '&host=' . $this->_dnsHost);
|
451
|
break;
|
452
|
case 'ods':
|
453
|
$needsIP = FALSE;
|
454
|
$misc_errno = 0;
|
455
|
$misc_error = "";
|
456
|
$server = "ods.org";
|
457
|
$port = "";
|
458
|
if ($this->_dnsServer) {
|
459
|
$server = $this->_dnsServer;
|
460
|
}
|
461
|
if ($this->_dnsPort) {
|
462
|
$port = ":" . $this->_dnsPort;
|
463
|
}
|
464
|
$this->con['socket'] = fsockopen("{$server}{$port}", "7070", $misc_errno, $misc_error, 30);
|
465
|
/* Check that we have connected */
|
466
|
if (!$this->con['socket']) {
|
467
|
print "error! could not connect.";
|
468
|
break;
|
469
|
}
|
470
|
/* Here is the loop. Read the incoming data (from the socket connection) */
|
471
|
while (!feof($this->con['socket'])) {
|
472
|
$this->con['buffer']['all'] = trim(fgets($this->con['socket'], 4096));
|
473
|
$code = substr($this->con['buffer']['all'], 0, 3);
|
474
|
sleep(1);
|
475
|
switch ($code) {
|
476
|
case 100:
|
477
|
fputs($this->con['socket'], "LOGIN ".$this->_dnsUser." ".$this->_dnsPass."\n");
|
478
|
break;
|
479
|
case 225:
|
480
|
fputs($this->con['socket'], "DELRR ".$this->_dnsHost." A\n");
|
481
|
break;
|
482
|
case 901:
|
483
|
fputs($this->con['socket'], "ADDRR ".$this->_dnsHost." A ".$this->_dnsIP."\n");
|
484
|
break;
|
485
|
case 795:
|
486
|
fputs($this->con['socket'], "QUIT\n");
|
487
|
break;
|
488
|
}
|
489
|
}
|
490
|
$this->_checkStatus(0, $code);
|
491
|
break;
|
492
|
case 'freedns':
|
493
|
$needIP = FALSE;
|
494
|
curl_setopt($ch, CURLOPT_URL, 'https://freedns.afraid.org/dynamic/update.php?' . $this->_dnsPass);
|
495
|
break;
|
496
|
case 'dnsexit':
|
497
|
$needsIP = TRUE;
|
498
|
curl_setopt($ch, CURLOPT_URL, 'https://www.dnsexit.com/RemoteUpdate.sv?login='.$this->_dnsUser. '&password='.$this->_dnsPass.'&host='.$this->_dnsHost.'&myip='.$this->_dnsIP);
|
499
|
break;
|
500
|
case 'loopia':
|
501
|
$needsIP = TRUE;
|
502
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
503
|
curl_setopt($ch, CURLOPT_URL, 'https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP);
|
504
|
break;
|
505
|
case 'opendns':
|
506
|
$needsIP = FALSE;
|
507
|
if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
|
508
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
509
|
$server = "https://updates.opendns.com/nic/update?hostname=". $this->_dnsHost;
|
510
|
$port = "";
|
511
|
if ($this->_dnsServer) {
|
512
|
$server = $this->_dnsServer;
|
513
|
}
|
514
|
if ($this->_dnsPort) {
|
515
|
$port = ":" . $this->_dnsPort;
|
516
|
}
|
517
|
curl_setopt($ch, CURLOPT_URL, $server .$port);
|
518
|
break;
|
519
|
|
520
|
case 'staticcling':
|
521
|
$needsIP = FALSE;
|
522
|
curl_setopt($ch, CURLOPT_URL, 'https://www.staticcling.org/update.html?login='.$this->_dnsUser.'&pass='.$this->_dnsPass);
|
523
|
break;
|
524
|
case 'dnsomatic':
|
525
|
/* Example syntax
|
526
|
https://username:password@updates.dnsomatic.com/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
|
527
|
*/
|
528
|
$needsIP = FALSE;
|
529
|
if ($this->_dnsVerboseLog) {
|
530
|
log_error("DNS-O-Matic: DNS update() starting.");
|
531
|
}
|
532
|
if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") {
|
533
|
$this->_dnsWildcard = "ON";
|
534
|
}
|
535
|
/*
|
536
|
Reference: https://www.dnsomatic.com/wiki/api
|
537
|
DNS-O-Matic usernames are 3-25 characters.
|
538
|
DNS-O-Matic passwords are 6-20 characters.
|
539
|
All ASCII letters and numbers accepted.
|
540
|
Dots, dashes, and underscores allowed, but not at the beginning or end of the string.
|
541
|
Required: "rawurlencode" http://www.php.net/manual/en/function.rawurlencode.php
|
542
|
Encodes the given string according to RFC 3986.
|
543
|
*/
|
544
|
$server = "https://" . rawurlencode($this->_dnsUser) . ":" . rawurlencode($this->_dnsPass) . "@updates.dnsomatic.com/nic/update?hostname=";
|
545
|
if ($this->_dnsServer) {
|
546
|
$server = $this->_dnsServer;
|
547
|
}
|
548
|
if ($this->_dnsPort) {
|
549
|
$port = ":" . $this->_dnsPort;
|
550
|
}
|
551
|
curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NOCHG');
|
552
|
break;
|
553
|
case 'namecheap':
|
554
|
/* Example:
|
555
|
https://dynamicdns.park-your-domain.com/update?host=[host_name]&domain=[domain.com]&password=[domain_password]&ip=[your_ip]
|
556
|
*/
|
557
|
$needsIP = FALSE;
|
558
|
if ($this->_dnsVerboseLog) {
|
559
|
log_error("Namecheap ({$this->_dnsHost}): DNS update() starting.");
|
560
|
}
|
561
|
$dparts = explode(".", trim($this->_dnsHost));
|
562
|
$domain_part_count = ($dparts[count($dparts)-1] == "uk") ? 3 : 2;
|
563
|
$domain_offset = count($dparts) - $domain_part_count;
|
564
|
$hostname = implode(".", array_slice($dparts, 0, $domain_offset));
|
565
|
$domain = implode(".", array_slice($dparts, $domain_offset));
|
566
|
$dnspass = trim($this->_dnsPass);
|
567
|
$server = "https://dynamicdns.park-your-domain.com/update?host={$hostname}&domain={$domain}&password={$dnspass}&ip={$this->_dnsIP}";
|
568
|
curl_setopt($ch, CURLOPT_URL, $server);
|
569
|
break;
|
570
|
case 'he-net':
|
571
|
case 'he-net-v6':
|
572
|
$needsIP = FALSE;
|
573
|
if ($this->_dnsVerboseLog) {
|
574
|
log_error("HE.net ({$this->_dnsHost}): DNS update() starting.");
|
575
|
}
|
576
|
$server = "https://dyn.dns.he.net/nic/update?";
|
577
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
578
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
579
|
curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost . '&password=' . $this->_dnsPass . '&myip=' . $this->_dnsIP);
|
580
|
break;
|
581
|
case 'he-net-tunnelbroker':
|
582
|
$needsIP = FALSE;
|
583
|
if ($this->_dnsVerboseLog) {
|
584
|
log_error("HE.net Tunnelbroker: DNS update() starting.");
|
585
|
}
|
586
|
$server = "https://ipv4.tunnelbroker.net/ipv4_end.php?";
|
587
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser . ':' . $this->_dnsPass);
|
588
|
curl_setopt($ch, CURLOPT_URL, $server . 'tid=' . $this->_dnsHost);
|
589
|
break;
|
590
|
case 'selfhost':
|
591
|
$needsIP = FALSE;
|
592
|
if ($this->_dnsVerboseLog) {
|
593
|
log_error("SelfHost: DNS update() starting.");
|
594
|
}
|
595
|
if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") {
|
596
|
$this->_dnsWildcard = "ON";
|
597
|
}
|
598
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
599
|
$server = "https://carol.selfhost.de/nic/update";
|
600
|
$port = "";
|
601
|
if ($this->_dnsServer) {
|
602
|
$server = $this->_dnsServer;
|
603
|
}
|
604
|
if ($this->_dnsPort) {
|
605
|
$port = ":" . $this->_dnsPort;
|
606
|
}
|
607
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
|
608
|
break;
|
609
|
case 'route53':
|
610
|
if ($this->_dnsVerboseLog) {
|
611
|
log_error("Route53 ({$this->_dnsHost}): DNS update() starting.");
|
612
|
}
|
613
|
|
614
|
/* Setting Variables */
|
615
|
$hostname = "{$this->_dnsHost}.";
|
616
|
$ZoneID = $this->_dnsZoneID;
|
617
|
$AccessKeyId = $this->_dnsUser;
|
618
|
$SecretAccessKey = $this->_dnsPass;
|
619
|
$NewIP = $this->_dnsIP;
|
620
|
$NewTTL = $this->_dnsTTL;
|
621
|
|
622
|
/* Include Route 53 Library Class */
|
623
|
require_once('/etc/inc/r53.class');
|
624
|
|
625
|
/* Set Amazon AWS Credentials for this record */
|
626
|
$r53 = new Route53($AccessKeyId, $SecretAccessKey);
|
627
|
|
628
|
/* Function to find old values of records in Route 53 */
|
629
|
if (!function_exists('Searchrecords')) {
|
630
|
function SearchRecords($records, $name) {
|
631
|
$result = array();
|
632
|
foreach ($records as $record) {
|
633
|
if (strtolower($record['Name']) == strtolower($name)) {
|
634
|
$result [] = $record;
|
635
|
}
|
636
|
}
|
637
|
return ($result) ? $result : false;
|
638
|
}
|
639
|
}
|
640
|
|
641
|
$records = $r53->listResourceRecordSets("/hostedzone/$ZoneID");
|
642
|
|
643
|
/* Get IP for your hostname in Route 53 */
|
644
|
if (false !== ($a_result = SearchRecords($records['ResourceRecordSets'], "$hostname"))) {
|
645
|
$OldTTL = $a_result[0][TTL];
|
646
|
$OldIP = $a_result[0][ResourceRecords][0];
|
647
|
} else {
|
648
|
$OldIP = "";
|
649
|
}
|
650
|
|
651
|
/* Check if we need to update DNS Record */
|
652
|
if ($OldIP !== $NewIP) {
|
653
|
if (!empty($OldIP)) {
|
654
|
/* Your Hostname already exists, deleting and creating it again */
|
655
|
$changes = array();
|
656
|
$changes[] = $r53->prepareChange(DELETE, $hostname, A, $OldTTL, $OldIP);
|
657
|
$changes[] = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
|
658
|
$result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
|
659
|
} else {
|
660
|
/* Your Hostname does not exist yet, creating it */
|
661
|
$changes = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
|
662
|
$result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
|
663
|
}
|
664
|
}
|
665
|
$this->_checkStatus(0, $result);
|
666
|
break;
|
667
|
case 'custom':
|
668
|
case 'custom-v6':
|
669
|
if ($this->_dnsVerboseLog) {
|
670
|
log_error("Custom DDNS ({$this->_dnsHost}): DNS update() starting.");
|
671
|
}
|
672
|
if (strstr($this->dnsUpdateURL, "%IP%")) {$needsIP = TRUE;} else {$needsIP = FALSE;}
|
673
|
if ($this->_dnsUser != '') {
|
674
|
if ($this->_curlIpresolveV4) {
|
675
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
676
|
}
|
677
|
if ($this->_curlSslVerifypeer) {
|
678
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
|
679
|
} else {
|
680
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
681
|
}
|
682
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
683
|
curl_setopt($ch, CURLOPT_USERPWD, "{$this->_dnsUser}:{$this->_dnsPass}");
|
684
|
}
|
685
|
$server = str_replace("%IP%", $this->_dnsIP, $this->_dnsUpdateURL);
|
686
|
if ($this->_dnsVerboseLog) {
|
687
|
log_error("Sending request to: ".$server);
|
688
|
}
|
689
|
curl_setopt($ch, CURLOPT_URL, $server);
|
690
|
break;
|
691
|
case 'cloudflare':
|
692
|
$needsIP = TRUE;
|
693
|
$dnsServer ='api.cloudflare.com';
|
694
|
$dnsHost = str_replace(' ', '', $this->_dnsHost);
|
695
|
$host_names = explode(".", $dnsHost);
|
696
|
$bottom_host_name = $host_names[count($host_names)-2] . "." . $host_names[count($host_names)-1];
|
697
|
|
698
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
699
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
700
|
'X-Auth-Email: '.$this->_dnsUser.'',
|
701
|
'X-Auth-Key: '.$this->_dnsPass.'',
|
702
|
'Content-Type: application/json'
|
703
|
));
|
704
|
|
705
|
// Get zone ID
|
706
|
$getZoneId = "https://{$dnsServer}/client/v4/zones/?name={$bottom_host_name}";
|
707
|
curl_setopt($ch, CURLOPT_URL, $getZoneId);
|
708
|
$output = json_decode(curl_exec($ch));
|
709
|
$zone = $output->result[0]->id;
|
710
|
if ($zone) { // If zone ID was found get host ID
|
711
|
$getHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records?name={$this->_dnsHost}";
|
712
|
curl_setopt($ch, CURLOPT_URL, $getHostId);
|
713
|
$output = json_decode(curl_exec($ch));
|
714
|
$host = $output->result[0]->id;
|
715
|
if ($host) { // If host ID was found update host
|
716
|
$hostData = array(
|
717
|
"content" => "{$this->_dnsIP}",
|
718
|
"type" => "A",
|
719
|
"name" => "{$this->_dnsHost}"
|
720
|
);
|
721
|
$data_json = json_encode($hostData);
|
722
|
$updateHostId = "https://{$dnsServer}/client/v4/zones/{$zone}/dns_records/{$host}";
|
723
|
curl_setopt($ch, CURLOPT_URL, $updateHostId);
|
724
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
725
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
|
726
|
}
|
727
|
}
|
728
|
break;
|
729
|
case 'eurodns':
|
730
|
$needsIP = TRUE;
|
731
|
if ($this->_dnsVerboseLog) {
|
732
|
log_error("EuroDynDns ({$this->_dnsHost}) DNS update() starting.");
|
733
|
}
|
734
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
735
|
$server = "https://update.eurodyndns.org/update/";
|
736
|
$port = "";
|
737
|
if ($this->_dnsPort) {
|
738
|
$port = ":" . $this->_dnsPort;
|
739
|
}
|
740
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP);
|
741
|
break;
|
742
|
case 'gratisdns':
|
743
|
$needsIP = TRUE;
|
744
|
if ($this->_dnsVerboseLog) {
|
745
|
log_error("GratisDNS.dk ({$this->_dnsHost}): DNS update() starting.");
|
746
|
}
|
747
|
$server = "https://ssl.gratisdns.dk/ddns.phtml";
|
748
|
$host = trim($this->_dnsHost);
|
749
|
$hostnames = explode(".", $host);
|
750
|
$hostnames_count = count($hostnames);
|
751
|
if ($hostnames_count > 2) {
|
752
|
$domain = $hostnames[$hostnames_count-2] . "." . $hostnames[$hostnames_count-1];
|
753
|
} else {
|
754
|
$domain = $host;
|
755
|
}
|
756
|
curl_setopt($ch, CURLOPT_URL, $server . '?u=' . $this->_dnsUser . '&p=' . $this->_dnsPass . '&h=' . $host . '&d=' . $domain . '&i=' . $this->_dnsIP);
|
757
|
break;
|
758
|
case 'ovh-dynhost':
|
759
|
$needsIP = FALSE;
|
760
|
if ($this->_dnsVerboseLog) {
|
761
|
log_error("OVH DynHOST: ({$this->_dnsHost}) DNS update() starting.");
|
762
|
}
|
763
|
if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
|
764
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
765
|
$server = "https://www.ovh.com/nic/update";
|
766
|
$port = "";
|
767
|
if ($this->_dnsServer) {
|
768
|
$server = $this->_dnsServer;
|
769
|
}
|
770
|
if ($this->_dnsPort) {
|
771
|
$port = ":" . $this->_dnsPort;
|
772
|
}
|
773
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
|
774
|
break;
|
775
|
case 'citynetwork':
|
776
|
$needsIP = TRUE;
|
777
|
if ($this->_dnsVerboseLog) {
|
778
|
log_error("City Network: ({$this->_dnsHost}) DNS update() starting.");
|
779
|
}
|
780
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
781
|
$server = 'https://dyndns.citynetwork.se/nic/update';
|
782
|
$port = "";
|
783
|
if ($this->_dnsServer) {
|
784
|
$server = $this->_dnsServer;
|
785
|
}
|
786
|
if ($this->_dnsPort) {
|
787
|
$port = ":" . $this->_dnsPort;
|
788
|
}
|
789
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP);
|
790
|
break;
|
791
|
case 'dnsimple':
|
792
|
/* Uses DNSimple's REST API
|
793
|
Requires username and Account API token passed in header
|
794
|
Piggybacks on Route 53's ZoneID field for DNSimple record ID
|
795
|
Data sent as JSON */
|
796
|
$needsIP = TRUE;
|
797
|
$server = 'https://api.dnsimple.com/v1/domains/';
|
798
|
$token = $this->_dnsUser . ':' . $this->_dnsPass;
|
799
|
$jsondata = '{"record":{"content":"' . $this->_dnsIP . '","ttl":"' . $this->_dnsTTL . '"}}';
|
800
|
curl_setopt($ch, CURLOPT_HEADER, 1);
|
801
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
802
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json', 'X-DNSimple-Token: ' . $token));
|
803
|
curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '/records/' . $this->_dnsZoneID);
|
804
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata);
|
805
|
break;
|
806
|
case 'googledomains':
|
807
|
$needsIP = FALSE;
|
808
|
if ($this->_dnsVerboseLog) {
|
809
|
log_error("Google Domains: ({$this->_dnsHost}) DNS update() starting.");
|
810
|
}
|
811
|
$post_data['username:password'] = $this->_dnsUser . ':' . $this->_dnsPass;
|
812
|
$post_data['hostname'] = $this->_dnsHost;
|
813
|
$post_data['myip'] = $this->_dnsIP;
|
814
|
$post_data['offline'] = 'no';
|
815
|
$server = "https://domains.google.com/nic/update";
|
816
|
$port = "";
|
817
|
curl_setopt($ch, CURLOPT_URL, 'https://domains.google.com/nic/update');
|
818
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
819
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
820
|
break;
|
821
|
case 'dnsmadeeasy':
|
822
|
$needsIP = TRUE;
|
823
|
if ($this->_dnsVerboseLog) {
|
824
|
log_error("DNS Made Easy ({$this->_dnsHost}): DNS update() starting.");
|
825
|
}
|
826
|
$server = "https://cp.dnsmadeeasy.com/servlet/updateip";
|
827
|
curl_setopt($ch, CURLOPT_URL, $server . '?username=' . $this->_dnsUser . '&password=' . $this->_dnsPass . '&id=' . $this->_dnsHost . '&ip=' . $this->_dnsIP);
|
828
|
break;
|
829
|
case 'spdns':
|
830
|
case 'spdns-v6':
|
831
|
$needsIP = FALSE;
|
832
|
if ($this->_dnsVerboseLog) {
|
833
|
log_error("SPDNS: ({$this->_dnsHost}) DNS update() starting.");
|
834
|
}
|
835
|
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
|
836
|
$server = "https://update.spdns.de/nic/update";
|
837
|
$port = "";
|
838
|
if ($this->_dnsServer) {
|
839
|
$server = $this->_dnsServer;
|
840
|
}
|
841
|
if ($this->_dnsPort) {
|
842
|
$port = ":" . $this->_dnsPort;
|
843
|
}
|
844
|
curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP);
|
845
|
break;
|
846
|
default:
|
847
|
break;
|
848
|
}
|
849
|
if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53') {
|
850
|
$data = curl_exec($ch);
|
851
|
$this->_checkStatus($ch, $data);
|
852
|
@curl_close($ch);
|
853
|
}
|
854
|
}
|
855
|
|
856
|
/*
|
857
|
* Private Function (added 12 July 2005) [beta]
|
858
|
* Retrieve Update Status
|
859
|
*/
|
860
|
function _checkStatus($ch, $data) {
|
861
|
if ($this->_dnsVerboseLog) {
|
862
|
log_error("DynDNS ({$this->_dnsHost}): DynDns _checkStatus() starting.");
|
863
|
log_error("DynDNS ({$this->_dnsHost}): Current Service: {$this->_dnsService}");
|
864
|
}
|
865
|
$successful_update = false;
|
866
|
if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53' && @curl_error($ch)) {
|
867
|
$status = "Curl error occurred: " . curl_error($ch);
|
868
|
log_error($status);
|
869
|
$this->status = $status;
|
870
|
return;
|
871
|
}
|
872
|
switch ($this->_dnsService) {
|
873
|
case 'glesys':
|
874
|
if (preg_match('/Record updated/i', $data)) {
|
875
|
$status = "GleSYS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
876
|
$successful_update = true;
|
877
|
} else {
|
878
|
$status = "GleSYS ({$this->_dnsHost}): (Unknown Response)";
|
879
|
log_error("GleSYS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
880
|
$this->_debug($data);
|
881
|
}
|
882
|
break;
|
883
|
case 'dnsomatic':
|
884
|
if (preg_match('/badauth/i', $data)) {
|
885
|
$status = "DNS-O-Matic ({$this->_dnsHost}): The DNS-O-Matic username or password specified are incorrect. No updates will be distributed to services until this is resolved.";
|
886
|
} else if (preg_match('/notfqdn /i', $data)) {
|
887
|
$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname specified is not a fully-qualified domain name. If no hostnames included, notfqdn will be returned once.";
|
888
|
} else if (preg_match('/nohost/i', $data)) {
|
889
|
$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname passed could not be matched to any services configured. The service field will be blank in the return code.";
|
890
|
} else if (preg_match('/numhost/i', $data)) {
|
891
|
$status = "DNS-O-Matic ({$this->_dnsHost}): You may update up to 20 hosts. numhost is returned if you try to update more than 20 or update a round-robin.";
|
892
|
} else if (preg_match('/abuse/i', $data)) {
|
893
|
$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname is blocked for update abuse.";
|
894
|
} else if (preg_match('/good/i', $data)) {
|
895
|
$status = "DNS-O-Matic ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
896
|
$successful_update = true;
|
897
|
} else if (preg_match('/dnserr/i', $data)) {
|
898
|
$status = "DNS-O-Matic ({$this->_dnsHost}): DNS error encountered. Stop updating for 30 minutes.";
|
899
|
} else {
|
900
|
$status = "DNS-O-Matic ({$this->_dnsHost}): (Unknown Response)";
|
901
|
log_error("DNS-O-Matic ({$this->_dnsHost}): PAYLOAD: {$data}");
|
902
|
$this->_debug($data);
|
903
|
}
|
904
|
break;
|
905
|
case 'citynetwork':
|
906
|
if (preg_match('/notfqdn/i', $data)) {
|
907
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
|
908
|
} else if (preg_match('/nohost/i', $data)) {
|
909
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) No such host";
|
910
|
} else if (preg_match('/nochg/i', $data)) {
|
911
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
912
|
$successful_update = true;
|
913
|
} else if (preg_match('/good/i', $data)) {
|
914
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
915
|
$successful_update = true;
|
916
|
} else if (preg_match('/badauth/i', $data)) {
|
917
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
918
|
} else {
|
919
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
920
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
921
|
$this->_debug($data);
|
922
|
}
|
923
|
break;
|
924
|
case 'ovh-dynhost':
|
925
|
case 'dyndns':
|
926
|
if (preg_match('/notfqdn/i', $data)) {
|
927
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
|
928
|
} else if (preg_match('/nochg/i', $data)) {
|
929
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
930
|
$successful_update = true;
|
931
|
} else if (preg_match('/good/i', $data)) {
|
932
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
933
|
$successful_update = true;
|
934
|
} else if (preg_match('/noauth/i', $data)) {
|
935
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
936
|
} else {
|
937
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
938
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
939
|
$this->_debug($data);
|
940
|
}
|
941
|
break;
|
942
|
case 'dyndns-static':
|
943
|
if (preg_match('/notfqdn/i', $data)) {
|
944
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
|
945
|
} else if (preg_match('/nochg/i', $data)) {
|
946
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
947
|
$successful_update = true;
|
948
|
} else if (preg_match('/good/i', $data)) {
|
949
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
|
950
|
$successful_update = true;
|
951
|
} else if (preg_match('/noauth/i', $data)) {
|
952
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
953
|
} else {
|
954
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
955
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
956
|
$this->_debug($data);
|
957
|
}
|
958
|
break;
|
959
|
case 'dyndns-custom':
|
960
|
if (preg_match('/notfqdn/i', $data)) {
|
961
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
|
962
|
} else if (preg_match('/nochg/i', $data)) {
|
963
|
$status = "phpDynDNS: (Success) No Change In IP Address";
|
964
|
$successful_update = true;
|
965
|
} else if (preg_match('/good/i', $data)) {
|
966
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
|
967
|
$successful_update = true;
|
968
|
} else if (preg_match('/noauth/i', $data)) {
|
969
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
970
|
} else {
|
971
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
972
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
973
|
$this->_debug($data);
|
974
|
}
|
975
|
break;
|
976
|
case 'dhs':
|
977
|
break;
|
978
|
case 'noip':
|
979
|
case 'noip-free':
|
980
|
list($ip, $code) = explode(":", $data);
|
981
|
switch ($code) {
|
982
|
case 0:
|
983
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP address is current, no update performed.";
|
984
|
$successful_update = true;
|
985
|
break;
|
986
|
case 1:
|
987
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS hostname update successful.";
|
988
|
$successful_update = true;
|
989
|
break;
|
990
|
case 2:
|
991
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname supplied does not exist.";
|
992
|
break;
|
993
|
case 3:
|
994
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid Username.";
|
995
|
break;
|
996
|
case 4:
|
997
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid Password.";
|
998
|
break;
|
999
|
case 5:
|
1000
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Too many updates sent.";
|
1001
|
break;
|
1002
|
case 6:
|
1003
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Account disabled due to violation of No-IP terms of service.";
|
1004
|
break;
|
1005
|
case 7:
|
1006
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid IP. IP Address submitted is improperly formatted or is a private IP address or is on a blacklist.";
|
1007
|
break;
|
1008
|
case 8:
|
1009
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Disabled / Locked Hostname.";
|
1010
|
break;
|
1011
|
case 9:
|
1012
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Host updated is configured as a web redirect and no update was performed.";
|
1013
|
break;
|
1014
|
case 10:
|
1015
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Group supplied does not exist.";
|
1016
|
break;
|
1017
|
case 11:
|
1018
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS group update is successful.";
|
1019
|
$successful_update = true;
|
1020
|
break;
|
1021
|
case 12:
|
1022
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS group is current, no update performed.";
|
1023
|
$successful_update = true;
|
1024
|
break;
|
1025
|
case 13:
|
1026
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Update client support not available for supplied hostname or group.";
|
1027
|
break;
|
1028
|
case 14:
|
1029
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname supplied does not have offline settings configured.";
|
1030
|
break;
|
1031
|
case 99:
|
1032
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Client disabled. Client should exit and not perform any more updates without user intervention.";
|
1033
|
break;
|
1034
|
case 100:
|
1035
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Client disabled. Client should exit and not perform any more updates without user intervention.";
|
1036
|
break;
|
1037
|
default:
|
1038
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1039
|
$this->_debug("Unknown Response: ".$data);
|
1040
|
break;
|
1041
|
}
|
1042
|
break;
|
1043
|
case 'easydns':
|
1044
|
if (preg_match('/NOACCESS/i', $data)) {
|
1045
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Authentication Failed: Username and/or Password was Incorrect.";
|
1046
|
} else if (preg_match('/NOSERVICE/i', $data)) {
|
1047
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) No Service: Dynamic DNS Service has been disabled for this domain.";
|
1048
|
} else if (preg_match('/ILLEGAL INPUT/i', $data)) {
|
1049
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Illegal Input: Self-Explanatory";
|
1050
|
} else if (preg_match('/TOOSOON/i', $data)) {
|
1051
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Too Soon: Not Enough Time Has Elapsed Since Last Update";
|
1052
|
} else if (preg_match('/NOERROR/i', $data)) {
|
1053
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Updated Successfully!";
|
1054
|
$successful_update = true;
|
1055
|
} else {
|
1056
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1057
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1058
|
$this->_debug($data);
|
1059
|
}
|
1060
|
break;
|
1061
|
case 'hn':
|
1062
|
/* FIXME: add checks */
|
1063
|
break;
|
1064
|
case 'zoneedit':
|
1065
|
if (preg_match('/799/i', $data)) {
|
1066
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error 799) Update Failed!";
|
1067
|
} else if (preg_match('/700/i', $data)) {
|
1068
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error 700) Update Failed!";
|
1069
|
} else if (preg_match('/200/i', $data)) {
|
1070
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1071
|
$successful_update = true;
|
1072
|
} else if (preg_match('/201/i', $data)) {
|
1073
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1074
|
$successful_update = true;
|
1075
|
} else {
|
1076
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1077
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1078
|
$this->_debug($data);
|
1079
|
}
|
1080
|
break;
|
1081
|
case 'dyns':
|
1082
|
if (preg_match("/400/i", $data)) {
|
1083
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - The URL was malformed. Required parameters were not provided.";
|
1084
|
} else if (preg_match('/402/i', $data)) {
|
1085
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Update Too Soon - You have tried updating to quickly since last change.";
|
1086
|
} else if (preg_match('/403/i', $data)) {
|
1087
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Database Error - There was a server-sided database error.";
|
1088
|
} else if (preg_match('/405/i', $data)) {
|
1089
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname Error - The hostname (".$this->_dnsHost.") doesn't belong to you.";
|
1090
|
} else if (preg_match('/200/i', $data)) {
|
1091
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1092
|
$successful_update = true;
|
1093
|
} else {
|
1094
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1095
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1096
|
$this->_debug($data);
|
1097
|
}
|
1098
|
break;
|
1099
|
case 'ods':
|
1100
|
if (preg_match("/299/i", $data)) {
|
1101
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1102
|
$successful_update = true;
|
1103
|
} else {
|
1104
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1105
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1106
|
$this->_debug($data);
|
1107
|
}
|
1108
|
break;
|
1109
|
case 'freedns':
|
1110
|
if (preg_match("/has not changed./i", $data)) {
|
1111
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
1112
|
$successful_update = true;
|
1113
|
} else if (preg_match("/Updated/i", $data)) {
|
1114
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
|
1115
|
$successful_update = true;
|
1116
|
} else {
|
1117
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1118
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1119
|
$this->_debug($data);
|
1120
|
}
|
1121
|
break;
|
1122
|
case 'dnsexit':
|
1123
|
if (preg_match("/is the same/i", $data)) {
|
1124
|
$status = "phpDynDns ({$this->_dnsHost}): (Success) No Change In IP Address";
|
1125
|
$successful_update = true;
|
1126
|
} else if (preg_match("/Success/i", $data)) {
|
1127
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
|
1128
|
$successful_update = true;
|
1129
|
} else {
|
1130
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1131
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1132
|
$this->_debug($data);
|
1133
|
}
|
1134
|
break;
|
1135
|
case 'loopia':
|
1136
|
if (preg_match("/nochg/i", $data)) {
|
1137
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
1138
|
$successful_update = true;
|
1139
|
} else if (preg_match("/good/i", $data)) {
|
1140
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
|
1141
|
$successful_update = true;
|
1142
|
} else if (preg_match('/badauth/i', $data)) {
|
1143
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
1144
|
} else {
|
1145
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1146
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1147
|
$this->_debug($data);
|
1148
|
}
|
1149
|
break;
|
1150
|
case 'opendns':
|
1151
|
if (preg_match('/badauth/i', $data)) {
|
1152
|
$status = "phpDynDNS({$this->_dnsHost}): (Error) Not a valid username or password!";
|
1153
|
} else if (preg_match('/nohost/i', $data)) {
|
1154
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname you are trying to update does not exist.";
|
1155
|
$successful_update = true;
|
1156
|
} else if (preg_match('/good/i', $data)) {
|
1157
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
1158
|
$successful_update = true;
|
1159
|
} else if (preg_match('/yours/i', $data)) {
|
1160
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) hostname specified exists, but not under the username specified.";
|
1161
|
} else if (preg_match('/abuse/i', $data)) {
|
1162
|
$status = "phpDynDns ({$this->_dnsHost}): (Error) Updating too frequently, considered abuse.";
|
1163
|
} else {
|
1164
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1165
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1166
|
$this->_debug($data);
|
1167
|
}
|
1168
|
break;
|
1169
|
case 'staticcling':
|
1170
|
if (preg_match("/invalid ip/i", $data)) {
|
1171
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - The IP provided was invalid.";
|
1172
|
} else if (preg_match('/required info missing/i', $data)) {
|
1173
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - Required parameters were not provided.";
|
1174
|
} else if (preg_match('/invalid characters/i', $data)) {
|
1175
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - Illegal characters in either the username or the password.";
|
1176
|
} else if (preg_match('/bad password/i', $data)) {
|
1177
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid password.";
|
1178
|
} else if (preg_match('/account locked/i', $data)) {
|
1179
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) This account has been administratively locked.";
|
1180
|
} else if (preg_match('/update too frequent/i', $data)) {
|
1181
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Updating too frequently.";
|
1182
|
} else if (preg_match('/DB error/i', $data)) {
|
1183
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Server side error.";
|
1184
|
} else if (preg_match('/success/i', $data)) {
|
1185
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1186
|
$successful_update = true;
|
1187
|
} else {
|
1188
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1189
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1190
|
$this->_debug($data);
|
1191
|
}
|
1192
|
break;
|
1193
|
case 'namecheap':
|
1194
|
$tmp = str_replace("^M", "", $data);
|
1195
|
$ncresponse = @xml2array($tmp);
|
1196
|
if (preg_match("/internal server error/i", $data)) {
|
1197
|
$status = "phpDynDNS: (Error) Server side error.";
|
1198
|
} else if (preg_match("/request is badly formed/i", $data)) {
|
1199
|
$status = "phpDynDNS: (Error) Badly Formed Request (check your settings).";
|
1200
|
} else if ($ncresponse['interface-response']['ErrCount'] === "0") {
|
1201
|
$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
|
1202
|
$successful_update = true;
|
1203
|
} else if (is_numeric($ncresponse['interface-response']['ErrCount']) && ($ncresponse['interface-response']['ErrCount'] > 0)) {
|
1204
|
$status = "phpDynDNS: (Error) " . implode(", ", $ncresponse["interface-response"]["errors"]);
|
1205
|
$successful_update = true;
|
1206
|
} else {
|
1207
|
$status = "phpDynDNS: (Unknown Response)";
|
1208
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1209
|
$this->_debug($data);
|
1210
|
}
|
1211
|
break;
|
1212
|
|
1213
|
case 'he-net':
|
1214
|
case 'he-net-v6':
|
1215
|
if (preg_match("/badip/i", $data)) {
|
1216
|
$status = "phpDynDNS: (Error) Bad Request - The IP provided was invalid.";
|
1217
|
} else if (preg_match('/nohost/i', $data)) {
|
1218
|
$status = "phpDynDNS: (Error) Bad Request - A hostname was not provided.";
|
1219
|
} else if (preg_match('/badauth/i', $data)) {
|
1220
|
$status = "phpDynDNS: (Error) Invalid username or password.";
|
1221
|
} else if (preg_match('/good/i', $data)) {
|
1222
|
$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
|
1223
|
$successful_update = true;
|
1224
|
} else if (preg_match('/nochg/i', $data)) {
|
1225
|
$status = "phpDynDNS: (Success) No Change In IP Address.";
|
1226
|
$successful_update = true;
|
1227
|
} else {
|
1228
|
$status = "phpDynDNS: (Unknown Response)";
|
1229
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1230
|
$this->_debug($data);
|
1231
|
}
|
1232
|
break;
|
1233
|
case 'he-net-tunnelbroker':
|
1234
|
/*
|
1235
|
-ERROR: Missing parameter(s).
|
1236
|
-ERROR: Invalid API key or password
|
1237
|
-ERROR: Tunnel not found
|
1238
|
-ERROR: Another tunnel exists for this IP.
|
1239
|
-ERROR: This tunnel is already associated with this IP address
|
1240
|
+OK: Tunnel endpoint updated to: x.x.x.x
|
1241
|
*/
|
1242
|
if (preg_match("/Missing parameter/i", $data)) {
|
1243
|
$status = "phpDynDNS: (Error) Bad Request - Missing/Invalid Parameters.";
|
1244
|
} else if (preg_match('/Tunnel not found/i', $data)) {
|
1245
|
$status = "phpDynDNS: (Error) Bad Request - Invalid Tunnel ID.";
|
1246
|
} else if (preg_match('/Invalid API key or password/i', $data)) {
|
1247
|
$status = "phpDynDNS: (Error) Invalid username or password.";
|
1248
|
} else if (preg_match('/OK:/i', $data)) {
|
1249
|
$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
|
1250
|
$successful_update = true;
|
1251
|
} else if (preg_match('/This tunnel is already associated with this IP address/i', $data)) {
|
1252
|
$status = "phpDynDNS: (Success) No Change In IP Address.";
|
1253
|
$successful_update = true;
|
1254
|
} else {
|
1255
|
$status = "phpDynDNS: (Unknown Response)";
|
1256
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1257
|
$this->_debug($data);
|
1258
|
}
|
1259
|
break;
|
1260
|
case 'selfhost':
|
1261
|
if (preg_match('/notfqdn/i', $data)) {
|
1262
|
$status = "phpDynDNS: (Error) Not A FQDN!";
|
1263
|
} else if (preg_match('/nochg/i', $data)) {
|
1264
|
$status = "phpDynDNS: (Success) No Change In IP Address";
|
1265
|
$successful_update = true;
|
1266
|
} else if (preg_match('/good/i', $data)) {
|
1267
|
$status = "phpDynDNS: (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
1268
|
$successful_update = true;
|
1269
|
} else if (preg_match('/noauth/i', $data)) {
|
1270
|
$status = "phpDynDNS: (Error) User Authorization Failed";
|
1271
|
} else {
|
1272
|
$status = "phpDynDNS: (Unknown Response)";
|
1273
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1274
|
$this->_debug($data);
|
1275
|
}
|
1276
|
break;
|
1277
|
case 'route53':
|
1278
|
$successful_update = true;
|
1279
|
break;
|
1280
|
case 'custom':
|
1281
|
case 'custom-v6':
|
1282
|
$successful_update = false;
|
1283
|
if ($this->_dnsResultMatch == "") {
|
1284
|
$successful_update = true;
|
1285
|
} else {
|
1286
|
$this->_dnsResultMatch = str_replace("%IP%", $this->_dnsIP, $this->_dnsResultMatch);
|
1287
|
$matches = preg_split("/(?<!\\\\)\\|/", $this->_dnsResultMatch);
|
1288
|
foreach ($matches as $match) {
|
1289
|
$match= str_replace("\\|", "|", $match);
|
1290
|
if (strcmp($match, trim($data, "\t\n\r")) == 0) {
|
1291
|
$successful_update = true;
|
1292
|
}
|
1293
|
}
|
1294
|
unset ($matches);
|
1295
|
}
|
1296
|
if ($successful_update == true) {
|
1297
|
$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
|
1298
|
} else {
|
1299
|
$status = "phpDynDNS: (Error) Result did not match. [$data]";
|
1300
|
}
|
1301
|
break;
|
1302
|
case 'cloudflare':
|
1303
|
$output = json_decode($data);
|
1304
|
if ($output->result->content === $this->_dnsIP) {
|
1305
|
$status = "DynDNS: (Success) {$this->_dnsHost} updated to {$this->_dnsIP}";
|
1306
|
$successful_update = true;
|
1307
|
} elseif ($output->errors[0]->code === 9103) {
|
1308
|
$status = "DynDNS ({$this->_dnsHost}): ERROR - Invalid Credentials! Don't forget to use API Key for password field with CloudFlare.";
|
1309
|
} elseif (($output->success) && (!$output->result[0]->id)) {
|
1310
|
$status = "DynDNS ({$this->_dnsHost}): ERROR - Zone or Host ID was not found, check your hostname.";
|
1311
|
} else {
|
1312
|
$status = "DynDNS ({$this->_dnsHost}): UNKNOWN ERROR - {$output->errors[0]->message}";
|
1313
|
log_error("DynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1314
|
}
|
1315
|
break;
|
1316
|
case 'eurodns':
|
1317
|
if (preg_match('/notfqdn/i', $data)) {
|
1318
|
$status = "phpDynDNS: (Error) Not A FQDN!";
|
1319
|
} else if (preg_match('/nochg/i', $data)) {
|
1320
|
$status = "phpDynDNS: (Success) No Change In IP Address";
|
1321
|
$successful_update = true;
|
1322
|
} else if (preg_match('/good/i', $data)) {
|
1323
|
$status = "phpDynDNS: (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
1324
|
$successful_update = true;
|
1325
|
} else if (preg_match('/badauth/i', $data)) {
|
1326
|
$status = "phpDynDNS: (Error) User Authorization Failed";
|
1327
|
} else {
|
1328
|
$status = "phpDynDNS: (Unknown Response)";
|
1329
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1330
|
$this->_debug($data);
|
1331
|
}
|
1332
|
break;
|
1333
|
case 'gratisdns':
|
1334
|
if (preg_match('/Forkerte værdier/i', $data)) {
|
1335
|
$status = "phpDynDNS: (Error) Wrong values - Update could not be completed.";
|
1336
|
} else if (preg_match('/Bruger login: Bruger eksistere ikke/i', $data)) {
|
1337
|
$status = "phpDynDNS: (Error) Unknown username - User does not exist.";
|
1338
|
} else if (preg_match('/Bruger login: 1Fejl i kodeord/i', $data)) {
|
1339
|
$status = "phpDynDNS: (Error) Wrong password - Remember password is case sensitive.";
|
1340
|
} else if (preg_match('/Domæne kan IKKE administreres af bruger/i', $data)) {
|
1341
|
$status = "phpDynDNS: (Error) User unable to administer the selected domain.";
|
1342
|
} else if (preg_match('/OK/i', $data)) {
|
1343
|
$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
|
1344
|
$successful_update = true;
|
1345
|
} else {
|
1346
|
$status = "phpDynDNS: (Unknown Response)";
|
1347
|
log_error("phpDynDNS: PAYLOAD: {$data}");
|
1348
|
$this->_debug($data);
|
1349
|
}
|
1350
|
break;
|
1351
|
case 'dnsimple':
|
1352
|
/* Responds with HTTP 200 on success.
|
1353
|
Responds with HTTP 4xx on error.
|
1354
|
Returns JSON data as body */
|
1355
|
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
1356
|
$header = substr($data, 0, $header_size);
|
1357
|
$body = substr($data, $header_size);
|
1358
|
if (preg_match("/Status: 200\s/i", $header)) {
|
1359
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
|
1360
|
$successful_update = true;
|
1361
|
} else if (preg_match("/Status: 4\d\d\s/i", $header)) {
|
1362
|
$arrbody = json_decode($body, true);
|
1363
|
$message = $arrbody['message'] . ".";
|
1364
|
if (isset($arrbody['errors']['content'])) {
|
1365
|
foreach ($arrbody['errors']['content'] as $key => $content) {
|
1366
|
$message .= " " . $content . ".";
|
1367
|
}
|
1368
|
}
|
1369
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) " . $message;
|
1370
|
} else {
|
1371
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1372
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$body}");
|
1373
|
$this->_debug($body);
|
1374
|
}
|
1375
|
break;
|
1376
|
case 'googledomains':
|
1377
|
if (preg_match('/notfqdn/i', $data)) {
|
1378
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN";
|
1379
|
} else if (preg_match('/nochg/i', $data)) {
|
1380
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
1381
|
$successful_update = true;
|
1382
|
} else if (preg_match('/good/i', $data)) {
|
1383
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
1384
|
$successful_update = true;
|
1385
|
} else if (preg_match('/badauth/i', $data)) {
|
1386
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
1387
|
} else if (preg_match('/nohost/i', $data)) {
|
1388
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname does not exist or DynDNS not enabled";
|
1389
|
} else if (preg_match('/badagent/i', $data)) {
|
1390
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad request";
|
1391
|
} else if (preg_match('/abuse/i', $data)) {
|
1392
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Dynamic DNS access has been blocked!";
|
1393
|
} else if (preg_match('/911/i', $data)) {
|
1394
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Error on Google's end, retry in 5 minutes";
|
1395
|
} else {
|
1396
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1397
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1398
|
$this->_debug($data);
|
1399
|
}
|
1400
|
break;
|
1401
|
case 'dnsmadeeasy':
|
1402
|
switch ($data) {
|
1403
|
case 'success':
|
1404
|
$status = "phpDynDNS({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")";
|
1405
|
$successful_update = true;
|
1406
|
break;
|
1407
|
case 'error-auth':
|
1408
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid username or password";
|
1409
|
break;
|
1410
|
case 'error-auth-suspend':
|
1411
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Account suspended";
|
1412
|
break;
|
1413
|
case 'error-auth-voided':
|
1414
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Account revoked";
|
1415
|
break;
|
1416
|
case 'error-record-invalid':
|
1417
|
$status = "phpDynDns ({$this->_dnsHost}): (Error) Record does not exist in the system. Unable to update record";
|
1418
|
break;
|
1419
|
case 'error-record-auth':
|
1420
|
$status = "phpDynDns ({$this->_dnsHost}): (Error) User does not have access to this record";
|
1421
|
break;
|
1422
|
case 'error-record-ip-same':
|
1423
|
$status = "phpDynDns ({$this->_dnsHost}): (Success) No change in IP Address";
|
1424
|
$successful_update = true;
|
1425
|
break;
|
1426
|
case 'error-system':
|
1427
|
$status = "phpDynDns ({$this->_dnsHost}): (Error) General system error recognized by the system";
|
1428
|
break;
|
1429
|
case 'error':
|
1430
|
$status = "phpDynDns ({$this->_dnsHost}): (Error) General system error unrecognized by the system";
|
1431
|
break;
|
1432
|
default:
|
1433
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1434
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1435
|
$this->_debug($data);
|
1436
|
break;
|
1437
|
}
|
1438
|
break;
|
1439
|
case 'spdns':
|
1440
|
case 'spdns-v6':
|
1441
|
if (preg_match('/notfqdn/i', $data)) {
|
1442
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
|
1443
|
} else if (preg_match('/nohost/i', $data)) {
|
1444
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) No such host";
|
1445
|
} else if (preg_match('/nochg/i', $data)) {
|
1446
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
|
1447
|
$successful_update = true;
|
1448
|
} else if (preg_match('/good/i', $data)) {
|
1449
|
$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
|
1450
|
$successful_update = true;
|
1451
|
} else if (preg_match('/badauth/i', $data)) {
|
1452
|
$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
|
1453
|
} else {
|
1454
|
$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
|
1455
|
log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
|
1456
|
$this->_debug($data);
|
1457
|
}
|
1458
|
break;
|
1459
|
}
|
1460
|
|
1461
|
if ($successful_update == true) {
|
1462
|
/* Write WAN IP to cache file */
|
1463
|
$wan_ip = $this->_checkIP();
|
1464
|
conf_mount_rw();
|
1465
|
if ($this->_useIPv6 == false && $wan_ip > 0) {
|
1466
|
$currentTime = time();
|
1467
|
notify_all_remote(sprintf(gettext("DynDNS updated IP Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip));
|
1468
|
log_error("phpDynDNS: updating cache file {$this->_cacheFile}: {$wan_ip}");
|
1469
|
@file_put_contents($this->_cacheFile, "{$wan_ip}:{$currentTime}");
|
1470
|
} else {
|
1471
|
@unlink($this->_cacheFile);
|
1472
|
}
|
1473
|
if ($this->_useIPv6 == true && $wan_ip > 0) {
|
1474
|
$currentTime = time();
|
1475
|
notify_all_remote(sprintf(gettext("DynDNS updated IPv6 Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip));
|
1476
|
log_error("phpDynDNS: updating cache file {$this->_cacheFile_v6}: {$wan_ip}");
|
1477
|
@file_put_contents($this->_cacheFile_v6, "{$wan_ip}|{$currentTime}");
|
1478
|
} else {
|
1479
|
@unlink($this->_cacheFile_v6);
|
1480
|
}
|
1481
|
conf_mount_ro();
|
1482
|
}
|
1483
|
$this->status = $status;
|
1484
|
log_error($status);
|
1485
|
}
|
1486
|
|
1487
|
/*
|
1488
|
* Private Function (added 12 July 05) [beta]
|
1489
|
* Return Error, Set Last Error, and Die.
|
1490
|
*/
|
1491
|
function _error($errorNumber = '1') {
|
1492
|
switch ($errorNumber) {
|
1493
|
case 0:
|
1494
|
break;
|
1495
|
case 2:
|
1496
|
$error = 'phpDynDNS: (ERROR!) No Dynamic DNS Service provider was selected.';
|
1497
|
break;
|
1498
|
case 3:
|
1499
|
$error = 'phpDynDNS: (ERROR!) No Username Provided.';
|
1500
|
break;
|
1501
|
case 4:
|
1502
|
$error = 'phpDynDNS: (ERROR!) No Password Provided.';
|
1503
|
break;
|
1504
|
case 5:
|
1505
|
$error = 'phpDynDNS: (ERROR!) No Hostname Provided.';
|
1506
|
break;
|
1507
|
case 6:
|
1508
|
$error = 'phpDynDNS: (ERROR!) The Dynamic DNS Service provided is not yet supported.';
|
1509
|
break;
|
1510
|
case 7:
|
1511
|
$error = 'phpDynDNS: (ERROR!) No Update URL Provided.';
|
1512
|
break;
|
1513
|
case 8:
|
1514
|
$status = "Route 53: (Error) Invalid ZoneID";
|
1515
|
break;
|
1516
|
case 9:
|
1517
|
$status = "Route 53: (Error) Invalid TTL";
|
1518
|
break;
|
1519
|
case 10:
|
1520
|
$error = "phpDynDNS ({$this->_dnsHost}): No change in my IP address and/or " . $this->_dnsMaxCacheAgeDays . " days has not passed. Not updating dynamic DNS entry.";
|
1521
|
break;
|
1522
|
default:
|
1523
|
$error = "phpDynDNS: (ERROR!) Unknown Response.";
|
1524
|
/* FIXME: $data isn't in scope here */
|
1525
|
/* $this->_debug($data); */
|
1526
|
break;
|
1527
|
}
|
1528
|
$this->lastError = $error;
|
1529
|
log_error($error);
|
1530
|
}
|
1531
|
|
1532
|
/*
|
1533
|
* Private Function (added 12 July 05) [beta]
|
1534
|
* - Detect whether or not IP needs to be updated.
|
1535
|
* | Written Specifically for pfSense (https://www.pfsense.org) may
|
1536
|
* | work with other systems. pfSense base is FreeBSD.
|
1537
|
*/
|
1538
|
function _detectChange() {
|
1539
|
global $debug;
|
1540
|
|
1541
|
if ($debug) {
|
1542
|
log_error("DynDns ({$this->_dnsHost}): _detectChange() starting.");
|
1543
|
}
|
1544
|
|
1545
|
$currentTime = time();
|
1546
|
|
1547
|
$wan_ip = $this->_checkIP();
|
1548
|
if ($wan_ip == 0) {
|
1549
|
log_error("DynDns ({$this->_dnsHost}): Current WAN IP could not be determined, skipping update process.");
|
1550
|
return false;
|
1551
|
}
|
1552
|
$log_error = "DynDns ({$this->_dnsHost}): Current WAN IP: {$wan_ip} ";
|
1553
|
|
1554
|
if ($this->_useIPv6 == true) {
|
1555
|
if (file_exists($this->_cacheFile_v6)) {
|
1556
|
$contents = file_get_contents($this->_cacheFile_v6);
|
1557
|
list($cacheIP, $cacheTime) = explode('|', $contents);
|
1558
|
$this->_debug($cacheIP.'/'.$cacheTime);
|
1559
|
$initial = false;
|
1560
|
$log_error .= "Cached IPv6: {$cacheIP} ";
|
1561
|
} else {
|
1562
|
conf_mount_rw();
|
1563
|
$cacheIP = '::';
|
1564
|
@file_put_contents($this->_cacheFile, "::|{$currentTime}");
|
1565
|
conf_mount_ro();
|
1566
|
$cacheTime = $currentTime;
|
1567
|
$initial = true;
|
1568
|
$log_error .= "No Cached IPv6 found.";
|
1569
|
}
|
1570
|
} else {
|
1571
|
if (file_exists($this->_cacheFile)) {
|
1572
|
$contents = file_get_contents($this->_cacheFile);
|
1573
|
list($cacheIP, $cacheTime) = explode(':', $contents);
|
1574
|
$this->_debug($cacheIP.'/'.$cacheTime);
|
1575
|
$initial = false;
|
1576
|
$log_error .= "Cached IP: {$cacheIP} ";
|
1577
|
} else {
|
1578
|
conf_mount_rw();
|
1579
|
$cacheIP = '0.0.0.0';
|
1580
|
@file_put_contents($this->_cacheFile, "0.0.0.0:{$currentTime}");
|
1581
|
conf_mount_ro();
|
1582
|
$cacheTime = $currentTime;
|
1583
|
$initial = true;
|
1584
|
$log_error .= "No Cached IP found.";
|
1585
|
}
|
1586
|
}
|
1587
|
if ($this->_dnsVerboseLog) {
|
1588
|
log_error($log_error);
|
1589
|
}
|
1590
|
|
1591
|
// Convert seconds = days * hr/day * min/hr * sec/min
|
1592
|
$maxCacheAgeSecs = $this->_dnsMaxCacheAgeDays * 24 * 60 * 60;
|
1593
|
|
1594
|
$needs_updating = FALSE;
|
1595
|
/* lets determine if the item needs updating */
|
1596
|
if ($cacheIP != $wan_ip) {
|
1597
|
$needs_updating = true;
|
1598
|
$update_reason = "DynDns: cacheIP != wan_ip. Updating. ";
|
1599
|
$update_reason .= "Cached IP: {$cacheIP} WAN IP: {$wan_ip} ";
|
1600
|
}
|
1601
|
if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
|
1602
|
$needs_updating = true;
|
1603
|
$this->_forceUpdateNeeded = true;
|
1604
|
$update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days. Updating. ";
|
1605
|
$update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
|
1606
|
}
|
1607
|
if ($initial == true) {
|
1608
|
$needs_updating = true;
|
1609
|
$update_reason .= "Initial update. ";
|
1610
|
}
|
1611
|
|
1612
|
/* finally if we need updating then store the
|
1613
|
* new cache value and return true
|
1614
|
*/
|
1615
|
if ($needs_updating == true) {
|
1616
|
if ($this->_dnsVerboseLog) {
|
1617
|
log_error("DynDns ({$this->_dnsHost}): {$update_reason}");
|
1618
|
}
|
1619
|
return true;
|
1620
|
}
|
1621
|
|
1622
|
return false;
|
1623
|
}
|
1624
|
|
1625
|
/*
|
1626
|
* Private Function (added 16 July 05) [beta]
|
1627
|
* - Writes debug information to a file.
|
1628
|
* - This function is only called when a unknown response
|
1629
|
* - status is returned from a DynDNS service provider.
|
1630
|
*/
|
1631
|
function _debug($data) {
|
1632
|
global $g;
|
1633
|
|
1634
|
if (!$g['debug']) {
|
1635
|
return;
|
1636
|
}
|
1637
|
$string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n";
|
1638
|
conf_mount_rw();
|
1639
|
$file = fopen($this->_debugFile, 'a');
|
1640
|
fwrite($file, $string);
|
1641
|
fclose($file);
|
1642
|
conf_mount_ro();
|
1643
|
}
|
1644
|
function _checkIP() {
|
1645
|
global $debug;
|
1646
|
|
1647
|
if ($debug) {
|
1648
|
log_error("DynDns ({$this->_dnsHost}): _checkIP() starting.");
|
1649
|
}
|
1650
|
|
1651
|
if ($this->_useIPv6 == true) {
|
1652
|
$ip_address = find_interface_ipv6($this->_if);
|
1653
|
if (!is_ipaddrv6($ip_address)) {
|
1654
|
return 0;
|
1655
|
}
|
1656
|
} else {
|
1657
|
$ip_address = find_interface_ip($this->_if);
|
1658
|
if (!is_ipaddr($ip_address)) {
|
1659
|
return 0;
|
1660
|
}
|
1661
|
}
|
1662
|
if ($this->_useIPv6 == false && is_private_ip($ip_address)) {
|
1663
|
$hosttocheck = "checkip.dyndns.org";
|
1664
|
$try = 0;
|
1665
|
while ($try < 3) {
|
1666
|
$checkip = gethostbyname($hosttocheck);
|
1667
|
if (is_ipaddr($checkip)) {
|
1668
|
break;
|
1669
|
}
|
1670
|
$try++;
|
1671
|
}
|
1672
|
if ($try >= 3) {
|
1673
|
log_error("Dyndns debug information ({$this->_dnsHost}): Could not resolve {$hosttocheck} to IP using interface IP {$ip_address}.");
|
1674
|
return 0;
|
1675
|
}
|
1676
|
$ip_ch = curl_init("http://{$checkip}");
|
1677
|
curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
|
1678
|
curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
1679
|
curl_setopt($ip_ch, CURLOPT_INTERFACE, 'host!' . $ip_address);
|
1680
|
curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30');
|
1681
|
curl_setopt($ip_ch, CURLOPT_TIMEOUT, 120);
|
1682
|
if ($this->_useIPv6 == false) {
|
1683
|
curl_setopt($ip_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
1684
|
}
|
1685
|
$ip_result_page = curl_exec($ip_ch);
|
1686
|
curl_close($ip_ch);
|
1687
|
$ip_result_decoded = urldecode($ip_result_page);
|
1688
|
preg_match('/Current IP Address: (.*)<\/body>/', $ip_result_decoded, $matches);
|
1689
|
$ip_address = trim($matches[1]);
|
1690
|
if (is_ipaddr($ip_address)) {
|
1691
|
if ($this->_dnsVerboseLog) {
|
1692
|
log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from {$hosttocheck}");
|
1693
|
}
|
1694
|
} else {
|
1695
|
log_error("DynDns ({$this->_dnsHost}): IP address could not be extracted from {$hosttocheck}");
|
1696
|
return 0;
|
1697
|
}
|
1698
|
} else {
|
1699
|
if ($this->_dnsVerboseLog) {
|
1700
|
log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from local system.");
|
1701
|
}
|
1702
|
}
|
1703
|
$this->_dnsIP = $ip_address;
|
1704
|
|
1705
|
return $ip_address;
|
1706
|
}
|
1707
|
|
1708
|
}
|
1709
|
|
1710
|
?>
|