diff options
author | Remy <relst@relst.nl> | 2015-06-03 20:23:17 +0200 |
---|---|---|
committer | Remy <relst@relst.nl> | 2015-06-03 20:23:17 +0200 |
commit | deebed4560e32c77a0e217418a947ef1cf6db54b (patch) | |
tree | 7d2eee0a0e09137c0023658aa296f03c691b5fdd | |
parent | 299c30103e00a153d260c23bc06beb3352f94af2 (diff) | |
download | ssl-decoder-deebed4560e32c77a0e217418a947ef1cf6db54b.zip ssl-decoder-deebed4560e32c77a0e217418a947ef1cf6db54b.tar.gz ssl-decoder-deebed4560e32c77a0e217418a947ef1cf6db54b.tar.bz2 |
fix testing and name resolution of ipv6 only hosts
-rw-r--r-- | functions/connection.php | 13 | ||||
-rw-r--r-- | functions/variables.php | 4 |
2 files changed, 13 insertions, 4 deletions
diff --git a/functions/connection.php b/functions/connection.php index 54f7236..a6049cd 100644 --- a/functions/connection.php +++ b/functions/connection.php @@ -15,7 +15,18 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. function fixed_gethostbyname($host) { - $ip = gethostbyname($host); + $ips = dns_get_record($host, DNS_A + DNS_AAAA); + sort($ips); + foreach ($ips as $key => $value) { + if ($value['type'] === "AAAA") { + $ip = $value['ipv6']; + } elseif ($value['type'] === "A") { + $ip = $value['ip']; + } else { + return false; + } + } + pre_dump($ips); if ($ip != $host) { return $ip; } else { diff --git a/functions/variables.php b/functions/variables.php index a2e1d24..09a794c 100644 --- a/functions/variables.php +++ b/functions/variables.php @@ -50,9 +50,7 @@ function parse_hostname($u_hostname){ $parts[1] = preg_replace('/[^A-Za-z0-9\.\:_-]/', '', $parts[1]); if (filter_var($parts[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) or filter_var($parts[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { $ip = mb_strtolower($parts[1]); - } else { - $ip = fixed_gethostbyname($hostname); - } + } } else { if (filter_var($hostname, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { $ip = $hostname; |