mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
arcdns: update
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
e5ee331326
commit
72ba6441b7
@ -1,20 +1,5 @@
|
||||
#!/usr/bin/php -d open_basedir=/usr/syno/bin/ddns
|
||||
<?php
|
||||
/*
|
||||
Usage Instructions ( Obviously your domain has to be hosted on ArcDNS )
|
||||
|
||||
1) Copy this file to /usr/syno/bin/ddns/arcdns.php
|
||||
|
||||
2) Add the following entry in /etc.defaults/ddns_provider.conf
|
||||
[Custom - ArcDNS]
|
||||
modulepath=/usr/syno/bin/ddns/arcdns.php
|
||||
queryurl=dyn.arcdns.tech
|
||||
|
||||
3) In Synology External Access > DDNS
|
||||
Hostname = subdomain.domain.com OR domain.com
|
||||
Username = put-random-string-here-for-validation-purpose
|
||||
Password = ArcDNS DDNS Token (Accounts > Domain List > Advanced DNS)
|
||||
*/
|
||||
|
||||
if ($argc !== 5) {
|
||||
echo 'badparam';
|
||||
@ -32,39 +17,32 @@ if (strpos($hostname, '.') === false) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// check the hostname contains '.'
|
||||
if (strpos($pwd, '.') === false) {
|
||||
echo 'badparam';
|
||||
exit();
|
||||
}
|
||||
|
||||
// only for IPv4 format
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
echo "badparam";
|
||||
exit();
|
||||
}
|
||||
|
||||
$array = explode('.', $hostname);
|
||||
if (count($array) >= 3) {
|
||||
$domain = implode('.', array_slice($array, 1));
|
||||
$hostname = implode('.', array_slice($array, 0, 1));
|
||||
} else {
|
||||
$domain = implode('.', $array);
|
||||
$hostname = '@';
|
||||
}
|
||||
|
||||
$url = 'https://arcdns.tech/update/'.$hostname.'/'.$pwd.;
|
||||
|
||||
$req = curl_init();
|
||||
curl_setopt($req, CURLOPT_URL, $url);
|
||||
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($req);
|
||||
curl_close($req);
|
||||
$json = json_decode($res, true);
|
||||
|
||||
$xml = new SimpleXMLElement($res);
|
||||
if ($xml->ErrCount > 0) {
|
||||
$error = $xml->errors[0]->Err1;
|
||||
if (strcmp($error, "This hostname has not been registered or is expired.") === 0) {
|
||||
echo "nohost";
|
||||
} elseif (strcmp($error, "You have supplied the wrong token to manipulate this host") === 0) {
|
||||
echo "badauth";
|
||||
if ($json['status'] !== 'Successfuly updated') {
|
||||
echo 'badauth';
|
||||
curl_close($req);
|
||||
exit();
|
||||
} else {
|
||||
echo "911 [".$error."]";
|
||||
}
|
||||
} else {
|
||||
echo "good";
|
||||
echo 'good';
|
||||
curl_close($req);
|
||||
exit();
|
||||
}
|
Loading…
Reference in New Issue
Block a user