Fix the problem of OMM Killer triggered by too many UDP connections

This commit is contained in:
jevin.shi 2023-06-28 09:50:41 +08:00
parent 1b3709657f
commit 6fe2b45e99

View file

@ -4,6 +4,7 @@ import (
"encoding/binary" "encoding/binary"
"io" "io"
"net" "net"
"time"
"github.com/sagernet/sing/common" "github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/buf" "github.com/sagernet/sing/common/buf"
@ -89,6 +90,7 @@ func (c *ServerConn) loopInput() {
if err != nil { if err != nil {
break break
} }
c.SetDeadline(time.Now().Add(2 * time.Minute))
} }
c.Close() c.Close()
} }
@ -105,6 +107,7 @@ func (c *ServerConn) loopOutput() {
if err != nil { if err != nil {
break break
} }
c.SetDeadline(time.Now().Add(2 * time.Minute))
if !c.isConnect { if !c.isConnect {
err = AddrParser.WriteAddrPort(c.outputWriter, M.SocksaddrFromNet(addr)) err = AddrParser.WriteAddrPort(c.outputWriter, M.SocksaddrFromNet(addr))
if err != nil { if err != nil {