chore: various renames, server packet conn adjustment

This commit is contained in:
Toby 2022-10-23 11:07:54 -07:00
parent 83764ba9de
commit cf970f09e4
10 changed files with 63 additions and 61 deletions

View file

@ -13,7 +13,7 @@ import (
"github.com/HyNetwork/hysteria/pkg/transport/pktconns" "github.com/HyNetwork/hysteria/pkg/transport/pktconns"
"github.com/HyNetwork/hysteria/pkg/pmtud_fix" "github.com/HyNetwork/hysteria/pkg/pmtud"
"github.com/HyNetwork/hysteria/pkg/redirect" "github.com/HyNetwork/hysteria/pkg/redirect"
"github.com/oschwald/geoip2-golang" "github.com/oschwald/geoip2-golang"
"github.com/yosuke-furukawa/json5/encoding/json5" "github.com/yosuke-furukawa/json5/encoding/json5"
@ -101,7 +101,7 @@ func client(config *clientConfig) {
quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow quicConfig.InitialConnectionReceiveWindow = DefaultConnectionReceiveWindow
quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow quicConfig.MaxConnectionReceiveWindow = DefaultConnectionReceiveWindow
} }
if !quicConfig.DisablePathMTUDiscovery && pmtud_fix.DisablePathMTUDiscovery { if !quicConfig.DisablePathMTUDiscovery && pmtud.DisablePathMTUDiscovery {
logrus.Info("Path MTU Discovery is not yet supported on this platform") logrus.Info("Path MTU Discovery is not yet supported on this platform")
} }
// Auth // Auth

View file

