Browse Source

feat: builder of Hysteria

master
dnomd343 2 years ago
parent
commit
ab5278e3cc
  1. 28
      Builder/Hysteria.py
  2. 2
      Builder/__init__.py
  3. 16
      demo.py
  4. 36
      docs/ProxyObject/Hysteria.md

28
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), {}

2
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'],
}

16
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)

36
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*

Loading…
Cancel
Save