Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"/etc/resolv.conf" assumed default path is wrong for termux #724

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion eventlet/support/greendns.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,24 @@ def getaliases(self, hostname):
return aliases


resolver = ResolverProxy(hosts_resolver=HostsResolver())
"""
Some systems' default resolv.conf file is not located in /etc/resolv.conf

for instance, in termux (terminal app in android) there are system configurations wich can not
be mounted or symbolically linked to the android's /etc/ path, due to how android works
and therefore have their own locations in a subdirectory in the app's data directory

the termux environment can be identified via the $PREFIX environment variable, and so
the following code provides a patch for this specific case, while maintaining the default
functionality if the system is not termux
"""
resolver = None
if 'PREFIX' in os.environ and os.environ['PREFIX']=='/data/data/com.termux/files/usr':
print('greendns: system is termux')
resolver = ResolverProxy(hosts_resolver=HostsResolver(),filename=(os.environ['PREFIX']+'/etc/resolv.conf'))
else:
resolver = ResolverProxy(hosts_resolver=HostsResolver())



def resolve(name, family=socket.AF_INET, raises=True, _proxy=None,
Expand Down