Remove pointless udpMinTimeout

This commit is contained in:
Toby 2021-04-24 18:13:30 -07:00
parent 3b7aefb10d
commit 2b4e660324

View File

@ -11,8 +11,6 @@ import (
const udpBufferSize = 65535 const udpBufferSize = 65535
const udpMinTimeout = 4 * time.Second
var ErrTimeout = errors.New("inactivity timeout") var ErrTimeout = errors.New("inactivity timeout")
type UDPRelay struct { type UDPRelay struct {
@ -41,8 +39,6 @@ func NewUDPRelay(hyClient *core.Client, listen, remote string, timeout time.Dura
} }
if timeout == 0 { if timeout == 0 {
r.Timeout = 1 * time.Minute r.Timeout = 1 * time.Minute
} else if timeout < udpMinTimeout {
r.Timeout = udpMinTimeout
} }
return r, nil return r, nil
} }
@ -101,7 +97,7 @@ func (r *UDPRelay) ListenAndServe() error {
go func() { go func() {
for { for {
ttl := ent.Deadline.Load().(time.Time).Sub(time.Now()) ttl := ent.Deadline.Load().(time.Time).Sub(time.Now())
if ttl < 0 { if ttl <= 0 {
// Time to die // Time to die
connMapMutex.Lock() connMapMutex.Lock()
_ = hyConn.Close() _ = hyConn.Close()