mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Fix: add missing error check
This commit is contained in:
parent
c02b16b446
commit
b9b8632362
|
@ -30,7 +30,10 @@ func (d *Direct) DialUDP(metadata *C.Metadata) (net.PacketConn, net.Addr, error)
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
addr, _ := net.ResolveUDPAddr("udp", net.JoinHostPort(metadata.String(), metadata.Port))
|
||||
addr, err := net.ResolveUDPAddr("udp", net.JoinHostPort(metadata.String(), metadata.Port))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return pc, addr, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,15 @@ func (ss *ShadowSocks) DialUDP(metadata *C.Metadata) (net.PacketConn, net.Addr,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
addr, _ := net.ResolveUDPAddr("udp", ss.server)
|
||||
remoteAddr, _ := net.ResolveUDPAddr("udp", net.JoinHostPort(metadata.String(), metadata.Port))
|
||||
addr, err := net.ResolveUDPAddr("udp", ss.server)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
remoteAddr, err := net.ResolveUDPAddr("udp", net.JoinHostPort(metadata.String(), metadata.Port))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
pc = ss.cipher.PacketConn(pc)
|
||||
return &ssUDPConn{PacketConn: pc, rAddr: remoteAddr}, addr, nil
|
||||
|
|
|
@ -144,7 +144,12 @@ func (t *Tunnel) handleConn(localConn C.ServerAdapter) {
|
|||
}
|
||||
|
||||
if metadata.NetWork == C.UDP {
|
||||
pc, addr, _ := proxy.DialUDP(metadata)
|
||||
pc, addr, err := proxy.DialUDP(metadata)
|
||||
defer pc.Close()
|
||||
if err != nil {
|
||||
log.Warnln("Proxy[%s] connect [%s --> %s] error: %s", proxy.Name(), metadata.SourceIP.String(), metadata.String(), err.Error())
|
||||
}
|
||||
|
||||
t.handleUDPOverTCP(localConn, pc, addr)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user