mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
proxy: nat fullcone support for tproxy, trojan, ss, socks5 (fix #253)
This commit is contained in:
1 parent
d68f361c35
commit
a98995e2cb
42 files changed
+366
-280
No files matched your search
@@ -5,15 +5,20 @@ import (
|
||||
)
|
||||
|
||||
// PktConn is a udp Packet.Conn.
|
||||
type PktConn struct{ net.Conn }
|
||||
type PktConn struct {
|
||||
net.Conn
|
||||
target *net.UDPAddr
|
||||
}
|
||||
|
||||
// NewPktConn returns a PktConn.
|
||||
func NewPktConn(c net.Conn) *PktConn { return &PktConn{Conn: c} }
|
||||
func NewPktConn(c net.Conn, target *net.UDPAddr) *PktConn {
|
||||
return &PktConn{Conn: c, target: target}
|
||||
}
|
||||
|
||||
// ReadFrom implements the necessary function of net.PacketConn.
|
||||
func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
n, err := pc.Read(b)
|
||||
return n, nil, err
|
||||
return n, pc.target, err
|
||||
}
|
||||
|
||||
// WriteTo implements the necessary function of net.PacketConn.
|
||||
|
||||
Reference in new issue
Block a user