Skip to content

Commit

Permalink
allow non-changed addr in test1 (fix #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccding committed May 19, 2016
1 parent 54567dc commit e657458
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions stun/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,17 @@ func test1(conn net.PacketConn, addr net.Addr, softwareName string) (*packet, ne
}
}

identical := isLocalAddress(conn.LocalAddr().String(), hostMappedAddr.TransportAddr())

hostChangedAddr := packet.changedAddr()
if hostChangedAddr == nil {
return nil, nil, false, nil, errors.New("No changed address.")
return packet, nil, identical, hostMappedAddr, nil
}
changeAddrStr := hostChangedAddr.TransportAddr()
changeAddr, err := net.ResolveUDPAddr("udp", changeAddrStr)
if err != nil {
return nil, nil, false, nil, errors.New("Failed to resolve changed address.")
}
identical := isLocalAddress(conn.LocalAddr().String(), hostMappedAddr.TransportAddr())
return packet, changeAddr, identical, hostMappedAddr, nil
}

Expand Down Expand Up @@ -208,6 +209,10 @@ func discover(conn net.PacketConn, addr net.Addr, softwareName string) (NATType,
return NAT_ERROR, nil, err
}

if changeAddr == nil {
return NAT_ERROR, host, errors.New("No changed address.")
}

packet, _, identical, _, err = test1(otherConn, changeAddr, softwareName)
if err != nil {
return NAT_ERROR, host, err
Expand Down

0 comments on commit e657458

Please sign in to comment.