Enabling /etc/hosts parsing by default in greendns, solves a few silly-seeming issues like not being able to look up localhost.
This commit is contained in:
@@ -68,9 +68,12 @@ class ResolverProxy(object):
|
|||||||
self._load_etc_hosts()
|
self._load_etc_hosts()
|
||||||
|
|
||||||
def _load_etc_hosts(self):
|
def _load_etc_hosts(self):
|
||||||
|
try:
|
||||||
fd = open('/etc/hosts', 'r')
|
fd = open('/etc/hosts', 'r')
|
||||||
contents = fd.read()
|
contents = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
|
except (IOError, OSError):
|
||||||
|
return
|
||||||
contents = [line for line in contents.split('\n') if line and not line[0] == '#']
|
contents = [line for line in contents.split('\n') if line and not line[0] == '#']
|
||||||
for line in contents:
|
for line in contents:
|
||||||
line = line.replace('\t', ' ')
|
line = line.replace('\t', ' ')
|
||||||
@@ -104,7 +107,7 @@ class ResolverProxy(object):
|
|||||||
#
|
#
|
||||||
# cache
|
# cache
|
||||||
#
|
#
|
||||||
resolver = ResolverProxy()
|
resolver = ResolverProxy(dev=True)
|
||||||
|
|
||||||
def resolve(name):
|
def resolve(name):
|
||||||
error = None
|
error = None
|
||||||
|
Reference in New Issue
Block a user