diff --git a/.vscode/launch.json b/.vscode/launch.json index 0d7258d..20d269d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "mode": "auto", "program": "${workspaceFolder}/cmd/http/main.go", "env": { - "LILPROXY_TARGET": "localhost:9001", + "LILPROXY_TARGET": "127.0.0.1:2456", "LILPROXY_PORT":":9000" } } diff --git a/main b/main index d224f4c..53216b5 100755 Binary files a/main and b/main differ diff --git a/pkg/udpproxy/session.go b/pkg/udpproxy/session.go index 72f56a1..2c50e5e 100644 --- a/pkg/udpproxy/session.go +++ b/pkg/udpproxy/session.go @@ -33,14 +33,14 @@ func createSession(caddr *net.UDPAddr, raddr *net.UDPAddr, proxyConn *net.UDPCon func (s *Session) listen() error { for { - buf := make([]byte, 1024) - _, err := s.serverConn.Read(buf) + buf := make([]byte, 2048) + n, err := s.serverConn.Read(buf) if err != nil { log.Println(err) continue } - go s.proxyFrom(buf) + s.proxyFrom(buf[:n]) } } diff --git a/pkg/udpproxy/udpproxy.go b/pkg/udpproxy/udpproxy.go index 60102c8..4365711 100644 --- a/pkg/udpproxy/udpproxy.go +++ b/pkg/udpproxy/udpproxy.go @@ -47,7 +47,7 @@ func (c *Client) ListenAndServe() error { for { buf := make([]byte, 2048) - _, caddr, err := c.proxyConn.ReadFromUDP(buf) + n, caddr, err := c.proxyConn.ReadFromUDP(buf) if err != nil { log.Println(err) } @@ -63,7 +63,7 @@ func (c *Client) ListenAndServe() error { c.sessions[caddr.String()] = session } - go session.proxyTo(buf) + session.proxyTo(buf[:n]) } }