Skip to content

Commit

Permalink
Added py3dns recipe (#2590)
Browse files Browse the repository at this point in the history
* Added py3dns recipe
* Update py3dns recipe
  • Loading branch information
Neizvestnyj authored May 1, 2022
1 parent 92cb8f4 commit 9670576
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pythonforandroid/recipes/py3dns/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pythonforandroid.recipe import PythonRecipe


class Py3DNSRecipe(PythonRecipe):
site_packages_name = 'DNS'
version = '3.2.1'
url = 'https://launchpad.net/py3dns/trunk/{version}/+download/py3dns-{version}.tar.gz'
depends = ['setuptools']
patches = ['patches/android.patch']
call_hostpython_via_targetpython = False


recipe = Py3DNSRecipe()
27 changes: 27 additions & 0 deletions pythonforandroid/recipes/py3dns/patches/android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/DNS/Base.py b/DNS/Base.py
index 34a6da7..a558889 100644
--- a/DNS/Base.py
+++ b/DNS/Base.py
@@ -15,6 +15,7 @@ import socket, string, types, time, select
import errno
from . import Type,Class,Opcode
import asyncore
+import os
#
# This random generator is used for transaction ids and port selection. This
# is important to prevent spurious results from lost packets, and malicious
@@ -50,8 +51,12 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,

def ParseResolvConf(resolv_path="/etc/resolv.conf"):
"parses the /etc/resolv.conf file and sets defaults for name servers"
- with open(resolv_path, 'r') as stream:
- return ParseResolvConfFromIterable(stream)
+ if os.path.exists(resolv_path):
+ with open(resolv_path, 'r') as stream:
+ return ParseResolvConfFromIterable(stream)
+ else:
+ defaults['server'].append('127.0.0.1')
+ return

def ParseResolvConfFromIterable(lines):
"parses a resolv.conf formatted stream and sets defaults for name servers"

0 comments on commit 9670576

Please sign in to comment.