Skip to content

Commit

Permalink
add ss multiplex
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock authored Oct 30, 2023
1 parent 8a0ea99 commit bc7d061
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions parsers/ss.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tool,json,re,urllib,sys
from urllib.parse import parse_qs
def parse(data):
param = data[5:]
if not param or param.isspace():
Expand Down Expand Up @@ -68,12 +69,27 @@ def parse(data):
'enabled': True,
'fingerprint': plugin.get('fp')
}
if param.find('&') > -1:
smux = param[param.find('&')+1:]
smux_dict = parse_qs(smux)
smux_dict = {k: v[0] for k, v in smux_dict.items() if v[0]}
node['multiplex'] = {
'enabled': True,
'protocol': smux_dict['protocol'],
'max_streams': int(smux_dict.get('max-streams', '0'))
}
if smux_dict.get('max-connections'):
node['multiplex']['max_connections'] = int(smux_dict['max-connections'])
if smux_dict.get('min-streams'):
node['multiplex']['min_streams'] = int(smux_dict['min-streams'])
if smux_dict.get('padding') == 'True':
node['multiplex']['padding'] = True
if param.find('@') > -1:
matcher = re.match(r'(.*?)@(.*):(.*)', param)
if matcher:
param = matcher.group(1)
node['server'] = matcher.group(2)
node['server_port'] = matcher.group(3)
node['server_port'] = matcher.group(3).split('&')[0]
else:
return None
try:
Expand All @@ -91,7 +107,7 @@ def parse(data):
node['method'] = matcher.group(1)
node['password'] = matcher.group(2)
node['server'] = matcher.group(3)
node['server_port'] = matcher.group(4)
node['server_port'] = matcher.group(4).split('&')[0]
else:
return None
node['server_port'] = int(node['server_port'])
Expand Down

0 comments on commit bc7d061

Please sign in to comment.