feat: support sudp proxy (#1730)

This commit is contained in:
Tank
2020-04-22 21:37:45 +08:00
committed by GitHub
parent 6d78af6144
commit 4797136965
15 changed files with 669 additions and 1 deletions

View File

@ -57,11 +57,11 @@ func ForwardUserConn(udpConn *net.UDPConn, readCh <-chan *msg.UdpPacket, sendCh
for {
n, remoteAddr, err := udpConn.ReadFromUDP(buf)
if err != nil {
udpConn.Close()
return
}
// buf[:n] will be encoded to string, so the bytes can be reused
udpMsg := NewUdpPacket(buf[:n], nil, remoteAddr)
select {
case sendCh <- udpMsg:
default: