mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 03:16:47 +00:00
feat: support setting realm-opts.proxy for hysteria2 listener
This commit is contained in:
1 parent
44c94236b3
commit
787dbfc5fd
5 files changed
+7
-1
No files matched your search
@@ -256,6 +256,7 @@ func NewHysteria2(option Hysteria2Option) (*Hysteria2, error) {
|
||||
TLSConfig: &tls.Config{
|
||||
ServerName: option.RealmOpts.SNI,
|
||||
InsecureSkipVerify: option.RealmOpts.SkipCertVerify,
|
||||
NextProtos: option.RealmOpts.ALPN,
|
||||
},
|
||||
Fingerprint: option.RealmOpts.Fingerprint,
|
||||
Certificate: option.RealmOpts.Certificate,
|
||||
|
||||
@@ -1961,6 +1961,7 @@ listeners:
|
||||
# - stun.nextcloud.com:3478
|
||||
# - stun.sip.us:3478
|
||||
# - global.stun.twilio.com:3478
|
||||
# # proxy: DIRECT # 设置server-url通过哪个代理进行连接
|
||||
# # 下面支持填写针对server-url的TLS配置(sni, skip-cert-verify, fingerprint, certificate, private-key, alpn)
|
||||
# # skip-cert-verify: false
|
||||
# # ......
|
||||
|
||||
@@ -51,6 +51,7 @@ type Hysteria2RealmOption struct {
|
||||
Certificate string `yaml:"certificate" json:"certificate,omitempty"`
|
||||
PrivateKey string `yaml:"private-key" json:"private-key,omitempty"`
|
||||
ALPN []string `yaml:"alpn" json:"alpn,omitempty"`
|
||||
Proxy string `yaml:"proxy" json:"proxy,omitempty"`
|
||||
}
|
||||
|
||||
func (h Hysteria2Server) String() string {
|
||||
|
||||
@@ -53,6 +53,7 @@ type Hysteria2RealmOption struct {
|
||||
Certificate string `inbound:"certificate,omitempty"`
|
||||
PrivateKey string `inbound:"private-key,omitempty"`
|
||||
ALPN []string `inbound:"alpn,omitempty"`
|
||||
Proxy string `inbound:"proxy,omitempty"`
|
||||
}
|
||||
|
||||
func (o Hysteria2RealmOption) Build() LC.Hysteria2RealmOption {
|
||||
@@ -68,6 +69,7 @@ func (o Hysteria2RealmOption) Build() LC.Hysteria2RealmOption {
|
||||
Certificate: o.Certificate,
|
||||
PrivateKey: o.PrivateKey,
|
||||
ALPN: o.ALPN,
|
||||
Proxy: o.Proxy,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ func New(config LC.Hysteria2Server, tunnel C.Tunnel, additions ...inbound.Additi
|
||||
TLSConfig: &tls.Config{
|
||||
ServerName: config.RealmOpts.SNI,
|
||||
InsecureSkipVerify: config.RealmOpts.SkipCertVerify,
|
||||
NextProtos: config.RealmOpts.ALPN,
|
||||
},
|
||||
Fingerprint: config.RealmOpts.Fingerprint,
|
||||
Certificate: config.RealmOpts.Certificate,
|
||||
@@ -170,7 +171,7 @@ func New(config LC.Hysteria2Server, tunnel C.Tunnel, additions ...inbound.Additi
|
||||
STUNServers: config.RealmOpts.STUNServers,
|
||||
HTTPClient: &http.Client{Transport: &http.Transport{
|
||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
return inner.HandleTcp(tunnel, address, "")
|
||||
return inner.HandleTcp(tunnel, address, config.RealmOpts.Proxy)
|
||||
},
|
||||
TLSClientConfig: httpTLSClientConfig,
|
||||
// from http.DefaultTransport
|
||||
|
||||
Reference in new issue
Block a user