Skip to content

Commit

Permalink
fix type of http clash
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock authored Nov 7, 2023
1 parent 5d6ae16 commit 102c4c6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions parsers/clash2base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,23 +266,31 @@ def clash2v2ray(share_link):
# TODO
elif share_link['type'] == 'http':
http_info = {
"user": share_link['username'],
"password": share_link['password'],
"server": share_link['server'],
"port": share_link['port'],
"name": quote(share_link.get('name', ''), 'utf-8')
}
base_link = base64.b64encode("{user}:{password}@{server}:{port}/#{name}".format(**http_info).encode('utf-8')).decode('utf-8')
if share_link.get('username'):
if share_link['password']:
http_info ["user"] = share_link['username']
http_info ["password"] = share_link['password']
base_link = base64.b64encode("{user}:{password}@{server}:{port}".format(**http_info).encode('utf-8')).decode('utf-8')
else:
base_link = base64.b64encode("{server}:{port}".format(**http_info).encode('utf-8')).decode('utf-8')
link = f"https://{base_link}"
if share_link.get('name'):
link += f"#{share_link['name']}"
return link
# TODO
elif share_link['type'] == 'socks5':
socks5_info = {
"server": share_link['server'],
"port": share_link['port'],
}
if share_link.get('username') and share_link.get('password'):
base_link = base64.b64encode("{user}:{password}@{server}:{port}".format(**socks5_info).encode('utf-8')).decode('utf-8')
if share_link.get('username'):
if share_link['password']:
socks5_info ["user"] = share_link['username']
socks5_info ["password"] = share_link['password']
base_link = base64.b64encode("{user}:{password}@{server}:{port}".format(**socks5_info).encode('utf-8')).decode('utf-8')
else:
base_link = base64.b64encode("{server}:{port}".format(**socks5_info).encode('utf-8')).decode('utf-8')
link = f"socks://{base_link}"
Expand Down

0 comments on commit 102c4c6

Please sign in to comment.