feat(vmess): support forward/udp (#199)

This commit is contained in:
mzz authored and GitHub committed 2020-12-03 15:27:52 +08:00
1 parent 2db84bb7aa
commit 1b484cca8f
3 files changed
+41 -9

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
package vmess
import (
"net"
)
// PktConn is a udp Packet.Conn.
type PktConn struct{ net.Conn }
// NewPktConn returns a PktConn.
func NewPktConn(c net.Conn) *PktConn { return &PktConn{Conn: c} }
// 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
}
// WriteTo implements the necessary function of net.PacketConn.
func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error) {
return pc.Write(b)
}