Update networktool.php

This commit is contained in:
Namhyeon Go 2018-09-26 20:06:07 +09:00 committed by GitHub
parent 62ade3f26c
commit af8f9e7d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,12 +107,19 @@ if(!function_exists("get_network_outbound_addr")) {
function get_network_outbound_addr($protocol="") {
$addr = false;
// via icanhazip.com
if(loadHelper("webpagetool")) {
$remote_host = "http://" . ($protocol == "ipv6" ? "ipv6." : "") . "icanhazip.com";
$response = get_web_page($remote_host, "get.cache");
$addr = get_value_in_array("content", $response, $addr);
}
// via opendns.com
if(!$addr && loadHelper("exectool")) {
$cmd = "dig +short myip.opendns.com @resolver1.opendns.com";
$addr = exec_command($cmd, "shell_exec");
}
return $addr;
}
}