From a1ab369cce2914c75fcfd65201ef506089c6a6af Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 11 Feb 2022 14:48:15 +0800 Subject: [PATCH] update: change pluginArg to pluginParam --- ProxyBuilder/Shadowsocks.py | 8 ++++---- ProxyBuilder/builder.py | 3 +++ demo.py | 38 ++++++++++++++++++------------------- test/Shadowsocks.py | 4 ++-- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ProxyBuilder/Shadowsocks.py b/ProxyBuilder/Shadowsocks.py index 9f4780b..1164baa 100644 --- a/ProxyBuilder/Shadowsocks.py +++ b/ProxyBuilder/Shadowsocks.py @@ -149,10 +149,10 @@ def __baseJSON(proxyInfo, socksPort): # 生成JSON基本结构 } if proxyInfo['plugin'] != '': jsonContent['plugin'] = proxyInfo['plugin'] - jsonContent['plugin_opts'] = proxyInfo['pluginArg'] + jsonContent['plugin_opts'] = proxyInfo['pluginParam'] return jsonContent -def __pluginUdpCheck(plugin, pluginArg): # 插件是否使用UDP通讯 +def __pluginUdpCheck(plugin, pluginParam): # 插件是否使用UDP通讯 if plugin == '': # 无插件 return False noUdpPlugin = [ # 不使用UDP通讯的插件 @@ -173,7 +173,7 @@ def __pluginUdpCheck(plugin, pluginArg): # 插件是否使用UDP通讯 if plugin in onlyUdpPlugin: return True if plugin == 'v2ray-plugin' or plugin == 'xray-plugin' or plugin == 'gost-plugin': - if not 'mode=quic' in pluginArg.split(';'): + if not 'mode=quic' in pluginParam.split(';'): return False return True # 默认假定占用UDP @@ -216,7 +216,7 @@ def __ssRust(proxyInfo, socksPort): # ss-rust配置文件生成 return jsonContent, 'ss-rust-local' def load(proxyInfo, socksPort, configFile): # Shadowsocks配置载入 - proxyInfo['udp'] = not __pluginUdpCheck(proxyInfo['plugin'], proxyInfo['pluginArg']) + proxyInfo['udp'] = not __pluginUdpCheck(proxyInfo['plugin'], proxyInfo['pluginParam']) if proxyInfo['method'] in ssMethodList['ss-libev']: jsonContent, ssFile = __ssLibev(proxyInfo, socksPort) elif proxyInfo['method'] in ssMethodList['ss-libev-legacy']: diff --git a/ProxyBuilder/builder.py b/ProxyBuilder/builder.py index a0ab8df..9a5fcb7 100644 --- a/ProxyBuilder/builder.py +++ b/ProxyBuilder/builder.py @@ -77,8 +77,10 @@ def build(proxyInfo, configDir): # 构建代理节点连接 elif proxyType == 'ssr': # ShadowsocksR节点 startCommand, fileContent = ShadowsocksR.load(proxyInfo, socksPort, configFile) else: # 未知类型 + print("Unknown proxy type") return None if startCommand == None: # 格式出错 + print("Format error with " + proxyType) return None try: with open(configFile, 'w') as fileObject: @@ -97,6 +99,7 @@ def build(proxyInfo, configDir): # 构建代理节点连接 stderr = subprocess.DEVNULL, preexec_fn = exitWithMe) # 子进程跟随退出 except: + print("WARNING: Subprocess may become a Orphan Process") process = subprocess.Popen(startCommand, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) # prctl失败 回退正常启动 diff --git a/demo.py b/demo.py index f83a2a3..ea3941c 100644 --- a/demo.py +++ b/demo.py @@ -8,28 +8,28 @@ import requests import ProxyBuilder as Builder import ProxyChecker as Checker -# testInfo = { -# 'type': 'ss', -# 'server': '127.0.0.1', -# 'port': 12345, -# 'password': 'dnomd343', -# 'method': 'aes-256-ctr', -# 'plugin': '', -# 'pluginArg': '', -# } - testInfo = { - 'type': 'ssr', - "server": "127.0.0.1", - "port": 23456, - "password": "dnomd343", - "method": "table", - "protocol": "auth_aes128_md5", - "protocolParam": "", - "obfs": "tls1.2_ticket_auth", - "obfsParam": "" + 'type': 'ss', + 'server': '127.0.0.1', + 'port': 12345, + 'password': 'dnomd343', + 'method': 'aes-256-ctr', + 'plugin': '', + 'pluginParam': '', } +# testInfo = { +# 'type': 'ssr', +# "server": "127.0.0.1", +# "port": 23456, +# "password": "dnomd343", +# "method": "table", +# "protocol": "auth_aes128_md5", +# "protocolParam": "", +# "obfs": "tls1.2_ticket_auth", +# "obfsParam": "" +# } + print("start") print(testInfo) task = Builder.build(testInfo, '/tmp/ProxyC') diff --git a/test/Shadowsocks.py b/test/Shadowsocks.py index ca79e4d..13ae286 100644 --- a/test/Shadowsocks.py +++ b/test/Shadowsocks.py @@ -63,7 +63,7 @@ def test(port, password): 'password': password, 'method': method, 'plugin': '', - 'pluginArg': '', + 'pluginParam': '', } testInfo = 'Shadowsocks method ' + method if method == 'plain' or method == 'none': @@ -115,7 +115,7 @@ def test(port, password): 'password': password, 'method': 'aes-256-ctr', 'plugin': 'obfs-local', - 'pluginArg': 'obfs=http;obfs-host=www.bing.com', + 'pluginParam': 'obfs=http;obfs-host=www.bing.com', }, 'serverCommand': [ 'ss-bootstrap-server',