add router handler & connector

This commit is contained in:
ginuerzh
2025-02-07 15:44:31 +08:00
parent 379d9a73ad
commit 355c72477a
25 changed files with 1265 additions and 110 deletions
+7 -8
View File
@@ -130,14 +130,13 @@ func (c *bindUDPConn) Write(b []byte) (n int, err error) {
return
}
// 2-byte data length header
var bh [2]byte
binary.BigEndian.PutUint16(bh[:], uint16(len(b)))
_, err = c.Conn.Write(bh[:])
if err != nil {
return
}
return c.Conn.Write(b)
buf := bufpool.Get(len(b) + 2)
defer bufpool.Put(buf)
binary.BigEndian.PutUint16(buf[:2], uint16(len(b)))
n = copy(buf[2:], b)
return c.Conn.Write(buf)
}
func (c *bindUDPConn) ReadFrom(b []byte) (n int, addr net.Addr, err error) {