Skip to content

Commit e6f933b

Browse files
use variables for IPv4/IPv6 address provider
1 parent c065cb6 commit e6f933b

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

config.dist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
// Most likely though, you should keep this active, unless you know otherwise.
3434
define('USE_IPV4', true);
3535

36+
37+
define('IPV4_ADDRESS_PROVIDER', 'https://api.ipify.org');
38+
define('IPV4_ADDRESS_PROVIDER_FALLBACK', 'https://ipv4.seeip.org');
39+
define('IPV6_ADDRESS_PROVIDER', 'https://ipv6.seeip.org');
40+
define('IPV6_ADDRESS_PROVIDER_FALLBACK', 'https://v6.ident.me/');
41+
42+
3643
// If set to true, the script will check for your public IPv6 address too and add it as an AAAA-Record / change an existing AAAA-Record for the host.
3744
// Activate this only if you have IPv6 connectivity, or you *WILL* get errors.
3845
define('USE_IPV6', false);

functions.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function getCurrentPublicIPv4()
279279

280280
outputStdout('Getting IPv4 address from API.');
281281

282-
$url = 'https://api.ipify.org';
282+
$url = IPV4_ADDRESS_PROVIDER;
283283
$ch = initializeCurlHandlerGetIP($url);
284284
$publicIP = trim(curl_exec($ch));
285285

@@ -292,8 +292,8 @@ function getCurrentPublicIPv4()
292292
}
293293

294294
if (!isIPV4Valid($publicIP) || $publicIP === false) {
295-
outputWarning("https://api.ipify.org didn't return a valid IPv4 address (Try $retryCount / $retryLimit). Trying fallback API https://ipv4.seeip.org");
296-
$url = 'https://ipv4.seeip.org';
295+
outputWarning(IPV4_ADDRESS_PROVIDER . " didn't return a valid IPv4 address (Try $retryCount / $retryLimit). Trying fallback API " . IPV4_ADDRESS_PROVIDER_FALLBACK);
296+
$url = IPV4_ADDRESS_PROVIDER_FALLBACK;
297297
$ch = initializeCurlHandlerGetIP($url);
298298
$publicIP = trim(curl_exec($ch));
299299
if (!wasCurlSuccessful($ch) || !isIPV4Valid($publicIP)) {
@@ -326,7 +326,7 @@ function getCurrentPublicIPv6()
326326

327327
outputStdout('Getting IPv6 address from API.');
328328

329-
$url = 'https://ipv6.seeip.org';
329+
$url = IPV6_ADDRESS_PROVIDER;
330330
$ch = initializeCurlHandlerGetIP($url);
331331
$publicIP = trim(curl_exec($ch));
332332

@@ -339,8 +339,8 @@ function getCurrentPublicIPv6()
339339
}
340340

341341
if (!isIPV6Valid($publicIP) || $publicIP === false) {
342-
outputWarning("https://ipv6.seeip.org didn't return a valid IPv6 address (Try $retryCount / $retryLimit). Trying fallback API https://v6.ident.me/");
343-
$url = 'https://v6.ident.me/';
342+
outputWarning(IPV6_ADDRESS_PROVIDER . " didn't return a valid IPv6 address (Try $retryCount / $retryLimit). Trying fallback API " . IPV6_ADDRESS_PROVIDER_FALLBACK);
343+
$url = IPV6_ADDRESS_PROVIDER_FALLBACK;
344344
$ch = initializeCurlHandlerGetIP($url);
345345
$publicIP = trim(curl_exec($ch));
346346
if (!wasCurlSuccessful($ch) || !isIPV6Valid($publicIP)) {

update.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
exit(1);
2525
}
2626

27+
if (!defined('IPV4_ADDRESS_PROVIDER')) {
28+
define('IPV4_ADDRESS_PROVIDER', 'https://api.ipify.org');
29+
}
30+
31+
if (!defined('IPV4_ADDRESS_PROVIDER_FALLBACK')) {
32+
define('IPV4_ADDRESS_PROVIDER_FALLBACK', 'https://ipv4.seeip.org');
33+
}
34+
35+
if (!defined('IPV6_ADDRESS_PROVIDER')) {
36+
define('IPV6_ADDRESS_PROVIDER', 'https://ipv6.seeip.org');
37+
}
38+
39+
if (!defined('IPV6_ADDRESS_PROVIDER_FALLBACK')) {
40+
define('IPV6_ADDRESS_PROVIDER_FALLBACK', 'https://v6.ident.me/');
41+
}
42+
2743
if (USE_IPV4 === true) {
2844
// Get current IPv4 address
2945
if (!$publicIPv4 = getCurrentPublicIPv4()) {

0 commit comments

Comments
 (0)