()
| 116 | |
| 117 | |
| 118 | def windows_nameservers(): |
| 119 | out = subprocess.check_output(["powershell", "-NonInteractive", "-NoProfile", "-Command", "Get-DnsClientServerAddress"], |
| 120 | encoding="utf-8") |
| 121 | servers = set() |
| 122 | for line in out.splitlines(): |
| 123 | if line.startswith("Loopback "): |
| 124 | continue |
| 125 | m = re.search(r'{.+}', line) |
| 126 | if not m: |
| 127 | continue |
| 128 | for s in m.group().strip('{}').split(','): |
| 129 | s = s.strip() |
| 130 | if s.startswith('fec0:0:0:ffff'): |
| 131 | continue |
| 132 | servers.add(s) |
| 133 | debug2("Found DNS servers: %s" % servers) |
| 134 | return [(socket.AF_INET6 if ':' in s else socket.AF_INET, s) for s in servers] |
| 135 | |
| 136 | |
| 137 | def get_random_nameserver(): |
no test coverage detected