diff options
Diffstat (limited to 'src/etc/inc/services.inc')
-rw-r--r-- | src/etc/inc/services.inc | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index ab7a5b3..7046551 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -2045,7 +2045,7 @@ function services_dyndns_configure($int = "") { } function dyndnsCheckIP($int) { - global $config; + global $config, $factory_default_checkipservice; $ip_address = get_interface_ip($int); if (is_private_ip($ip_address)) { $gateways_status = return_gateways_status(true); @@ -2054,14 +2054,35 @@ function dyndnsCheckIP($int) { if (stristr($gateways_status[$config['interfaces'][$int]['gateway']]['status'], "down")) { return "down"; } - $hosttocheck = "http://checkip.dyndns.org"; + + // Append the factory default check IP service to the list (if not disabled). + if (!isset($config['checkipservices']['disable_factory_default'])) { + $config['checkipservices']['checkipservice'][] = $factory_default_checkipservice; + } + + // Use the first enabled check IP service as the default. + if (is_array($config['checkipservices']['checkipservice'])) { + foreach ($config['checkipservices']['checkipservice'] as $i => $checkipservice) { + if (isset($checkipservice['enable'])) { + $url = $checkipservice['url']; + $username = $checkipservice['username']; + $password = $checkipservice['password']; + $verifysslpeer = isset($checkipservice['verifysslpeer']); + break; + } + } + } + + $hosttocheck = $url; $ip_ch = curl_init($hosttocheck); curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, $verifysslpeer); curl_setopt($ip_ch, CURLOPT_INTERFACE, 'host!' . $ip_address); curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30'); curl_setopt($ip_ch, CURLOPT_TIMEOUT, 120); curl_setopt($ip_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_setopt($ip_ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($ip_ch, CURLOPT_USERPWD, "{$username}:{$password}"); $ip_result_page = curl_exec($ip_ch); curl_close($ip_ch); $ip_result_decoded = urldecode($ip_result_page); |