Ticket #5529: dns-resolver-windows-hosts.patch

File dns-resolver-windows-hosts.patch, 1.1 KB (added by Jared, 8 years ago)

Use correct hosts file, detect Windows properly, and use system-specific "Windows' folder

  • twisted/names/client.py

     
    543543
    544544    @type hosts: C{str} or C{None}
    545545    @param hosts: If not C{None}, an alternate hosts file to use. If C{None}
    546     on posix systems, /etc/hosts will be used. On windows, C:\windows\hosts
    547     will be used.
     546    on posix systems, /etc/hosts will be used. On windows,
     547    %SYSTEMROOT%/system32/drivers/etc/hosts will be used.
    548548
    549549    @rtype: C{IResolver}
    550550    """
     
    556556            hosts = '/etc/hosts'
    557557        theResolver = Resolver(resolvconf, servers)
    558558        hostResolver = hostsModule.Resolver(hosts)
    559     else:
     559    elif platform.isWindows():
    560560        if hosts is None:
    561             hosts = r'c:\windows\hosts'
     561            systemroot = os.environ["SYSTEMROOT"]
     562            hosts = systemroot + r"\system32\drivers\etc\hosts"
    562563        from twisted.internet import reactor
    563564        bootstrap = _ThreadedResolverImpl(reactor)
    564565        hostResolver = hostsModule.Resolver(hosts)