Skip to content

Commit

Permalink
fix trojan tls
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock committed Mar 27, 2024
1 parent 2ec1a67 commit bc4aeb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions parsers/clash2base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def clash2v2ray(share_link):
"server": share_link['server'],
"port": share_link['port'],
"sni": share_link.get('sni', ''),
"skip_cert_verify": share_link.get('skip-cert-verify', False),
"allowInsecure": '1' if share_link.get('skip-cert-verify') == True else '0',
"type": share_link.get('network', 'tcp'),
"fp": share_link.get('client-fingerprint', ''),
"alpn": quote(','.join(share_link.get('alpn', '')), 'utf-8'),
Expand All @@ -152,17 +152,17 @@ def clash2v2ray(share_link):
trojan_info["serviceName"] = server_parts[-2]
else:
trojan_info["serviceName"] = ''
link = "trojan://{password}@{server}:{port}?sni={sni}&skip_cert_verify={skip_cert_verify}&type={type}&serviceName={serviceName}&fp={fp}&alpn={alpn}".format(**trojan_info)
link = "trojan://{password}@{server}:{port}?sni={sni}&allowInsecure={allowInsecure}&type={type}&serviceName={serviceName}&fp={fp}&alpn={alpn}".format(**trojan_info)
elif trojan_info['type'] == 'ws':
if share_link.get('ws-opts'):
trojan_info["path"] = quote(share_link['ws-opts'].get('path', ''), 'utf-8')
trojan_info["host"] = share_link.get('ws-opts', {}).get('headers', {}).get('Host', '')
else:
trojan_info["path"] = ''
trojan_info["host"] = trojan_info["sni"]
link = "trojan://{password}@{server}:{port}?sni={sni}&skip_cert_verify={skip_cert_verify}&type={type}&host={host}&path={path}&fp={fp}&alpn={alpn}".format(**trojan_info)
link = "trojan://{password}@{server}:{port}?sni={sni}&allowInsecure={allowInsecure}&type={type}&host={host}&path={path}&fp={fp}&alpn={alpn}".format(**trojan_info)
elif trojan_info['type'] == 'tcp':
link = "trojan://{password}@{server}:{port}?sni={sni}&skip_cert_verify={skip_cert_verify}&type={type}&fp={fp}&alpn={alpn}".format(**trojan_info)
link = "trojan://{password}@{server}:{port}?sni={sni}&allowInsecure={allowInsecure}&type={type}&fp={fp}&alpn={alpn}".format(**trojan_info)
if share_link.get('smux',{}).get('enabled', '') == True:
trojan_info["protocol"] = share_link['smux']['protocol']
trojan_info["max_connections"] = share_link['smux'].get('max-connections','')
Expand Down
2 changes: 1 addition & 1 deletion parsers/trojan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def parse(data):
'insecure': False
}
}
if netquery.get('skip_cert_verify') == True:
if netquery.get('allowInsecure') == '1':
node['tls']['insecure'] = True
if netquery.get('alpn'):
node['tls']['alpn'] = netquery.get('alpn').strip('{}').split(',')
Expand Down

0 comments on commit bc4aeb5

Please sign in to comment.