Really set source IP for broadcast discovery packets on Windows/FreeBSD

This whole code was no-op: it enumerates network interfaces, enumerates
its IP addresses, but does not change the address of broadcast UDP
packet, sending it only via default route/interface.

Bind the socket to IP addresses of the interfaces to fix the issue.

BUG: 459171
This commit is contained in:
ValdikSS ValdikSS 2022-09-15 22:14:22 +03:00 committed by Simon Redman
parent 8cfa308140
commit 390a44a901

View file

@ -171,6 +171,7 @@ void LanLinkProvider::broadcastToNetwork()
QHostAddress sourceAddress = ifaceAddress.ip();
if (sourceAddress.protocol() == QAbstractSocket::IPv4Protocol && sourceAddress != QHostAddress::LocalHost) {
qCDebug(KDECONNECT_CORE()) << "Broadcasting as" << sourceAddress;
sendSocket.bind(sourceAddress);
sendBroadcasts(sendSocket, np, destinations);
sendSocket.close();
}