@ -13,7 +13,7 @@ import (
"github.com/HyNetwork/hysteria/cmd/auth" "github.com/HyNetwork/hysteria/cmd/auth"
"github.com/HyNetwork/hysteria/pkg/acl" "github.com/HyNetwork/hysteria/pkg/acl"
"github.com/HyNetwork/hysteria/pkg/core" "github.com/HyNetwork/hysteria/pkg/core"
"github.com/HyNetwork/hysteria/pkg/pmtud_fix" "github.com/HyNetwork/hysteria/pkg/pmtud"
"github.com/HyNetwork/hysteria/pkg/sockopt" "github.com/HyNetwork/hysteria/pkg/sockopt"
"github.com/HyNetwork/hysteria/pkg/transport" "github.com/HyNetwork/hysteria/pkg/transport"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
@ -100,7 +100,7 @@ func server(config *serverConfig) {
if quicConfig.MaxIncomingStreams == 0 { if quicConfig.MaxIncomingStreams == 0 {
quicConfig.MaxIncomingStreams = DefaultMaxIncomingStreams quicConfig.MaxIncomingStreams = DefaultMaxIncomingStreams
} }
if !quicConfig.DisablePathMTUDiscovery && pmtud_fix.DisablePathMTUDiscovery { if !quicConfig.DisablePathMTUDiscovery && pmtud.DisablePathMTUDiscovery {
logrus.Info("Path MTU Discovery is not yet supported on this platform") logrus.Info("Path MTU Discovery is not yet supported on this platform")
} }
// Auth // Auth
@ -150,12 +150,6 @@ func server(config *serverConfig) {
} }
return ok, msg return ok, msg
} }
// Packet conn
pktConnFuncFactory := serverPacketConnFuncFactoryMap[config.Protocol]
if pktConnFuncFactory == nil {
logrus.WithField("protocol", config.Protocol).Fatal("Unsupported protocol")
}
pktConnFunc := pktConnFuncFactory(config.Obfs)
// Resolve preference // Resolve preference
if len(config.ResolvePreference) > 0 { if len(config.ResolvePreference) > 0 {
pref, err := transport.ResolvePreferenceFromString(config.ResolvePreference) pref, err := transport.ResolvePreferenceFromString(config.ResolvePreference)
@ -220,7 +214,7 @@ func server(config *serverConfig) {
} }
aclEngine.DefaultAction = acl.ActionDirect aclEngine.DefaultAction = acl.ActionDirect
} }
// Server // Prometheus
var promReg *prometheus.Registry var promReg *prometheus.Registry
if len(config.PrometheusListen) > 0 { if len(config.PrometheusListen) > 0 {
promReg = prometheus.NewRegistry() promReg = prometheus.NewRegistry()
@ -230,8 +224,22 @@ func server(config *serverConfig) {
logrus.WithField("error", err).Fatal("Prometheus HTTP server error") logrus.WithField("error", err).Fatal("Prometheus HTTP server error")
}() }()
} }
// Packet conn
pktConnFuncFactory := serverPacketConnFuncFactoryMap[config.Protocol]
if pktConnFuncFactory == nil {
logrus.WithField("protocol", config.Protocol).Fatal("Unsupported protocol")
}
pktConnFunc := pktConnFuncFactory(config.Obfs)
pktConn, err := pktConnFunc(config.Listen)
if err != nil {
logrus.WithFields(logrus.Fields{
"error": err,
"addr": config.Listen,
}).Fatal("Failed to listen on the UDP address")
}
// Server
up, down, _ := config.Speed() up, down, _ := config.Speed()
server, err := core.NewServer(config.Listen, tlsConfig, quicConfig, pktConnFunc, server, err := core.NewServer(tlsConfig, quicConfig, pktConn,
transport.DefaultServerTransport, up, down, config.DisableUDP, aclEngine, transport.DefaultServerTransport, up, down, config.DisableUDP, aclEngine,
connectFunc, disconnectFunc, tcpRequestFunc, tcpErrorFunc, udpRequestFunc, udpErrorFunc, promReg) connectFunc, disconnectFunc, tcpRequestFunc, tcpErrorFunc, udpRequestFunc, udpErrorFunc, promReg)
if err != nil { if err != nil {

View file

@ -16,7 +16,7 @@ import (
"github.com/HyNetwork/hysteria/pkg/congestion" "github.com/HyNetwork/hysteria/pkg/congestion"
"github.com/HyNetwork/hysteria/pkg/pmtud_fix" "github.com/HyNetwork/hysteria/pkg/pmtud"
"github.com/HyNetwork/hysteria/pkg/utils" "github.com/HyNetwork/hysteria/pkg/utils"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/lunixbochs/struc" "github.com/lunixbochs/struc"
@ -49,7 +49,7 @@ type Client struct {
func NewClient(serverAddr string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config, func NewClient(serverAddr string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config,
pktConnFunc pktconns.ClientPacketConnFunc, sendBPS uint64, recvBPS uint64, quicReconnectFunc func(err error), pktConnFunc pktconns.ClientPacketConnFunc, sendBPS uint64, recvBPS uint64, quicReconnectFunc func(err error),
) (*Client, error) { ) (*Client, error) {
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud.DisablePathMTUDiscovery
c := &Client{ c := &Client{
serverAddr: serverAddr, serverAddr: serverAddr,
sendBPS: sendBPS, sendBPS: sendBPS,

View file

@ -7,12 +7,10 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/HyNetwork/hysteria/pkg/transport/pktconns"
"github.com/HyNetwork/hysteria/pkg/congestion" "github.com/HyNetwork/hysteria/pkg/congestion"
"github.com/HyNetwork/hysteria/pkg/acl" "github.com/HyNetwork/hysteria/pkg/acl"
"github.com/HyNetwork/hysteria/pkg/pmtud_fix" "github.com/HyNetwork/hysteria/pkg/pmtud"
"github.com/HyNetwork/hysteria/pkg/transport" "github.com/HyNetwork/hysteria/pkg/transport"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/lunixbochs/struc" "github.com/lunixbochs/struc"
@ -48,18 +46,14 @@ type Server struct {
listener quic.Listener listener quic.Listener
} }
func NewServer(addr string, tlsConfig *tls.Config, quicConfig *quic.Config, func NewServer(tlsConfig *tls.Config, quicConfig *quic.Config,
pktConnFunc pktconns.ServerPacketConnFunc, transport *transport.ServerTransport, pktConn net.PacketConn, transport *transport.ServerTransport,
sendBPS uint64, recvBPS uint64, disableUDP bool, aclEngine *acl.Engine, sendBPS uint64, recvBPS uint64, disableUDP bool, aclEngine *acl.Engine,
connectFunc ConnectFunc, disconnectFunc DisconnectFunc, connectFunc ConnectFunc, disconnectFunc DisconnectFunc,
tcpRequestFunc TCPRequestFunc, tcpErrorFunc TCPErrorFunc, tcpRequestFunc TCPRequestFunc, tcpErrorFunc TCPErrorFunc,
udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry, udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry,
) (*Server, error) { ) (*Server, error) {
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud.DisablePathMTUDiscovery
pktConn, err := pktConnFunc(addr)
if err != nil {
return nil, err
}
listener, err := quic.Listen(pktConn, tlsConfig, quicConfig) listener, err := quic.Listen(pktConn, tlsConfig, quicConfig)
if err != nil { if err != nil {
_ = pktConn.Close() _ = pktConn.Close()

View file

@ -35,7 +35,7 @@ type serverClient struct {
ConnGauge prometheus.Gauge ConnGauge prometheus.Gauge
udpSessionMutex sync.RWMutex udpSessionMutex sync.RWMutex
udpSessionMap map[uint32]transport.PUDPConn udpSessionMap map[uint32]transport.STPacketConn
nextUDPSessionID uint32 nextUDPSessionID uint32
udpDefragger defragger udpDefragger defragger
} }
@ -57,7 +57,7 @@ func newServerClient(cc quic.Connection, tr *transport.ServerTransport, auth []b
CTCPErrorFunc: CTCPErrorFunc, CTCPErrorFunc: CTCPErrorFunc,
CUDPRequestFunc: CUDPRequestFunc, CUDPRequestFunc: CUDPRequestFunc,
CUDPErrorFunc: CUDPErrorFunc, CUDPErrorFunc: CUDPErrorFunc,
udpSessionMap: make(map[uint32]transport.PUDPConn), udpSessionMap: make(map[uint32]transport.STPacketConn),
} }
if UpCounterVec != nil && DownCounterVec != nil && ConnGaugeVec != nil { if UpCounterVec != nil && DownCounterVec != nil && ConnGaugeVec != nil {
authB64 := base64.StdEncoding.EncodeToString(auth) authB64 := base64.StdEncoding.EncodeToString(auth)
@ -145,7 +145,7 @@ func (c *serverClient) handleMessage(msg []byte) {
} else { } else {
ipAddr, isDomain, err = c.Transport.ResolveIPAddr(dfMsg.Host) ipAddr, isDomain, err = c.Transport.ResolveIPAddr(dfMsg.Host)
} }
if err != nil && !(isDomain && c.Transport.SOCKS5Enabled()) { // Special case for domain requests + SOCKS5 outbound if err != nil && !(isDomain && c.Transport.ProxyEnabled()) { // Special case for domain requests + SOCKS5 outbound
return return
} }
switch action { switch action {
@ -157,7 +157,7 @@ func (c *serverClient) handleMessage(msg []byte) {
if isDomain { if isDomain {
addrEx.Domain = dfMsg.Host addrEx.Domain = dfMsg.Host
} }
_, _ = conn.WriteToUDP(dfMsg.Data, addrEx) _, _ = conn.WriteTo(dfMsg.Data, addrEx)
if c.UpCounter != nil { if c.UpCounter != nil {
c.UpCounter.Add(float64(len(dfMsg.Data))) c.UpCounter.Add(float64(len(dfMsg.Data)))
} }
@ -165,7 +165,7 @@ func (c *serverClient) handleMessage(msg []byte) {
// Do nothing // Do nothing
case acl.ActionHijack: case acl.ActionHijack:
hijackIPAddr, isDomain, err := c.Transport.ResolveIPAddr(arg) hijackIPAddr, isDomain, err := c.Transport.ResolveIPAddr(arg)
if err == nil || (isDomain && c.Transport.SOCKS5Enabled()) { // Special case for domain requests + SOCKS5 outbound if err == nil || (isDomain && c.Transport.ProxyEnabled()) { // Special case for domain requests + SOCKS5 outbound
addrEx := &transport.AddrEx{ addrEx := &transport.AddrEx{
IPAddr: hijackIPAddr, IPAddr: hijackIPAddr,
Port: int(dfMsg.Port), Port: int(dfMsg.Port),
@ -173,7 +173,7 @@ func (c *serverClient) handleMessage(msg []byte) {
if isDomain { if isDomain {
addrEx.Domain = arg addrEx.Domain = arg
} }
_, _ = conn.WriteToUDP(dfMsg.Data, addrEx) _, _ = conn.WriteTo(dfMsg.Data, addrEx)
if c.UpCounter != nil { if c.UpCounter != nil {
c.UpCounter.Add(float64(len(dfMsg.Data))) c.UpCounter.Add(float64(len(dfMsg.Data)))
} }
@ -195,7 +195,7 @@ func (c *serverClient) handleTCP(stream quic.Stream, host string, port uint16) {
} else { } else {
ipAddr, isDomain, err = c.Transport.ResolveIPAddr(host) ipAddr, isDomain, err = c.Transport.ResolveIPAddr(host)
} }
if err != nil && !(isDomain && c.Transport.SOCKS5Enabled()) { // Special case for domain requests + SOCKS5 outbound if err != nil && !(isDomain && c.Transport.ProxyEnabled()) { // Special case for domain requests + SOCKS5 outbound
_ = struc.Pack(stream, &serverResponse{ _ = struc.Pack(stream, &serverResponse{
OK: false, OK: false,
Message: "host resolution failure", Message: "host resolution failure",
@ -232,7 +232,7 @@ func (c *serverClient) handleTCP(stream quic.Stream, host string, port uint16) {
return return
case acl.ActionHijack: case acl.ActionHijack:
hijackIPAddr, isDomain, err := c.Transport.ResolveIPAddr(arg) hijackIPAddr, isDomain, err := c.Transport.ResolveIPAddr(arg)
if err != nil && !(isDomain && c.Transport.SOCKS5Enabled()) { // Special case for domain requests + SOCKS5 outbound if err != nil && !(isDomain && c.Transport.ProxyEnabled()) { // Special case for domain requests + SOCKS5 outbound
_ = struc.Pack(stream, &serverResponse{ _ = struc.Pack(stream, &serverResponse{
OK: false, OK: false,
Message: err.Error(), Message: err.Error(),
@ -318,7 +318,7 @@ func (c *serverClient) handleUDP(stream quic.Stream) {
go func() { go func() {
buf := make([]byte, udpBufferSize) buf := make([]byte, udpBufferSize)
for { for {
n, rAddr, err := conn.ReadFromUDP(buf) n, rAddr, err := conn.ReadFrom(buf)
if n > 0 { if n > 0 {
var msgBuf bytes.Buffer var msgBuf bytes.Buffer
msg := udpMessage{ msg := udpMessage{

View file

@ -1,7 +1,7 @@
//go:build linux || windows //go:build linux || windows
// +build linux windows // +build linux windows
package pmtud_fix package pmtud
const ( const (
DisablePathMTUDiscovery = false DisablePathMTUDiscovery = false

View file

@ -1,7 +1,7 @@
//go:build !linux && !windows //go:build !linux && !windows
// +build !linux,!windows // +build !linux,!windows
package pmtud_fix package pmtud
const ( const (
DisablePathMTUDiscovery = true DisablePathMTUDiscovery = true

View file

@ -26,12 +26,12 @@ func NewClientUDPConnFunc(obfsPassword string) ClientPacketConnFunc {
} }
} else { } else {
return func(server string) (net.PacketConn, error) { return func(server string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
udpConn, err := net.ListenUDP("udp", nil) udpConn, err := net.ListenUDP("udp", nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return udp.NewObfsUDPConn(udpConn, obfs), nil return udp.NewObfsUDPConn(udpConn, ob), nil
} }
} }
} }
@ -47,12 +47,12 @@ func NewClientWeChatConnFunc(obfsPassword string) ClientPacketConnFunc {
} }
} else { } else {
return func(server string) (net.PacketConn, error) { return func(server string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
udpConn, err := net.ListenUDP("udp", nil) udpConn, err := net.ListenUDP("udp", nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return wechat.NewObfsWeChatUDPConn(udpConn, obfs), nil return wechat.NewObfsWeChatUDPConn(udpConn, ob), nil
} }
} }
} }
@ -64,12 +64,12 @@ func NewClientFakeTCPConnFunc(obfsPassword string) ClientPacketConnFunc {
} }
} else { } else {
return func(server string) (net.PacketConn, error) { return func(server string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
fakeTCPConn, err := faketcp.Dial("tcp", server) fakeTCPConn, err := faketcp.Dial("tcp", server)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return faketcp.NewObfsFakeTCPConn(fakeTCPConn, obfs), nil return faketcp.NewObfsFakeTCPConn(fakeTCPConn, ob), nil
} }
} }
} }
@ -85,7 +85,7 @@ func NewServerUDPConnFunc(obfsPassword string) ServerPacketConnFunc {
} }
} else { } else {
return func(listen string) (net.PacketConn, error) { return func(listen string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
laddrU, err := net.ResolveUDPAddr("udp", listen) laddrU, err := net.ResolveUDPAddr("udp", listen)
if err != nil { if err != nil {
return nil, err return nil, err
@ -94,7 +94,7 @@ func NewServerUDPConnFunc(obfsPassword string) ServerPacketConnFunc {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return udp.NewObfsUDPConn(udpConn, obfs), nil return udp.NewObfsUDPConn(udpConn, ob), nil
} }
} }
} }
@ -114,7 +114,7 @@ func NewServerWeChatConnFunc(obfsPassword string) ServerPacketConnFunc {
} }
} else { } else {
return func(listen string) (net.PacketConn, error) { return func(listen string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
laddrU, err := net.ResolveUDPAddr("udp", listen) laddrU, err := net.ResolveUDPAddr("udp", listen)
if err != nil { if err != nil {
return nil, err return nil, err
@ -123,7 +123,7 @@ func NewServerWeChatConnFunc(obfsPassword string) ServerPacketConnFunc {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return wechat.NewObfsWeChatUDPConn(udpConn, obfs), nil return wechat.NewObfsWeChatUDPConn(udpConn, ob), nil
} }
} }
} }
@ -135,12 +135,12 @@ func NewServerFakeTCPConnFunc(obfsPassword string) ServerPacketConnFunc {
} }
} else { } else {
return func(listen string) (net.PacketConn, error) { return func(listen string) (net.PacketConn, error) {
obfs := obfs.NewXPlusObfuscator([]byte(obfsPassword)) ob := obfs.NewXPlusObfuscator([]byte(obfsPassword))
fakeTCPListener, err := faketcp.Listen("tcp", listen) fakeTCPListener, err := faketcp.Listen("tcp", listen)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return faketcp.NewObfsFakeTCPConn(fakeTCPListener, obfs), nil return faketcp.NewObfsFakeTCPConn(fakeTCPListener, ob), nil
} }
} }
} }

View file

@ -36,21 +36,21 @@ func (a *AddrEx) String() string {
return net.JoinHostPort(ip, strconv.Itoa(a.Port)) return net.JoinHostPort(ip, strconv.Itoa(a.Port))
} }
type PUDPConn interface { type STPacketConn interface {
ReadFromUDP([]byte) (int, *net.UDPAddr, error) ReadFrom([]byte) (int, *net.UDPAddr, error)
WriteToUDP([]byte, *AddrEx) (int, error) WriteTo([]byte, *AddrEx) (int, error)
Close() error Close() error
} }
type udpConnPUDPConn struct { type udpSTPacketConn struct {
Conn *net.UDPConn Conn *net.UDPConn
} }
func (c *udpConnPUDPConn) ReadFromUDP(bytes []byte) (int, *net.UDPAddr, error) { func (c *udpSTPacketConn) ReadFrom(bytes []byte) (int, *net.UDPAddr, error) {
return c.Conn.ReadFromUDP(bytes) return c.Conn.ReadFromUDP(bytes)
} }
func (c *udpConnPUDPConn) WriteToUDP(bytes []byte, ex *AddrEx) (int, error) { func (c *udpSTPacketConn) WriteTo(bytes []byte, ex *AddrEx) (int, error) {
return c.Conn.WriteToUDP(bytes, &net.UDPAddr{ return c.Conn.WriteToUDP(bytes, &net.UDPAddr{
IP: ex.IPAddr.IP, IP: ex.IPAddr.IP,
Port: ex.Port, Port: ex.Port,
@ -58,7 +58,7 @@ func (c *udpConnPUDPConn) WriteToUDP(bytes []byte, ex *AddrEx) (int, error) {
}) })
} }
func (c *udpConnPUDPConn) Close() error { func (c *udpSTPacketConn) Close() error {
return c.Conn.Close() return c.Conn.Close()
} }
@ -90,7 +90,7 @@ func (st *ServerTransport) DialTCP(raddr *AddrEx) (*net.TCPConn, error) {
} }
} }
func (st *ServerTransport) ListenUDP() (PUDPConn, error) { func (st *ServerTransport) ListenUDP() (STPacketConn, error) {
if st.SOCKS5Client != nil { if st.SOCKS5Client != nil {
return st.SOCKS5Client.ListenUDP() return st.SOCKS5Client.ListenUDP()
} else { } else {
@ -101,16 +101,16 @@ func (st *ServerTransport) ListenUDP() (PUDPConn, error) {
if st.LocalUDPIntf != nil { if st.LocalUDPIntf != nil {
err = sockopt.BindUDPConn("udp", conn, st.LocalUDPIntf) err = sockopt.BindUDPConn("udp", conn, st.LocalUDPIntf)
if err != nil { if err != nil {
conn.Close() _ = conn.Close()
return nil, err return nil, err
} }
} }
return &udpConnPUDPConn{ return &udpSTPacketConn{
Conn: conn, Conn: conn,
}, nil }, nil
} }
} }
func (st *ServerTransport) SOCKS5Enabled() bool { func (st *ServerTransport) ProxyEnabled() bool {
return st.SOCKS5Client != nil return st.SOCKS5Client != nil
} }

View file

@ -111,7 +111,7 @@ func (c *SOCKS5Client) DialTCP(raddr *AddrEx) (*net.TCPConn, error) {
return conn, nil return conn, nil
} }
func (c *SOCKS5Client) ListenUDP() (*socks5UDPConn, error) { func (c *SOCKS5Client) ListenUDP() (STPacketConn, error) {
conn, err := net.DialTCP("tcp", nil, c.ServerTCPAddr) conn, err := net.DialTCP("tcp", nil, c.ServerTCPAddr)
if err != nil { if err != nil {
return nil, err return nil, err
@ -175,7 +175,7 @@ func (c *socks5UDPConn) hold() {
_ = c.udpConn.Close() _ = c.udpConn.Close()
} }
func (c *socks5UDPConn) ReadFromUDP(b []byte) (int, *net.UDPAddr, error) { func (c *socks5UDPConn) ReadFrom(b []byte) (int, *net.UDPAddr, error) {
n, err := c.udpConn.Read(b) n, err := c.udpConn.Read(b)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
@ -192,7 +192,7 @@ func (c *socks5UDPConn) ReadFromUDP(b []byte) (int, *net.UDPAddr, error) {
return n, addr, nil return n, addr, nil
} }
func (c *socks5UDPConn) WriteToUDP(b []byte, addr *AddrEx) (int, error) { func (c *socks5UDPConn) WriteTo(b []byte, addr *AddrEx) (int, error) {
atyp, dstAddr, dstPort, err := addrExToSOCKS5Addr(addr) atyp, dstAddr, dstPort, err := addrExToSOCKS5Addr(addr)
if err != nil { if err != nil {
return 0, err return 0, err