Synology router configuration files for adding dynv6.com DDNS provider.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add following lines to /etc.defaults/ddns_provider.conf | |
[dynv6.com] | |
modulepath=/usr/syno/bin/ddns/dynv6.php | |
queryurl=http://dynv6.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php -d open_basedir=/usr/syno/bin/ddns | |
<?php | |
$script = (string)$argv[0]; | |
$ret = 'badagent'; | |
if($argc !== 5) | |
{ | |
echo $ret; | |
syslog(LOG_CRIT, $script.':'.__LINE__.' '.$ret); | |
exit(); | |
} | |
$token = (string)$argv[1]; | |
$hostname = (string)$argv[3]; | |
$ip = (string)$argv[4]; | |
// check the hostname contains '.' | |
if(strpos($hostname, '.') === false) | |
{ | |
echo $ret; | |
syslog(LOG_CRIT, $script.':'.__LINE__.' '.$ret); | |
exit(); | |
} | |
// only for IPv4 format | |
if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) | |
{ | |
echo $ret; | |
syslog(LOG_CRIT, $script.':'.__LINE__.' '.$ret); | |
exit(); | |
} | |
$url = 'https://dynv6.com/api/update?hostname='.$hostname.'&ipv4='.$ip.'&token='.$token; | |
// syslog(LOG_CRIT, $script.':'.__LINE__.' REQUEST '.$url); | |
$req = curl_init(); | |
curl_setopt($req, CURLOPT_URL, $url); | |
curl_setopt($req, CURLOPT_RETURNTRANSFER, TRUE); | |
$res = curl_exec($req); | |
curl_close($req); | |
// syslog(LOG_CRIT, $script.':'.__LINE__.' RESPONSE '.$res); | |
switch(trim($res)) | |
{ | |
case 'addresses updated': | |
$ret = 'good'; | |
break; | |
case "addresses unchanged": | |
$ret = 'nochg'; | |
break; | |
case 'hostname not found': | |
$ret = 'nohost'; | |
break; | |
default: | |
$ret = trim($res); | |
} | |
echo $ret; | |
syslog(LOG_CRIT, $script.':'.__LINE__.' '.$ret); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment