Get out faster on nil udpAddr (#449)
This commit is contained in:
parent
6f37280e8e
commit
df7c7eec4a
|
@ -340,7 +340,7 @@ func (f *Interface) handleRecvError(addr *udpAddr, h *Header) {
|
|||
if !hostinfo.RecvErrorExceeded() {
|
||||
return
|
||||
}
|
||||
if hostinfo.remote != nil && hostinfo.remote.String() != addr.String() {
|
||||
if hostinfo.remote != nil && hostinfo.remote.Equals(addr) {
|
||||
f.l.Infoln("Someone spoofing recv_errors? ", addr, hostinfo.remote)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -99,6 +99,10 @@ func (r *RemoteList) ForEach(preferredRanges []*net.IPNet, forEach forEachFunc)
|
|||
// CopyAddrs locks and makes a deep copy of the deduplicated address list
|
||||
// The deduplication work may need to occur here, so you must pass preferredRanges
|
||||
func (r *RemoteList) CopyAddrs(preferredRanges []*net.IPNet) []*udpAddr {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
r.Rebuild(preferredRanges)
|
||||
|
||||
r.RLock()
|
||||
|
|
12
udp_all.go
12
udp_all.go
|
@ -33,14 +33,26 @@ func (ua *udpAddr) Equals(t *udpAddr) bool {
|
|||
}
|
||||
|
||||
func (ua *udpAddr) String() string {
|
||||
if ua == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
|
||||
return net.JoinHostPort(ua.IP.String(), fmt.Sprintf("%v", ua.Port))
|
||||
}
|
||||
|
||||
func (ua *udpAddr) MarshalJSON() ([]byte, error) {
|
||||
if ua == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return json.Marshal(m{"ip": ua.IP, "port": ua.Port})
|
||||
}
|
||||
|
||||
func (ua *udpAddr) Copy() *udpAddr {
|
||||
if ua == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
nu := udpAddr{
|
||||
Port: ua.Port,
|
||||
IP: make(net.IP, len(ua.IP)),
|
||||
|
|
Loading…
Reference in New Issue