working for valheim

This commit is contained in:
Dylan Parker 2023-01-08 04:59:43 -06:00
parent cfa445db14
commit 9640e6dc2d
4 changed files with 6 additions and 6 deletions

2
.vscode/launch.json vendored
View File

@ -11,7 +11,7 @@
"mode": "auto", "mode": "auto",
"program": "${workspaceFolder}/cmd/http/main.go", "program": "${workspaceFolder}/cmd/http/main.go",
"env": { "env": {
"LILPROXY_TARGET": "localhost:9001", "LILPROXY_TARGET": "127.0.0.1:2456",
"LILPROXY_PORT":":9000" "LILPROXY_PORT":":9000"
} }
} }

BIN
main

Binary file not shown.

View File

@ -33,14 +33,14 @@ func createSession(caddr *net.UDPAddr, raddr *net.UDPAddr, proxyConn *net.UDPCon
func (s *Session) listen() error { func (s *Session) listen() error {
for { for {
buf := make([]byte, 1024) buf := make([]byte, 2048)
_, err := s.serverConn.Read(buf) n, err := s.serverConn.Read(buf)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
continue continue
} }
go s.proxyFrom(buf) s.proxyFrom(buf[:n])
} }
} }

View File

@ -47,7 +47,7 @@ func (c *Client) ListenAndServe() error {
for { for {
buf := make([]byte, 2048) buf := make([]byte, 2048)
_, caddr, err := c.proxyConn.ReadFromUDP(buf) n, caddr, err := c.proxyConn.ReadFromUDP(buf)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
@ -63,7 +63,7 @@ func (c *Client) ListenAndServe() error {
c.sessions[caddr.String()] = session c.sessions[caddr.String()] = session
} }
go session.proxyTo(buf) session.proxyTo(buf[:n])
} }
} }