Fix: add missing error check

This commit is contained in:
gVisor bot 2019-04-24 10:29:29 +08:00
parent c02b16b446
commit b9b8632362
3 changed files with 19 additions and 4 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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
}