瀏覽代碼

Fix ipv6 redir port

世界 2 年之前
父節點
當前提交
86ea035bdd
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      common/redir/redir_linux.go

+ 4 - 1
common/redir/redir_linux.go

@@ -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
 	})