Fix ipv6 redir port

This commit is contained in:
世界 2023-02-05 14:38:34 +08:00
parent 9b6449dcf4
commit 86ea035bdd
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package redir
import (
"encoding/binary"
"net"
"net/netip"
"os"
@ -29,7 +30,9 @@ func GetOriginalDestination(conn net.Conn) (destination netip.AddrPort, err erro
if err != nil {
return err
}
destination = netip.AddrPortFrom(M.AddrFromIP(raw.Addr.Addr[:]), raw.Addr.Port)
var port [2]byte
binary.BigEndian.PutUint16(port[:], raw.Addr.Port)
destination = netip.AddrPortFrom(M.AddrFromIP(raw.Addr.Addr[:]), binary.LittleEndian.Uint16(port[:]))
}
return nil
})