Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
ab2dca6c27 |
30
pb-dydns.php
30
pb-dydns.php
|
|
@ -75,15 +75,35 @@ $myDomain = $argv[1];
|
||||||
$pbapi = new PorkbunAPI($config_filename);
|
$pbapi = new PorkbunAPI($config_filename);
|
||||||
|
|
||||||
// Test connection to Porkbun API in order to get the public IP:
|
// Test connection to Porkbun API in order to get the public IP:
|
||||||
$result = json_decode($pbapi->ping());
|
$raw = $pbapi->ping();
|
||||||
if ($result->status == "SUCCESS") $myIp = $result->yourIp;
|
$result = json_decode($raw);
|
||||||
else
|
|
||||||
|
if ($result === null)
|
||||||
{
|
{
|
||||||
echo_to_cli("There was an error trying to ping Porkbun." . PHP_EOL);
|
echo_to_cli("Invalid JSON returned by Porkbun API:\n$raw\n");
|
||||||
var_dump($result);
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($result->status))
|
||||||
|
{
|
||||||
|
echo_to_cli("Porkbun API response missing 'status' field:\n$raw\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result->status !== "SUCCESS")
|
||||||
|
{
|
||||||
|
echo_to_cli("Porkbun API returned an error:\n$raw\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($result->yourIp))
|
||||||
|
{
|
||||||
|
echo_to_cli("Porkbun API did not return your public IP.\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
$myIp = $result->yourIp;
|
||||||
|
|
||||||
echo_to_cli("Your public IP address is $myIp" . PHP_EOL);
|
echo_to_cli("Your public IP address is $myIp" . PHP_EOL);
|
||||||
|
|
||||||
// Retrieve all DNS records associated with user's domain:
|
// Retrieve all DNS records associated with user's domain:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue