Refactor: improve metadata structure

This commit is contained in:
xjasonlyu
2022-02-05 16:51:17 +08:00
parent dd0cde04b4
commit 6603c1f334
7 changed files with 61 additions and 42 deletions

View File

@@ -141,8 +141,8 @@ type socksPacketConn struct {
func (pc *socksPacketConn) WriteTo(b []byte, addr net.Addr) (n int, err error) {
var packet []byte
if m, ok := addr.(*M.Metadata); ok {
packet, err = socks5.EncodeUDPPacket(m.SerializeSocksAddr(), b)
if ma, ok := addr.(*M.Addr); ok {
packet, err = socks5.EncodeUDPPacket(ma.Metadata().SerializeSocksAddr(), b)
} else {
packet, err = socks5.EncodeUDPPacket(socks5.ParseAddrToSocksAddr(addr), b)
}