alsmith / multicast-relay

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

Use with wireguard interface? TypeError: ord() expected string of length 1 #30

Closed aefo closed 4 years ago

aefo commented 4 years ago

I'm trying to bridge / reflect / repeat SSDP traffic from a Wireguard connection to my home network. To check, is this something that should be possible?

I've tried running it and get the output error below. (I needed to add the allowNonEther option as otherwise it reported that it couldn't find out the MAC address for wg0).

(For reference I'm running it in Docker following https://github.com/scyto/multicast-relay)

Thanks,

starting multicast-relay

Using Interfaces: eth0 wg0
Using Options --foreground  --verbose --allowNonEther
Jun-05 09:20:25 /etc/app/multicast-relay/multicast-relay.py INFO: Adding broadcast relay for 255.255.255.255:6969 (Sonos Discovery)
Jun-05 09:20:25 /etc/app/multicast-relay/multicast-relay.py INFO: Adding multicast relay for 239.255.255.250:1900 (SSDP)
Jun-05 09:20:25 /etc/app/multicast-relay/multicast-relay.py INFO: Adding multicast relay for 224.0.0.251:5353 (mDNS)
Jun-05 09:21:13 /etc/app/multicast-relay/multicast-relay.py INFO: [SSDP] Relayed 356 bytes from 192.168.1.254:1900 on eth0 [ttl 4] to 239.255.255.250:1900 via wg0/10.6.0.1
Traceback (most recent call last):
  File "/etc/app/multicast-relay/multicast-relay.py", line 869, in <module>
    sys.exit(main())
  File "/etc/app/multicast-relay/multicast-relay.py", line 866, in main
    packetRelay.loop()
  File "/etc/app/multicast-relay/multicast-relay.py", line 595, in loop
    self.transmitPacket(tx['socket'], tx['mac'], destMac, ipHeaderLength, data)
  File "/etc/app/multicast-relay/multicast-relay.py", line 370, in transmitPacket
    dontFragment = (ord(ipPacket[6]) & 0x40) >> 6
TypeError: ord() expected string of length 1, but int found
alsmith commented 4 years ago

May I ask which version of python you are using?

alsmith commented 4 years ago

This was a python2 vs python3 issue - fixed in https://github.com/alsmith/multicast-relay/commit/127704fb4a6fb16bafe698289994790f34e828e1

aefo commented 4 years ago

Thanks for the quickly reply & change. As you guessed, I'm using python3

bash-4.4# python3 --version
Python 3.6.9

Updating to your latest seems to get it going further and reporting transferring messages,

Thanks,

bash-4.4# ./start.sh 
starting multicast-relay
Using Interfaces: eth0 wg0
Using Options --foreground  --verbose --allowNonEther
Jun-05 12:12:22 /etc/app/multicast-relay/multicast-relay.py INFO: Adding multicast relay for 224.0.0.251:5353 (mDNS)
Jun-05 12:12:22 /etc/app/multicast-relay/multicast-relay.py INFO: Adding multicast relay for 239.255.255.250:1900 (SSDP)
Jun-05 12:12:23 /etc/app/multicast-relay/multicast-relay.py INFO: Adding broadcast relay for 255.255.255.255:6969 (Sonos Discovery)
Jun-05 12:12:27 /etc/app/multicast-relay/multicast-relay.py INFO: [SSDP] Relayed 356 bytes from 192.168.1.254:1900 on eth0 [ttl 4] to 239.255.255.250:1900 via wg0/10.6.0.1
Jun-05 12:12:27 /etc/app/multicast-relay/multicast-relay.py INFO: [SSDP] Relayed 347 bytes from 192.168.1.254:1900 on eth0 [ttl 4] to 239.255.255.250:1900 via wg0/10.6.0.1
Jun-05 12:12:27 /etc/app/multicast-relay/multicast-relay.py INFO: [SSDP] Relayed 399 bytes from 192.168.1.254:1900 on eth0 [ttl 4] to 239.255.255.250:1900 via wg0/10.6.0.1
alsmith commented 4 years ago

Super - thanks for the feedback !

juliodiz commented 4 years ago

The last version stop working at my python2.7 the MDNS, don't know why

alsmith commented 4 years ago

Unfortunately I'd broken the UDP checksum calculation code - it's mended now. Apologies!