Skip to content

Commit

Permalink
services/comm: Don't ignore point-to-point interfaces, instead use pe…
Browse files Browse the repository at this point in the history
…er IP to broadcast.

This should make icecream work across WireGuard connections.
  • Loading branch information
torokati44 committed Jun 20, 2020
1 parent a7d8c81 commit f73dfe0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions services/comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,27 +1472,30 @@ static int open_send_broadcast(int port, const char* buf, int size)
trace() << "ignoring localhost " << addr->ifa_name << " for broadcast" << endl;
continue;
}

if ((addr->ifa_flags & IFF_POINTOPOINT) || !(addr->ifa_flags & IFF_BROADCAST)) {
log_info() << "ignoring tunnels " << addr->ifa_name << " for broadcast" << endl;
continue;
}
} else {
if (ntohl(((struct sockaddr_in *) addr->ifa_addr)->sin_addr.s_addr) != 0x7f000001) {
trace() << "ignoring non-localhost " << addr->ifa_name << " for broadcast" << endl;
continue;
}
}

if (addr->ifa_broadaddr) {
sockaddr_in *broad_or_dst_addr = nullptr;

if (addr->ifa_flags & IFF_BROADCAST)
broad_or_dst_addr = (sockaddr_in *)addr->ifa_broadaddr;

if (addr->ifa_flags & IFF_POINTOPOINT)
broad_or_dst_addr = (sockaddr_in *)addr->ifa_dstaddr;

if (broad_or_dst_addr) {
log_info() << "broadcast "
<< addr->ifa_name << " "
<< inet_ntoa(((sockaddr_in *)addr->ifa_broadaddr)->sin_addr)
<< inet_ntoa(broad_or_dst_addr->sin_addr)
<< endl;

remote_addr.sin_family = AF_INET;
remote_addr.sin_port = htons(port);
remote_addr.sin_addr = ((sockaddr_in *)addr->ifa_broadaddr)->sin_addr;
remote_addr.sin_addr = broad_or_dst_addr->sin_addr;

if (sendto(ask_fd, buf, size, 0, (struct sockaddr *)&remote_addr,
sizeof(remote_addr)) != size) {
Expand Down

0 comments on commit f73dfe0

Please sign in to comment.