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:
Ryan Williams
2010-07-04 13:52:12 -07:00
parent 675f76dc68
commit 390538a176

View File

@@ -68,9 +68,12 @@ class ResolverProxy(object):
self._load_etc_hosts()
def _load_etc_hosts(self):
try:
fd = open('/etc/hosts', 'r')
contents = fd.read()
fd.close()
except (IOError, OSError):
return
contents = [line for line in contents.split('\n') if line and not line[0] == '#']
for line in contents:
line = line.replace('\t', ' ')
@@ -104,7 +107,7 @@ class ResolverProxy(object):
#
# cache
#
resolver = ResolverProxy()
resolver = ResolverProxy(dev=True)
def resolve(name):
error = None