Skip to content

Commit 9670576

Browse files
authored
Added py3dns recipe (#2590)
* Added py3dns recipe * Update py3dns recipe
1 parent 92cb8f4 commit 9670576

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class Py3DNSRecipe(PythonRecipe):
5+
site_packages_name = 'DNS'
6+
version = '3.2.1'
7+
url = 'https://launchpad.net/py3dns/trunk/{version}/+download/py3dns-{version}.tar.gz'
8+
depends = ['setuptools']
9+
patches = ['patches/android.patch']
10+
call_hostpython_via_targetpython = False
11+
12+
13+
recipe = Py3DNSRecipe()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/DNS/Base.py b/DNS/Base.py
2+
index 34a6da7..a558889 100644
3+
--- a/DNS/Base.py
4+
+++ b/DNS/Base.py
5+
@@ -15,6 +15,7 @@ import socket, string, types, time, select
6+
import errno
7+
from . import Type,Class,Opcode
8+
import asyncore
9+
+import os
10+
#
11+
# This random generator is used for transaction ids and port selection. This
12+
# is important to prevent spurious results from lost packets, and malicious
13+
@@ -50,8 +51,12 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,
14+
15+
def ParseResolvConf(resolv_path="/etc/resolv.conf"):
16+
"parses the /etc/resolv.conf file and sets defaults for name servers"
17+
- with open(resolv_path, 'r') as stream:
18+
- return ParseResolvConfFromIterable(stream)
19+
+ if os.path.exists(resolv_path):
20+
+ with open(resolv_path, 'r') as stream:
21+
+ return ParseResolvConfFromIterable(stream)
22+
+ else:
23+
+ defaults['server'].append('127.0.0.1')
24+
+ return
25+
26+
def ParseResolvConfFromIterable(lines):
27+
"parses a resolv.conf formatted stream and sets defaults for name servers"

0 commit comments

Comments
 (0)