Browse Source

Merge branch 'manyuser' of git@breakwa11:breakwa11/shadowsocks.git into manyuser

dev
breakwa11 9 years ago
parent
commit
9df46398d6
  1. 6
      db_transfer.py
  2. 14
      server_pool.py
  3. 4
      shadowsocks/crypto/util.py
  4. 4
      shadowsocks/tcprelay.py
  5. 4
      shadowsocks/udprelay.py

6
db_transfer.py

@ -79,7 +79,7 @@ class DbTransfer(object):
try: try:
import switchrule import switchrule
keys = switchrule.getKeys() keys = switchrule.getKeys()
except Exception, e: except Exception as e:
keys = ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ] keys = ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ]
conn = cymysql.connect(host=Config.MYSQL_HOST, port=Config.MYSQL_PORT, user=Config.MYSQL_USER, conn = cymysql.connect(host=Config.MYSQL_HOST, port=Config.MYSQL_PORT, user=Config.MYSQL_USER,
passwd=Config.MYSQL_PASS, db=Config.MYSQL_DB, charset='utf8') passwd=Config.MYSQL_PASS, db=Config.MYSQL_DB, charset='utf8')
@ -102,13 +102,13 @@ class DbTransfer(object):
#需要动态载入switchrule,以便实时修改规则 #需要动态载入switchrule,以便实时修改规则
try: try:
import switchrule import switchrule
except Exception, e: except Exception as e:
logging.error('load switchrule.py fail') logging.error('load switchrule.py fail')
cur_servers = {} cur_servers = {}
for row in rows: for row in rows:
try: try:
allow = switchrule.isTurnOn(row) and row['enable'] == 1 and row['u'] + row['d'] < row['transfer_enable'] allow = switchrule.isTurnOn(row) and row['enable'] == 1 and row['u'] + row['d'] < row['transfer_enable']
except Exception, e: except Exception as e:
allow = False allow = False
port = row['port'] port = row['port']

14
server_pool.py

@ -120,7 +120,7 @@ class ServerPool(object):
if a_config['server_ipv6'] == "::": if a_config['server_ipv6'] == "::":
ipv6_ok = True ipv6_ok = True
except Exception, e: except Exception as e:
logging.warn("IPV6 %s " % (e,)) logging.warn("IPV6 %s " % (e,))
if 'server' in self.config: if 'server' in self.config:
@ -142,7 +142,7 @@ class ServerPool(object):
udp_server.add_to_loop(self.loop) udp_server.add_to_loop(self.loop)
self.udp_servers_pool.update({port: udp_server}) self.udp_servers_pool.update({port: udp_server})
except Exception, e: except Exception as e:
if not ipv6_ok: if not ipv6_ok:
logging.warn("IPV4 %s " % (e,)) logging.warn("IPV4 %s " % (e,))
@ -155,7 +155,7 @@ class ServerPool(object):
udpsock = socket(AF_INET, SOCK_DGRAM) udpsock = socket(AF_INET, SOCK_DGRAM)
udpsock.sendto('%s:%s:0:0' % (Config.MANAGE_PASS, port), (Config.MANAGE_BIND_IP, Config.MANAGE_PORT)) udpsock.sendto('%s:%s:0:0' % (Config.MANAGE_PASS, port), (Config.MANAGE_BIND_IP, Config.MANAGE_PORT))
udpsock.close() udpsock.close()
except Exception, e: except Exception as e:
logging.warn(e) logging.warn(e)
return True return True
@ -169,12 +169,12 @@ class ServerPool(object):
try: try:
self.tcp_servers_pool[port].close(False) self.tcp_servers_pool[port].close(False)
del self.tcp_servers_pool[port] del self.tcp_servers_pool[port]
except Exception, e: except Exception as e:
logging.warn(e) logging.warn(e)
try: try:
self.udp_servers_pool[port].close(False) self.udp_servers_pool[port].close(False)
del self.udp_servers_pool[port] del self.udp_servers_pool[port]
except Exception, e: except Exception as e:
logging.warn(e) logging.warn(e)
if 'server_ipv6' in self.config: if 'server_ipv6' in self.config:
@ -185,12 +185,12 @@ class ServerPool(object):
try: try:
self.tcp_ipv6_servers_pool[port].close(False) self.tcp_ipv6_servers_pool[port].close(False)
del self.tcp_ipv6_servers_pool[port] del self.tcp_ipv6_servers_pool[port]
except Exception, e: except Exception as e:
logging.warn(e) logging.warn(e)
try: try:
self.udp_ipv6_servers_pool[port].close(False) self.udp_ipv6_servers_pool[port].close(False)
del self.udp_ipv6_servers_pool[port] del self.udp_ipv6_servers_pool[port]
except Exception, e: except Exception as e:
logging.warn(e) logging.warn(e)
return True return True

4
shadowsocks/crypto/util.py

@ -87,8 +87,8 @@ def find_library(possible_lib_names, search_symbol, library_name):
else: else:
logging.warn('can\'t find symbol %s in %s', search_symbol, logging.warn('can\'t find symbol %s in %s', search_symbol,
path) path)
except Exception: except ValueError as e:
pass logging.error(e)
return None return None

4
shadowsocks/tcprelay.py

@ -717,8 +717,8 @@ class TCPRelay(object):
self._closed = False self._closed = False
self._eventloop = None self._eventloop = None
self._fd_to_handlers = {} self._fd_to_handlers = {}
self.server_transfer_ul = 0L self.server_transfer_ul = 0
self.server_transfer_dl = 0L self.server_transfer_dl = 0
self._timeout = config['timeout'] self._timeout = config['timeout']
self._timeouts = [] # a list for all the handlers self._timeouts = [] # a list for all the handlers

4
shadowsocks/udprelay.py

@ -873,8 +873,8 @@ class UDPRelay(object):
self._dns_cache = lru_cache.LRUCache(timeout=300) self._dns_cache = lru_cache.LRUCache(timeout=300)
self._eventloop = None self._eventloop = None
self._closed = False self._closed = False
self.server_transfer_ul = 0L self.server_transfer_ul = 0
self.server_transfer_dl = 0L self.server_transfer_dl = 0
self._sockets = set() self._sockets = set()
self._fd_to_handlers = {} self._fd_to_handlers = {}

Loading…
Cancel
Save