File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -46,16 +46,15 @@ protected function createCachedExecutor(LoopInterface $loop)
46
46
47
47
protected function addPortToServerIfMissing ($ nameserver )
48
48
{
49
- $ colon = strrpos ($ nameserver , ': ' );
50
-
51
- // there is no colon at all or the last one does not have a closing IPv6 bracket right before it
52
- if ($ colon === false || (strpos ($ nameserver , ': ' ) !== $ colon && strpos ($ nameserver , '] ' ) !== ($ colon - 1 ))) {
53
- if (strpos ($ nameserver , ': ' ) !== $ colon ) {
54
- // several colons => enclose IPv6 address in square brackets
55
- $ nameserver = '[ ' . $ nameserver . '] ' ;
56
- }
49
+ if (strpos ($ nameserver , '[ ' ) === false && substr_count ($ nameserver , ': ' ) >= 2 ) {
50
+ // several colons, but not enclosed in square brackets => enclose IPv6 address in square brackets
51
+ $ nameserver = '[ ' . $ nameserver . '] ' ;
52
+ }
53
+ // assume a dummy scheme when checking for the port, otherwise parse_url() fails
54
+ if (parse_url ('dummy:// ' . $ nameserver , PHP_URL_PORT ) === null ) {
57
55
$ nameserver .= ':53 ' ;
58
56
}
57
+
59
58
return $ nameserver ;
60
59
}
61
60
}
You can’t perform that action at this time.
0 commit comments