Fix: add missing error check
This commit is contained in:
parent
c02b16b446
commit
b9b8632362
3 changed files with 19 additions and 4 deletions
|
@ -30,7 +30,10 @@ func (d *Direct) DialUDP(metadata *C.Metadata) (net.PacketConn, net.Addr, error)
|
||||||
return nil, nil, err
|
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
|
return pc, addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,15 @@ func (ss *ShadowSocks) DialUDP(metadata *C.Metadata) (net.PacketConn, net.Addr,
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, _ := net.ResolveUDPAddr("udp", ss.server)
|
addr, err := net.ResolveUDPAddr("udp", ss.server)
|
||||||
remoteAddr, _ := net.ResolveUDPAddr("udp", net.JoinHostPort(metadata.String(), metadata.Port))
|
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)
|
pc = ss.cipher.PacketConn(pc)
|
||||||
return &ssUDPConn{PacketConn: pc, rAddr: remoteAddr}, addr, nil
|
return &ssUDPConn{PacketConn: pc, rAddr: remoteAddr}, addr, nil
|
||||||
|
|
|
@ -144,7 +144,12 @@ func (t *Tunnel) handleConn(localConn C.ServerAdapter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata.NetWork == C.UDP {
|
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)
|
t.handleUDPOverTCP(localConn, pc, addr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue