summaryrefslogtreecommitdiffstats
path: root/181.patch
blob: e3ce88349f85523d794061110a1c17b9ff8c8d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 24f0601345fa245eddaaecab5dde8fc0d14b0ef6 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
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;
     }