From 24f0601345fa245eddaaecab5dde8fc0d14b0ef6 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 28 Jun 2021 08:47:07 +0200 Subject: [PATCH] only return valid IPs --- src/Config/Config.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 37ae91d..81b70a4 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -85,7 +85,14 @@ public static function loadResolvConfBlocking($path = null) preg_match_all('/^nameserver\s+(\S+)\s*$/m', $contents, $matches); $config = new self(); - $config->nameservers = $matches[1]; + $config->nameservers = []; + + /* only valid IP */ + foreach($matches[1] as $n) { + if (filter_var("$n",FILTER_VALIDATE_IP)) { + $config->nameservers[] = $n; + } + } return $config; }