alsmith / multicast-relay

Relay multicast and broadcast packets between interfaces.
GNU General Public License v3.0
304 stars 47 forks source link

set REMOTE_HOST to a subnet? #64

Closed eusmark closed 2 years ago

eusmark commented 2 years ago

This is a fantastic project. I have a need to have the --listen flag able to receive connections from a subnet that is dynamically setup. For example "--listen 10.111.25.0/26".

alsmith commented 2 years ago

Hi Mark - appreciate the feedback.

I'll merge the code that will do this in the next few minutes.

eusmark commented 2 years ago

Thank you so much for the quick response and fix!

I just tried it out and getting an exception. This appears to be a python3 vs python2 syntax issue. Will see if there is a quick fix, otherwise, will install python2 on this system.

eusmark@fe1-net2-relay: $ git clone https://github.com/alsmith/multicast-relay.git Cloning into 'multicast-relay'... remote: Enumerating objects: 324, done. remote: Counting objects: 100% (29/29), done. remote: Compressing objects: 100% (13/13), done. remote: Total 324 (delta 16), reused 24 (delta 16), pack-reused 295 Receiving objects: 100% (324/324), 119.07 KiB | 812.00 KiB/s, done. Resolving deltas: 100% (194/194), done. eusmark@fe1-net2-relay: $ cd multicast-relay eusmark@fe1-net2-relay: multicast-relay$ sudo python3 ./multicast-relay.py --interfaces ens160 --listen 10.111.25.0/27 --noMDNS --noSSDP --noSonosDiscovery --relay 239.255.255.250:3702 --verbose --foreground Apr-28 09:41:45 ./multicast-relay.py INFO: Adding multicast relay for 239.255.255.250:3702 Traceback (most recent call last): File "./multicast-relay.py", line 1028, in sys.exit(main()) File "./multicast-relay.py", line 1025, in main packetRelay.loop() File "./multicast-relay.py", line 507, in loop if not len(list(filter(lambda addr: PacketRelay.onNetwork(remoteAddr[0], addr[0], PacketRelay.cidrToNetmask(addr[1])), self.listenAddr))): File "./multicast-relay.py", line 507, in if not len(list(filter(lambda addr: PacketRelay.onNetwork(remoteAddr[0], addr[0], PacketRelay.cidrToNetmask(addr[1])), self.listenAddr))): File "./multicast-relay.py", line 874, in cidrToNetmask return socket.inet_ntoa(struct.pack('!I', (1 << 32) - (1 << (32 - bits)))) TypeError: unsupported operand type(s) for -: 'int' and 'str' eusmark@fe1-net2-relay:~/multicast-relay$

alsmith commented 2 years ago

Fix pushed - sorry about that.

eusmark commented 2 years ago

Just tested and works like a champ! Thank you!

eusmark commented 2 years ago

Will this continue to work on python2 as well?

alsmith commented 2 years ago

Can you give it a try... I took the plunge a while ago:

multicast-relay> python2 ./multicast-relay.py 
zsh: correct 'python2' to 'python3' [nyae]? n
zsh: command not found: python2
multicast-relay> 
alsmith commented 2 years ago

But basically if it worked on python2 yesterday, it will still work today.