mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-09 13:59:54 +00:00
Merge pull request #239 from HyNetwork/fix-pmtud
feat: re-enable PMTUD on Windows & Linux
This commit is contained in:
commit
be45ab1344
@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/oschwald/geoip2-golang"
|
"github.com/oschwald/geoip2-golang"
|
||||||
|
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -70,7 +71,7 @@ func client(config *clientConfig) {
|
|||||||
InitialConnectionReceiveWindow: config.ReceiveWindow,
|
InitialConnectionReceiveWindow: config.ReceiveWindow,
|
||||||
MaxConnectionReceiveWindow: config.ReceiveWindow,
|
MaxConnectionReceiveWindow: config.ReceiveWindow,
|
||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
DisablePathMTUDiscovery: true, // Ref: https://github.com/lucas-clemente/quic-go/issues/3327
|
DisablePathMTUDiscovery: config.DisableMTUDiscovery,
|
||||||
EnableDatagrams: true,
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
if config.ReceiveWindowConn == 0 {
|
if config.ReceiveWindowConn == 0 {
|
||||||
@ -81,6 +82,9 @@ func client(config *clientConfig) {
|
|||||||
quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
||||||
quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow
|
||||||
}
|
}
|
||||||
|
if !quicConfig.DisablePathMTUDiscovery && pmtud_fix.DisablePathMTUDiscovery {
|
||||||
|
logrus.Info("Path MTU Discovery is not yet supported on this platform")
|
||||||
|
}
|
||||||
// Auth
|
// Auth
|
||||||
var auth []byte
|
var auth []byte
|
||||||
if len(config.Auth) > 0 {
|
if len(config.Auth) > 0 {
|
||||||
|
@ -49,6 +49,7 @@ type serverConfig struct {
|
|||||||
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
||||||
ReceiveWindowClient uint64 `json:"recv_window_client"`
|
ReceiveWindowClient uint64 `json:"recv_window_client"`
|
||||||
MaxConnClient int `json:"max_conn_client"`
|
MaxConnClient int `json:"max_conn_client"`
|
||||||
|
DisableMTUDiscovery bool `json:"disable_mtu_discovery"`
|
||||||
IPv6Only bool `json:"ipv6_only"`
|
IPv6Only bool `json:"ipv6_only"`
|
||||||
Resolver string `json:"resolver"`
|
Resolver string `json:"resolver"`
|
||||||
}
|
}
|
||||||
@ -140,18 +141,19 @@ type clientConfig struct {
|
|||||||
Listen string `json:"listen"`
|
Listen string `json:"listen"`
|
||||||
Timeout int `json:"timeout"`
|
Timeout int `json:"timeout"`
|
||||||
} `json:"tproxy_udp"`
|
} `json:"tproxy_udp"`
|
||||||
ACL string `json:"acl"`
|
ACL string `json:"acl"`
|
||||||
MMDB string `json:"mmdb"`
|
MMDB string `json:"mmdb"`
|
||||||
Obfs string `json:"obfs"`
|
Obfs string `json:"obfs"`
|
||||||
Auth []byte `json:"auth"`
|
Auth []byte `json:"auth"`
|
||||||
AuthString string `json:"auth_str"`
|
AuthString string `json:"auth_str"`
|
||||||
ALPN string `json:"alpn"`
|
ALPN string `json:"alpn"`
|
||||||
ServerName string `json:"server_name"`
|
ServerName string `json:"server_name"`
|
||||||
Insecure bool `json:"insecure"`
|
Insecure bool `json:"insecure"`
|
||||||
CustomCA string `json:"ca"`
|
CustomCA string `json:"ca"`
|
||||||
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
||||||
ReceiveWindow uint64 `json:"recv_window"`
|
ReceiveWindow uint64 `json:"recv_window"`
|
||||||
Resolver string `json:"resolver"`
|
DisableMTUDiscovery bool `json:"disable_mtu_discovery"`
|
||||||
|
Resolver string `json:"resolver"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *clientConfig) Check() error {
|
func (c *clientConfig) Check() error {
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
hyCongestion "github.com/tobyxdd/hysteria/pkg/congestion"
|
hyCongestion "github.com/tobyxdd/hysteria/pkg/congestion"
|
||||||
"github.com/tobyxdd/hysteria/pkg/core"
|
"github.com/tobyxdd/hysteria/pkg/core"
|
||||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||||
|
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||||
"io"
|
"io"
|
||||||
@ -70,7 +71,7 @@ func server(config *serverConfig) {
|
|||||||
MaxConnectionReceiveWindow: config.ReceiveWindowClient,
|
MaxConnectionReceiveWindow: config.ReceiveWindowClient,
|
||||||
MaxIncomingStreams: int64(config.MaxConnClient),
|
MaxIncomingStreams: int64(config.MaxConnClient),
|
||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
DisablePathMTUDiscovery: true, // Ref: https://github.com/lucas-clemente/quic-go/issues/3327
|
DisablePathMTUDiscovery: config.DisableMTUDiscovery,
|
||||||
EnableDatagrams: true,
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
if config.ReceiveWindowConn == 0 {
|
if config.ReceiveWindowConn == 0 {
|
||||||
@ -84,6 +85,9 @@ func server(config *serverConfig) {
|
|||||||
if quicConfig.MaxIncomingStreams == 0 {
|
if quicConfig.MaxIncomingStreams == 0 {
|
||||||
quicConfig.MaxIncomingStreams = DefaultMaxIncomingStreams
|
quicConfig.MaxIncomingStreams = DefaultMaxIncomingStreams
|
||||||
}
|
}
|
||||||
|
if !quicConfig.DisablePathMTUDiscovery && pmtud_fix.DisablePathMTUDiscovery {
|
||||||
|
logrus.Info("Path MTU Discovery is not yet supported on this platform")
|
||||||
|
}
|
||||||
// Auth
|
// Auth
|
||||||
var authFunc core.ConnectFunc
|
var authFunc core.ConnectFunc
|
||||||
var err error
|
var err error
|
||||||
|
5
go.mod
5
go.mod
@ -13,7 +13,7 @@ require (
|
|||||||
github.com/fsnotify/fsnotify v1.5.1
|
github.com/fsnotify/fsnotify v1.5.1
|
||||||
github.com/google/gopacket v1.1.19
|
github.com/google/gopacket v1.1.19
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
github.com/lucas-clemente/quic-go v0.24.0
|
github.com/lucas-clemente/quic-go v0.25.0
|
||||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
|
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
|
||||||
github.com/oschwald/geoip2-golang v1.6.1
|
github.com/oschwald/geoip2-golang v1.6.1
|
||||||
github.com/prometheus/client_golang v1.12.1
|
github.com/prometheus/client_golang v1.12.1
|
||||||
@ -37,6 +37,7 @@ require (
|
|||||||
github.com/magiconair/properties v1.8.5 // indirect
|
github.com/magiconair/properties v1.8.5 // indirect
|
||||||
github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect
|
github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect
|
||||||
github.com/marten-seemann/qtls-go1-17 v0.1.0 // indirect
|
github.com/marten-seemann/qtls-go1-17 v0.1.0 // indirect
|
||||||
|
github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||||
github.com/mholt/acmez v1.0.1 // indirect
|
github.com/mholt/acmez v1.0.1 // indirect
|
||||||
github.com/miekg/dns v1.1.43 // indirect
|
github.com/miekg/dns v1.1.43 // indirect
|
||||||
@ -73,4 +74,4 @@ require (
|
|||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/lucas-clemente/quic-go => github.com/tobyxdd/quic-go v0.24.0-mod
|
replace github.com/lucas-clemente/quic-go => github.com/tobyxdd/quic-go v0.25.1-0.20220220071449-45d21d89d5d4
|
||||||
|
6
go.sum
6
go.sum
@ -332,6 +332,8 @@ github.com/marten-seemann/qtls-go1-16 v0.1.4 h1:xbHbOGGhrenVtII6Co8akhLEdrawwB2i
|
|||||||
github.com/marten-seemann/qtls-go1-16 v0.1.4/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk=
|
github.com/marten-seemann/qtls-go1-16 v0.1.4/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk=
|
||||||
github.com/marten-seemann/qtls-go1-17 v0.1.0 h1:P9ggrs5xtwiqXv/FHNwntmuLMNq3KaSIG93AtAZ48xk=
|
github.com/marten-seemann/qtls-go1-17 v0.1.0 h1:P9ggrs5xtwiqXv/FHNwntmuLMNq3KaSIG93AtAZ48xk=
|
||||||
github.com/marten-seemann/qtls-go1-17 v0.1.0/go.mod h1:fz4HIxByo+LlWcreM4CZOYNuz3taBQ8rN2X6FqvaWo8=
|
github.com/marten-seemann/qtls-go1-17 v0.1.0/go.mod h1:fz4HIxByo+LlWcreM4CZOYNuz3taBQ8rN2X6FqvaWo8=
|
||||||
|
github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1 h1:EnzzN9fPUkUck/1CuY1FlzBaIYMoiBsdwTNmNGkwUUM=
|
||||||
|
github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1/go.mod h1:PUhIQk19LoFt2174H4+an8TYvWOGjb/hHwphBeaDHwI=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
@ -500,8 +502,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||||
github.com/tobyxdd/quic-go v0.24.0-mod h1:nEBhj/pWwa8UaZVUcXBLhbnWU9ndNATVzg7op3nKBn0=
|
github.com/tobyxdd/quic-go v0.25.1-0.20220220071449-45d21d89d5d4 h1:2oHsHe9vfX0djOpa6y0OahD/wmtdbrLN6o/idWT7hWo=
|
||||||
github.com/tobyxdd/quic-go v0.24.0-mod/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0=
|
github.com/tobyxdd/quic-go v0.25.1-0.20220220071449-45d21d89d5d4/go.mod h1:YtzP8bxRVCBlO77yRanE264+fY/T2U9ZlW1AaHOsMOg=
|
||||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||||
github.com/txthinking/runnergroup v0.0.0-20210326110939-37fc67d0da7c h1:6WIrmZPMl2Q61vozy5MfJNfD6CAgivGFgqvXsrho8GM=
|
github.com/txthinking/runnergroup v0.0.0-20210326110939-37fc67d0da7c h1:6WIrmZPMl2Q61vozy5MfJNfD6CAgivGFgqvXsrho8GM=
|
||||||
github.com/txthinking/runnergroup v0.0.0-20210326110939-37fc67d0da7c/go.mod h1:CLUSJbazqETbaR+i0YAhXBICV9TrKH93pziccMhmhpM=
|
github.com/txthinking/runnergroup v0.0.0-20210326110939-37fc67d0da7c/go.mod h1:CLUSJbazqETbaR+i0YAhXBICV9TrKH93pziccMhmhpM=
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/lucas-clemente/quic-go/congestion"
|
"github.com/lucas-clemente/quic-go/congestion"
|
||||||
"github.com/lunixbochs/struc"
|
"github.com/lunixbochs/struc"
|
||||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||||
|
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||||
"net"
|
"net"
|
||||||
@ -47,6 +48,7 @@ type Client struct {
|
|||||||
func NewClient(serverAddr string, protocol string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config,
|
func NewClient(serverAddr string, protocol string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config,
|
||||||
transport *transport.ClientTransport, sendBPS uint64, recvBPS uint64, congestionFactory CongestionFactory,
|
transport *transport.ClientTransport, sendBPS uint64, recvBPS uint64, congestionFactory CongestionFactory,
|
||||||
obfuscator obfs.Obfuscator) (*Client, error) {
|
obfuscator obfs.Obfuscator) (*Client, error) {
|
||||||
|
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery
|
||||||
c := &Client{
|
c := &Client{
|
||||||
transport: transport,
|
transport: transport,
|
||||||
serverAddr: serverAddr,
|
serverAddr: serverAddr,
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/tobyxdd/hysteria/pkg/acl"
|
"github.com/tobyxdd/hysteria/pkg/acl"
|
||||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||||
|
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
@ -46,6 +47,7 @@ func NewServer(addr string, protocol string, tlsConfig *tls.Config, quicConfig *
|
|||||||
obfuscator obfs.Obfuscator, connectFunc ConnectFunc, disconnectFunc DisconnectFunc,
|
obfuscator obfs.Obfuscator, connectFunc ConnectFunc, disconnectFunc DisconnectFunc,
|
||||||
tcpRequestFunc TCPRequestFunc, tcpErrorFunc TCPErrorFunc,
|
tcpRequestFunc TCPRequestFunc, tcpErrorFunc TCPErrorFunc,
|
||||||
udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry) (*Server, error) {
|
udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry) (*Server, error) {
|
||||||
|
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery
|
||||||
listener, err := transport.QUICListen(protocol, addr, tlsConfig, quicConfig, obfuscator)
|
listener, err := transport.QUICListen(protocol, addr, tlsConfig, quicConfig, obfuscator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
8
pkg/pmtud_fix/avail.go
Normal file
8
pkg/pmtud_fix/avail.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build linux || windows
|
||||||
|
// +build linux windows
|
||||||
|
|
||||||
|
package pmtud_fix
|
||||||
|
|
||||||
|
const (
|
||||||
|
DisablePathMTUDiscovery = false
|
||||||
|
)
|
8
pkg/pmtud_fix/unavail.go
Normal file
8
pkg/pmtud_fix/unavail.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build !linux && !windows
|
||||||
|
// +build !linux,!windows
|
||||||
|
|
||||||
|
package pmtud_fix
|
||||||
|
|
||||||
|
const (
|
||||||
|
DisablePathMTUDiscovery = true
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user