allow user to override system dnsserver with config.
config item: dns_server list eg: dns_server:[8.8.8.8,8.8.4.4]
This commit is contained in:
parent
eb033a8f6a
commit
0c4f79284e
2 changed files with 12 additions and 4 deletions
|
@ -248,7 +248,7 @@ STATUS_IPV6 = 1
|
|||
|
||||
class DNSResolver(object):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, server_list=None):
|
||||
self._loop = None
|
||||
self._hosts = {}
|
||||
self._hostname_status = {}
|
||||
|
@ -256,8 +256,11 @@ class DNSResolver(object):
|
|||
self._cb_to_hostname = {}
|
||||
self._cache = lru_cache.LRUCache(timeout=300)
|
||||
self._sock = None
|
||||
if server_list is None:
|
||||
self._servers = None
|
||||
self._parse_resolv()
|
||||
else:
|
||||
self._servers = server_list
|
||||
self._parse_hosts()
|
||||
# TODO monitor hosts change and reload hosts
|
||||
# TODO parse /etc/gai.conf and follow its rules
|
||||
|
|
|
@ -57,7 +57,12 @@ def main():
|
|||
|
||||
tcp_servers = []
|
||||
udp_servers = []
|
||||
|
||||
if 'dns_server' in config: # allow override settings in resolv.conf
|
||||
dns_resolver = asyncdns.DNSResolver(config['dns_server'])
|
||||
else:
|
||||
dns_resolver = asyncdns.DNSResolver()
|
||||
|
||||
port_password = config['port_password']
|
||||
del config['port_password']
|
||||
for port, password in port_password.items():
|
||||
|
|
Loading…
Reference in a new issue