From ca57f46a0cd63fca1068d0c85a8379876b90f09f Mon Sep 17 00:00:00 2001 From: alvie Date: Sat, 27 Jun 2015 08:17:53 +0800 Subject: [PATCH 1/2] compatible to newer shadowsocks version --- chinadns/dnsrelay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chinadns/dnsrelay.py b/chinadns/dnsrelay.py index ffeb719..a7c4222 100644 --- a/chinadns/dnsrelay.py +++ b/chinadns/dnsrelay.py @@ -35,7 +35,7 @@ sys.exit(1) import argparse -from shadowsocks import eventloop, asyncdns, lru_cache +from shadowsocks import eventloop, asyncdns, lru_cache, common BUF_SIZE = 16384 @@ -92,7 +92,7 @@ def _parse_hosts(self): parts = line.split() if len(parts) >= 2: ip = parts[0] - if asyncdns.is_ip(ip): + if common.is_ip(ip): for i in xrange(1, len(parts)): hostname = parts[i] if hostname: From 84a39473a8ef0d307fc95c9827395010c20cd033 Mon Sep 17 00:00:00 2001 From: alvie Date: Sat, 27 Jun 2015 08:28:44 +0800 Subject: [PATCH 2/2] change import order to pass pep8 check --- chinadns/dnsrelay.py | 7 ++++--- test.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chinadns/dnsrelay.py b/chinadns/dnsrelay.py index a7c4222..26410ea 100644 --- a/chinadns/dnsrelay.py +++ b/chinadns/dnsrelay.py @@ -29,14 +29,15 @@ import struct import logging +import argparse +from shadowsocks import eventloop, asyncdns, lru_cache, common + info = sys.version_info + if not (info[0] == 2 and info[1] >= 7): print 'Python 2.7 required' sys.exit(1) -import argparse -from shadowsocks import eventloop, asyncdns, lru_cache, common - BUF_SIZE = 16384 diff --git a/test.py b/test.py index ae12d00..f0a3175 100755 --- a/test.py +++ b/test.py @@ -2,12 +2,14 @@ # -*- coding: utf-8 -*- import sys -sys.path.insert(0, 'shadowsocks') import os import signal import select + from subprocess import Popen, PIPE +sys.path.insert(0, 'shadowsocks') + with open(sys.argv[-1]) as f: dig_cmd = f.read() p1 = Popen(['sudo', sys.executable, 'chinadns/dnsrelay.py'], shell=False,