diff --git a/Builder/Hysteria.py b/Builder/Hysteria.py new file mode 100644 index 0000000..a50ab2c --- /dev/null +++ b/Builder/Hysteria.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import json +from Basis.Functions import hostFormat + + +def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: + hysteriaConfig = {**{ + 'server': '%s:%i' % (hostFormat(proxyInfo['server'], v6Bracket = True), proxyInfo['port']), + 'protocol': proxyInfo['protocol'], + 'up_mbps': proxyInfo['up'], + 'down_mbps': proxyInfo['down'], + 'socks5': { + 'listen': '%s:%i' % (hostFormat(socksInfo['addr'], v6Bracket = True), socksInfo['port']) + } + }, **({} if proxyInfo['obfs'] is None else { + 'obfs': proxyInfo['obfs'] + }), **({} if proxyInfo['passwd'] is None else { + 'auth_str': proxyInfo['passwd'] + }), **({} if proxyInfo['sni'] == '' else { + 'server_name': proxyInfo['sni'] + }), **({} if proxyInfo['alpn'] is None else { + 'alpn': proxyInfo['alpn'] + }), **({} if proxyInfo['verify'] else { + 'insecure': True + })} + return ['hysteria', '-c', configFile, 'client'], json.dumps(hysteriaConfig), {} diff --git a/Builder/__init__.py b/Builder/__init__.py index 322c26d..e0e1e7c 100644 --- a/Builder/__init__.py +++ b/Builder/__init__.py @@ -9,6 +9,7 @@ from Builder import VMess from Builder import VLESS from Builder import Trojan from Builder import TrojanGo +from Builder import Hysteria from Builder import Shadowsocks from Builder import ShadowsocksR @@ -25,6 +26,7 @@ clientEntry = { 'trojan': [Trojan.load, '.json'], 'trojan-go': [TrojanGo.load, '.json'], 'brook': [Brook.load, ''], + 'hysteria': [Hysteria.load, '.json'], } diff --git a/demo.py b/demo.py index 243d843..8696076 100755 --- a/demo.py +++ b/demo.py @@ -112,13 +112,27 @@ proxyBrook = { } } +proxyHysteria = { + 'server': '127.0.0.1', + 'port': 12345, + 'protocol': 'udp', + 'obfs': 'obfs', + 'passwd': 'dnomd343', + 'up': 10, + 'down': 50, + 'sni': '343.re', + 'alpn': 'h3', + 'verify': False, +} + # client = Builder('ss', proxySS) # client = Builder('ssr', proxySSR) # client = Builder('vmess', proxyVMess) # client = Builder('vless', proxyVLESS) # client = Builder('trojan', proxyTrojan) # client = Builder('trojan-go', proxyTrojanGo) -client = Builder('brook', proxyBrook) +# client = Builder('brook', proxyBrook) +client = Builder('hysteria', proxyHysteria) logging.critical(client.id) logging.critical(client.proxyType) diff --git a/docs/ProxyObject/Hysteria.md b/docs/ProxyObject/Hysteria.md index 86dc31e..98b6a22 100644 --- a/docs/ProxyObject/Hysteria.md +++ b/docs/ProxyObject/Hysteria.md @@ -5,10 +5,10 @@ 'server': ---, 'port': ---, 'protocol': ---, - 'upMbps': ---, - 'downMbps': ---, 'obfs': ---, - 'auth': ---, + 'passwd': ---, + 'up': ---, + 'down': ---, 'sni': ---, 'alpn': ---, 'verify': ---, @@ -36,20 +36,6 @@ + 缺省:`udp` + 限制:`udp`, `wechat-video`, `faketcp` -### upMbps - -+ 类型:*int* -+ 说明:Hysteria最大上行速率 -+ 缺省:`10` -+ 限制:>0 - -### downMbps - -+ 类型:*int* -+ 说明:Hysteria最大下行速率 -+ 缺省:`50` -+ 限制:>0 - ### obfs + 类型:*None* / *str* @@ -57,13 +43,27 @@ + 缺省:`None` + 限制:无 -### auth +### passwd + 类型:*None* / *str* + 说明:Hysteria验证密码 + 缺省:`None` + 限制:无 +### up + ++ 类型:*int* ++ 说明:Hysteria最大上行速率(Mbps) ++ 缺省:`10` ++ 限制:>0 + +### down + ++ 类型:*int* ++ 说明:Hysteria最大下行速率(Mbps) ++ 缺省:`50` ++ 限制:>0 + ### sni + 类型:*str*