diff --git a/common/dialer/default.go b/common/dialer/default.go index e53de09a..ebe03fa2 100644 --- a/common/dialer/default.go +++ b/common/dialer/default.go @@ -110,7 +110,13 @@ func NewDefault(router adapter.Router, options option.DialerOptions) *DefaultDia if options.TCPFastOpen { warnTFOOnUnsupportedPlatform.Check() } - if !options.UDPFragment { + var udpFragment bool + if options.UDPFragment != nil { + udpFragment = *options.UDPFragment + } else { + udpFragment = options.UDPFragmentDefault + } + if !udpFragment { dialer.Control = control.Append(dialer.Control, control.DisableUDPFragment()) listener.Control = control.Append(listener.Control, control.DisableUDPFragment()) } diff --git a/common/tls/ech_client.go b/common/tls/ech_client.go index c6238f91..c128ed69 100644 --- a/common/tls/ech_client.go +++ b/common/tls/ech_client.go @@ -165,8 +165,6 @@ func newECHClient(router adapter.Router, serverAddress string, options option.Ou return &echClientConfig{&tlsConfig}, nil } -const typeHTTPS = 65 - func fetchECHClientConfig(router adapter.Router) func(ctx context.Context, serverName string) ([]cftls.ECHConfig, error) { return func(ctx context.Context, serverName string) ([]cftls.ECHConfig, error) { message := &mDNS.Msg{ diff --git a/option/outbound.go b/option/outbound.go index a1926ebf..ca4d938c 100644 --- a/option/outbound.go +++ b/option/outbound.go @@ -120,17 +120,18 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error { } type DialerOptions struct { - Detour string `json:"detour,omitempty"` - BindInterface string `json:"bind_interface,omitempty"` - BindAddress *ListenAddress `json:"bind_address,omitempty"` - ProtectPath string `json:"protect_path,omitempty"` - RoutingMark int `json:"routing_mark,omitempty"` - ReuseAddr bool `json:"reuse_addr,omitempty"` - ConnectTimeout Duration `json:"connect_timeout,omitempty"` - TCPFastOpen bool `json:"tcp_fast_open,omitempty"` - UDPFragment bool `json:"udp_fragment,omitempty"` - DomainStrategy DomainStrategy `json:"domain_strategy,omitempty"` - FallbackDelay Duration `json:"fallback_delay,omitempty"` + Detour string `json:"detour,omitempty"` + BindInterface string `json:"bind_interface,omitempty"` + BindAddress *ListenAddress `json:"bind_address,omitempty"` + ProtectPath string `json:"protect_path,omitempty"` + RoutingMark int `json:"routing_mark,omitempty"` + ReuseAddr bool `json:"reuse_addr,omitempty"` + ConnectTimeout Duration `json:"connect_timeout,omitempty"` + TCPFastOpen bool `json:"tcp_fast_open,omitempty"` + UDPFragment *bool `json:"udp_fragment,omitempty"` + UDPFragmentDefault bool `json:"-"` + DomainStrategy DomainStrategy `json:"domain_strategy,omitempty"` + FallbackDelay Duration `json:"fallback_delay,omitempty"` } type ServerOptions struct { diff --git a/outbound/direct.go b/outbound/direct.go index 567c963a..71989d6f 100644 --- a/outbound/direct.go +++ b/outbound/direct.go @@ -35,6 +35,7 @@ type Direct struct { } func NewDirect(router adapter.Router, logger log.ContextLogger, tag string, options option.DirectOutboundOptions) (*Direct, error) { + options.UDPFragmentDefault = true outbound := &Direct{ myOutboundAdapter: myOutboundAdapter{ protocol: C.TypeDirect,