Skip to content

Commit

Permalink
Allow a wider range of broadcast addresses (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaspence authored Oct 30, 2023
1 parent 745e116 commit 461d1c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions multicast-relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def addListener(self, addr, port, service):
rx.bind(('0.0.0.0', port))

self.receivers.append(rx)
self.bindings.add((broadcast, port))
listenIP = '255.255.255.255'

elif self.isMulticast(addr):
Expand Down Expand Up @@ -668,7 +669,7 @@ def loop(self):
broadcastPacket = False
if receivingInterface == 'local':
for tx in self.transmitters:
if origDstAddr == tx['relay']['addr'] and origDstPort == tx['relay']['port'] \
if (origDstAddr == tx['relay']['addr'] or origDstAddr == tx.get('broadcast')) and origDstPort == tx['relay']['port'] \
and self.onNetwork(addr, tx['addr'], tx['netmask']):
receivingInterface = tx['interface']
broadcastPacket = (origDstAddr == tx['broadcast'])
Expand Down Expand Up @@ -696,7 +697,7 @@ def loop(self):
origDstAddr = tx['broadcast']
data = data[:16] + socket.inet_aton(tx['broadcast']) + data[20:]

if origDstAddr == tx['relay']['addr'] and origDstPort == tx['relay']['port'] and (self.oneInterface or not self.onNetwork(addr, tx['addr'], tx['netmask'])):
if (origDstAddr == tx['relay']['addr'] or origDstAddr == tx.get('broadcast')) and origDstPort == tx['relay']['port'] and (self.oneInterface or not self.onNetwork(addr, tx['addr'], tx['netmask'])):
destMac = destMac if destMac else self.etherAddrs[dstAddr]

if tx['interface'] in self.masquerade:
Expand Down

0 comments on commit 461d1c9

Please sign in to comment.