本文整理匯總了Python中shadowsocks.common.PortRange方法的典型用法代碼示例。如果您正苦於以下問題:Python common.PortRange方法的具體用法?Python common.PortRange怎麽用?Python common.PortRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shadowsocks.common
的用法示例。
在下文中一共展示了common.PortRange方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pull_db_all_user
# 需要導入模塊: from shadowsocks import common [as 別名]
# 或者: from shadowsocks.common import PortRange [as 別名]
def pull_db_all_user(self):
import json
rows = None
config_path = get_config().MUDB_FILE
with open(config_path, 'rb+') as f:
rows = json.loads(f.read().decode('utf8'))
for row in rows:
try:
if 'forbidden_ip' in row:
row['forbidden_ip'] = common.IPNetwork(row['forbidden_ip'])
except Exception as e:
logging.error(e)
try:
if 'forbidden_port' in row:
row['forbidden_port'] = common.PortRange(row['forbidden_port'])
except Exception as e:
logging.error(e)
if not rows:
logging.warn('no user in json file')
return rows
示例2: modify_multi_user_table
# 需要導入模塊: from shadowsocks import common [as 別名]
# 或者: from shadowsocks.common import PortRange [as 別名]
def modify_multi_user_table(self, new_table):
self.multi_user_table = new_table.copy()
self.multi_user_host_table = {}
self._protocol.obfs.server_info.users = self.multi_user_table
for id in self.multi_user_table:
self.multi_user_host_table[common.get_mu_host(
id, self.multi_user_table[id]['md5'])] = id
if self.multi_user_table[id]['forbidden_ip'] is not None:
self.multi_user_table[id]['_forbidden_iplist'] = IPNetwork(
str(self.multi_user_table[id]['forbidden_ip']))
else:
self.multi_user_table[id][
'_forbidden_iplist'] = IPNetwork(str(""))
if self.multi_user_table[id]['disconnect_ip'] is not None:
self.multi_user_table[id]['_disconnect_ipset'] = IPNetwork(
str(self.multi_user_table[id]['disconnect_ip']))
else:
self.multi_user_table[id]['_disconnect_ipset'] = None
if self.multi_user_table[id]['forbidden_port'] is not None:
self.multi_user_table[id]['_forbidden_portset'] = PortRange(
str(self.multi_user_table[id]['forbidden_port']))
else:
self.multi_user_table[id][
'_forbidden_portset'] = PortRange(str(""))
示例3: modify_multi_user_table
# 需要導入模塊: from shadowsocks import common [as 別名]
# 或者: from shadowsocks.common import PortRange [as 別名]
def modify_multi_user_table(self, new_table):
self.multi_user_table = new_table.copy()
self.multi_user_host_table = {}
for id in self.multi_user_table:
if id not in self.mu_reset_time:
self.mu_reset_time[id] = time.time()
self.multi_user_host_table[common.get_mu_host(
id, self.multi_user_table[id]['md5'])] = id
if self.multi_user_table[id]['forbidden_ip'] is not None:
self.multi_user_table[id]['_forbidden_iplist'] = IPNetwork(
str(self.multi_user_table[id]['forbidden_ip']))
else:
self.multi_user_table[id][
'_forbidden_iplist'] = IPNetwork(str(""))
if self.multi_user_table[id]['disconnect_ip'] is not None:
self.multi_user_table[id]['_disconnect_ipset'] = IPNetwork(
str(self.multi_user_table[id]['disconnect_ip']))
else:
self.multi_user_table[id]['_disconnect_ipset'] = None
if self.multi_user_table[id]['forbidden_port'] is not None:
self.multi_user_table[id]['_forbidden_portset'] = PortRange(
str(self.multi_user_table[id]['forbidden_port']))
else:
self.multi_user_table[id][
'_forbidden_portset'] = PortRange(str(""))
if 'node_speedlimit' not in self.multi_user_table[id]:
bandwidth = 0
else:
bandwidth = float(
self.multi_user_table[id]['node_speedlimit']) * 128
self.mu_speed_tester_u[id] = SpeedTester(bandwidth)
self.mu_speed_tester_d[id] = SpeedTester(bandwidth)