mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-08-23 09:41:46 +00:00
Merge pull request #1016 from xchacha20-poly1305/dev-android-protect
feat: support Android protect path
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/apernet/hysteria/app/internal/http"
|
||||
"github.com/apernet/hysteria/app/internal/proxymux"
|
||||
"github.com/apernet/hysteria/app/internal/redirect"
|
||||
"github.com/apernet/hysteria/app/internal/sockopts"
|
||||
"github.com/apernet/hysteria/app/internal/socks5"
|
||||
"github.com/apernet/hysteria/app/internal/tproxy"
|
||||
"github.com/apernet/hysteria/app/internal/tun"
|
||||
@@ -100,13 +101,20 @@ type clientConfigTLS struct {
|
||||
}
|
||||
|
||||
type clientConfigQUIC struct {
|
||||
InitStreamReceiveWindow uint64 `mapstructure:"initStreamReceiveWindow"`
|
||||
MaxStreamReceiveWindow uint64 `mapstructure:"maxStreamReceiveWindow"`
|
||||
InitConnectionReceiveWindow uint64 `mapstructure:"initConnReceiveWindow"`
|
||||
MaxConnectionReceiveWindow uint64 `mapstructure:"maxConnReceiveWindow"`
|
||||
MaxIdleTimeout time.Duration `mapstructure:"maxIdleTimeout"`
|
||||
KeepAlivePeriod time.Duration `mapstructure:"keepAlivePeriod"`
|
||||
DisablePathMTUDiscovery bool `mapstructure:"disablePathMTUDiscovery"`
|
||||
InitStreamReceiveWindow uint64 `mapstructure:"initStreamReceiveWindow"`
|
||||
MaxStreamReceiveWindow uint64 `mapstructure:"maxStreamReceiveWindow"`
|
||||
InitConnectionReceiveWindow uint64 `mapstructure:"initConnReceiveWindow"`
|
||||
MaxConnectionReceiveWindow uint64 `mapstructure:"maxConnReceiveWindow"`
|
||||
MaxIdleTimeout time.Duration `mapstructure:"maxIdleTimeout"`
|
||||
KeepAlivePeriod time.Duration `mapstructure:"keepAlivePeriod"`
|
||||
DisablePathMTUDiscovery bool `mapstructure:"disablePathMTUDiscovery"`
|
||||
Sockopts clientConfigQUICSockopts `mapstructure:"sockopts"`
|
||||
}
|
||||
|
||||
type clientConfigQUICSockopts struct {
|
||||
BindInterface *string `mapstructure:"bindInterface"`
|
||||
FirewallMark *uint32 `mapstructure:"fwmark"`
|
||||
FdControlUnixSocket *string `mapstructure:"fdControlUnixSocket"`
|
||||
}
|
||||
|
||||
type clientConfigBandwidth struct {
|
||||
@@ -196,6 +204,21 @@ func (c *clientConfig) fillServerAddr(hyConfig *client.Config) error {
|
||||
// fillConnFactory must be called after fillServerAddr, as we have different logic
|
||||
// for ConnFactory depending on whether we have a port hopping address.
|
||||
func (c *clientConfig) fillConnFactory(hyConfig *client.Config) error {
|
||||
so := &sockopts.SocketOptions{
|
||||
BindInterface: c.QUIC.Sockopts.BindInterface,
|
||||
FirewallMark: c.QUIC.Sockopts.FirewallMark,
|
||||
FdControlUnixSocket: c.QUIC.Sockopts.FdControlUnixSocket,
|
||||
}
|
||||
if err := so.CheckSupported(); err != nil {
|
||||
var unsupportedErr *sockopts.UnsupportedError
|
||||
if errors.As(err, &unsupportedErr) {
|
||||
return configError{
|
||||
Field: "quic.sockopts." + unsupportedErr.Field,
|
||||
Err: errors.New("unsupported on this platform"),
|
||||
}
|
||||
}
|
||||
return configError{Field: "quic.sockopts", Err: err}
|
||||
}
|
||||
// Inner PacketConn
|
||||
var newFunc func(addr net.Addr) (net.PacketConn, error)
|
||||
switch strings.ToLower(c.Transport.Type) {
|
||||
@@ -203,11 +226,11 @@ func (c *clientConfig) fillConnFactory(hyConfig *client.Config) error {
|
||||
if hyConfig.ServerAddr.Network() == "udphop" {
|
||||
hopAddr := hyConfig.ServerAddr.(*udphop.UDPHopAddr)
|
||||
newFunc = func(addr net.Addr) (net.PacketConn, error) {
|
||||
return udphop.NewUDPHopPacketConn(hopAddr, c.Transport.UDP.HopInterval, nil)
|
||||
return udphop.NewUDPHopPacketConn(hopAddr, c.Transport.UDP.HopInterval, so.ListenUDP)
|
||||
}
|
||||
} else {
|
||||
newFunc = func(addr net.Addr) (net.PacketConn, error) {
|
||||
return net.ListenUDP("udp", nil)
|
||||
return so.ListenUDP()
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
Reference in New Issue
Block a user