mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-20 16:24:30 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
739a2dcd84 |
@@ -2,10 +2,10 @@ package socks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/signal"
|
"github.com/xtls/xray-core/common/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,6 +14,9 @@ func NewTempUDPConn(udpConn net.PacketConn, tcpConn net.Conn, expectedRemote *ne
|
|||||||
PacketConn: udpConn,
|
PacketConn: udpConn,
|
||||||
AssociatedTCPConn: tcpConn,
|
AssociatedTCPConn: tcpConn,
|
||||||
}
|
}
|
||||||
|
t.Timer = signal.CancelAfterInactivity(context.Background(), func() {
|
||||||
|
t.Close()
|
||||||
|
}, net.ConnIdleTimeout)
|
||||||
t.ExpectedRemote.Store(expectedRemote)
|
t.ExpectedRemote.Store(expectedRemote)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
@@ -60,9 +63,7 @@ func (c *TempUDPConn) RemoteAddr() net.Addr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *TempUDPConn) SetTimeout(d time.Duration) {
|
func (c *TempUDPConn) SetTimeout(d time.Duration) {
|
||||||
c.Timer = signal.CancelAfterInactivity(context.Background(), func() {
|
c.Timer.SetTimeout(d)
|
||||||
c.Close()
|
|
||||||
}, d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TempUDPConn) Close() error {
|
func (c *TempUDPConn) Close() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user