mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-05 21:07:41 +03:00
Fix canceler
This commit is contained in:
parent
a069af4787
commit
04152ea672
1 changed files with 4 additions and 2 deletions
|
@ -2,6 +2,7 @@ package canceler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
|
@ -31,7 +32,7 @@ func (c *TimeoutPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksa
|
||||||
for {
|
for {
|
||||||
err = c.PacketConn.SetReadDeadline(time.Now().Add(c.timeout))
|
err = c.PacketConn.SetReadDeadline(time.Now().Add(c.timeout))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return M.Socksaddr{}, err
|
return
|
||||||
}
|
}
|
||||||
destination, err = c.PacketConn.ReadPacket(buffer)
|
destination, err = c.PacketConn.ReadPacket(buffer)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -43,7 +44,7 @@ func (c *TimeoutPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksa
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return M.Socksaddr{}, err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,7 @@ func (c *TimeoutPacketConn) SetTimeout(timeout time.Duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TimeoutPacketConn) Close() error {
|
func (c *TimeoutPacketConn) Close() error {
|
||||||
|
c.cancel(net.ErrClosed)
|
||||||
return c.PacketConn.Close()
|
return c.PacketConn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue