hysteria 2 配置

背景

  hysteria 2,通过魔改QUIC协议,可以跑满本地带宽,但是需要能够直连上VPS,不能通过Cloudflare等cdn方式连接。根据不良林的教程,能够在Windows上使用v2ray连接,但是对于Android上使用sing-box连接,存在连接错误的问题。

解决方案

  sing-box配置文件较为复杂,而且我所使用的VPS又是只有IPv6地址的,所以情况又会更为复杂些。具体的注意点已在配置文件中的解释部分标出。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
{
"log": {
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns_proxy", # dns标签,此处为使用代理时,所使用的dns
"address": "2a01:4f8:c2c:123f::1", # dns地址,当远程VPS只有IPv6时,需要写NAT64的dns,否则域名解析会出错
"address_resolver": "dns_resolver", # 如果上面填写的address是域名,则需要另一个dns将域名解析成地址
"strategy": "prefer_ipv6", # 对于只有IPv6的VPS,不能填ipv*_only
"detour": "proxy"
},
{
"tag": "dns_direct",
"address": "h3://dns.alidns.com/dns-query",
"address_resolver": "dns_resolver",
"strategy": "prefer_ipv4", # 不能填写ipv*_only,否则outbounds里面填写的服务器域名可能无法解析
"detour": "direct"
},
{
"tag": "dns_block",
"address": "rcode://refused"
},
{
"tag": "dns_resolver",
"address": "223.5.5.5",
"strategy": "prefer_ipv4", # 对于只有IPv6的VPS,不能填ipv*_only
"detour": "direct"
}
],
"rules": [
{
"outbound": "any",
"server": "dns_resolver"
},
{
"geosite": "category-ads-all",
"server": "dns_block",
"disable_cache": true
},
{
"geosite": "geolocation-!cn",
"server": "dns_proxy"
},
{
"geosite": [
"cn",
"private"
],
"server": "dns_direct"
}
]
},
"ntp": {
"enabled": true,
"interval": "30m0s",
"server": "time.apple.com",
"server_port": 123,
"detour": "direct"
},
"inbounds": [
{
"type": "tun", # tunnel 模式
"tag": "tun-in",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"mtu": 1400,
"auto_route": true,
"strict_route": true,
"stack": "gvisor",
"sniff": true,
"sniff_override_destination": false
},
{
"type": "socks", # socks 模式
"tag": "socks-in",
"listen": "::",
"listen_port": 15353,
"udp_fragment": false,
"udp_timeout": 300,
"sniff_timeout": "300ms",
"domain_strategy": "prefer_ipv6"
}
],
"outbounds": [
{
"type": "hysteria2", # hysteria 2 模式
"tag": "proxy", # outbound 标签
"server": "www.test.com", # 部署 hysteria 2 服务的域名
"server_port": 443,
"up_mbps": 20, # 上行带宽
"down_mbps": 100, # 下行带宽
"password": "auth-password", # 密码
"tls": {
"enabled": true,
"server_name": "www.test.com",
"insecure": true # 自签证书时填true
}
},
{
"type": "vmess",
"tag": "proxy_vmess",
"connect_timeout": "5s",
"tcp_fast_open": true,
"udp_fragment": true,
"server": "www.test.com",
"server_port": 443,
"uuid": "uuid",
"security": "auto",
"tls": {
"enabled": true,
"insecure": true
},
"transport": {
"type": "ws",
"path": "/path"
}
}
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"protocol": "quic",
"outbound": "block"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"geosite": "geolocation-!cn"
},
{
"geoip": "cn",
"invert": true
}
],
"outbound": "proxy"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"geosite": "cn"
},
{
"geoip": "cn"
}
],
"outbound": "direct"
},
{
"geosite": "private",
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "direct"
}
],
"auto_detect_interface": true
}
}

参考链接