Browse Source

update: change pluginArg to pluginParam

master
Dnomd343 3 years ago
parent
commit
a1ab369cce
  1. 8
      ProxyBuilder/Shadowsocks.py
  2. 3
      ProxyBuilder/builder.py
  3. 38
      demo.py
  4. 4
      test/Shadowsocks.py

8
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']:

3
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失败 回退正常启动

38
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')

4
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',

Loading…
Cancel
Save