Fix build failed on windows

Udp mux need retrieve destination address to dispatch received
packet when listen at Any address. Windows use winsock APIs to
get that, but conn.FD() is not implement for windows, so
dispatch packet to first candidate, not ideally, but it will
work for ice connectin, wasm will have same result too.
This commit is contained in:
cnderrauber
2022-09-27 15:59:29 +08:00
committed by cnderrauber
parent 0cb77c669e
commit 12148c5d62
3 changed files with 11 additions and 4 deletions
+9 -2
View File
@@ -365,12 +365,19 @@ func (m *UDPMuxDefault) connWorker() { //nolint:gocognit
var destinationConn *udpMuxedConn
m.addressMapMu.Lock()
if conns, ok := m.addressMap[addr.String()]; ok {
destinationConn = conns[ipAddr(localHost.String())]
if localHost.IsUnspecified() {
for _, c := range conns {
destinationConn = c
break
}
} else {
destinationConn = conns[ipAddr(localHost.String())]
}
}
m.addressMapMu.Unlock()
// If we haven't seen this address before but is a STUN packet lookup by ufrag
if destinationConn == nil && stun.IsMessage(buf[:n]) {
if destinationConn == nil && stun.IsMessage(buf[:n]) && !localHost.IsUnspecified() {
msg := &stun.Message{
Raw: append([]byte{}, buf[:n]...),
}
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !js
//go:build !js && !windows
package ice
@@ -1,4 +1,4 @@
//go:build js
//go:build js || windows
package ice