mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-02 03:17:37 +03:00
udpnat2: Add timeout check
This commit is contained in:
parent
30e9d91b57
commit
a8f5bf4eb0
1 changed files with 4 additions and 2 deletions
|
@ -35,6 +35,9 @@ type Metrics struct {
|
|||
}
|
||||
|
||||
func New(handler N.UDPConnectionHandlerEx, prepare PrepareFunc, timeout time.Duration, shared bool) *Service {
|
||||
if timeout == 0 {
|
||||
panic("invalid timeout")
|
||||
}
|
||||
var cache freelru.Cache[netip.AddrPort, *natConn]
|
||||
if !shared {
|
||||
cache = common.Must1(freelru.New[netip.AddrPort, *natConn](1024, maphash.NewHasher[netip.AddrPort]().Hash32))
|
||||
|
@ -80,11 +83,10 @@ func (s *Service) Start() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) Close() error {
|
||||
func (s *Service) Close() {
|
||||
s.closeOnce.Do(func() {
|
||||
close(s.doneChan)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) NewPacket(bufferSlices [][]byte, source M.Socksaddr, destination M.Socksaddr, userData any) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue