mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: Deadline not apply on EnhancePacketConn
This commit is contained in:
parent
234f7dbd3b
commit
76caab19bf
|
@ -259,10 +259,11 @@ func (c *packetConn) ReaderReplaceable() bool {
|
|||
}
|
||||
|
||||
func newPacketConn(pc net.PacketConn, a C.ProxyAdapter) C.PacketConn {
|
||||
epc := N.NewEnhancePacketConn(pc)
|
||||
if _, ok := pc.(syscall.Conn); !ok { // exclusion system conn like *net.UDPConn
|
||||
pc = N.NewDeadlinePacketConn(pc) // most conn from outbound can't handle readDeadline correctly
|
||||
epc = N.NewDeadlineEnhancePacketConn(epc) // most conn from outbound can't handle readDeadline correctly
|
||||
}
|
||||
return &packetConn{N.NewEnhancePacketConn(pc), []string{a.Name()}, a.Name(), utils.NewUUIDV4().String(), parseRemoteDestination(a.Addr())}
|
||||
return &packetConn{epc, []string{a.Name()}, a.Name(), utils.NewUUIDV4().String(), parseRemoteDestination(a.Addr())}
|
||||
}
|
||||
|
||||
func parseRemoteDestination(addr string) string {
|
||||
|
|
|
@ -128,6 +128,10 @@ type EnhancePacketConn struct {
|
|||
enhancePacketConn packet.EnhancePacketConn
|
||||
}
|
||||
|
||||
func NewEnhancePacketConn(pc packet.EnhancePacketConn) packet.EnhancePacketConn {
|
||||
return NewPacketConn(pc).(packet.EnhancePacketConn)
|
||||
}
|
||||
|
||||
func (c *EnhancePacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error) {
|
||||
select {
|
||||
case result := <-c.resultCh:
|
||||
|
|
|
@ -12,6 +12,7 @@ type EnhancePacketConn = packet.EnhancePacketConn
|
|||
|
||||
var NewEnhancePacketConn = packet.NewEnhancePacketConn
|
||||
var NewDeadlinePacketConn = deadline.NewPacketConn
|
||||
var NewDeadlineEnhancePacketConn = deadline.NewEnhancePacketConn
|
||||
|
||||
type threadSafePacketConn struct {
|
||||
net.PacketConn
|
||||
|
|
Loading…
Reference in New Issue
Block a user