ProSafeLinux icon indicating copy to clipboard operation
ProSafeLinux copied to clipboard

Discover Bug

Open mahuika88 opened this issue 11 years ago • 4 comments

Running the discover command I got this error: Searching for ProSafe Plus Switches ...

Traceback (most recent call last): File "./psl-cli.py", line 191, in main() File "./psl-cli.py", line 187, in main cmd_funcs[args.operation](args, switch) File "./psl-cli.py", line 16, in discover data = switch.discover() File "/home/ianm/Downloads/ProSafeLinux-master/psl_class.py", line 383, in discover self.mac_cache[message[self.CMD_MAC]] = message[self.CMD_IP] TypeError: 'bool' object has no attribute 'getitem'

I'm using Python 2.7.3 and Fedora 18. This might be user error on my part.

mahuika88 avatar Jun 13 '13 00:06 mahuika88

Which command did you use when getting this error?

Z3po avatar Jun 13 '13 04:06 Z3po

It was ./psl-cli.py --interface em1 discover

mahuika88 avatar Jun 13 '13 15:06 mahuika88

I ran into the same problem. I did some investigation. if I do "./psi-cli --interface wlan0 discover" I have the same problem, except when I plug in a network cable into the same network so eth0 comes up. If I check with wireshark, I see a outgoing broadcast UDP packet to port 63322, from source port 63321. My switch sends a reply packet. All over eth0! Even if I explicitly replace 'eth0' by 'wlan0' in the sources this does not change. It seems binding to a specific interface fails somehow. And, there is some dependency on eth0 that I cannot find.

Ok, after some more testing (and googling..) I found a solution: in file psl_class.py on line 152 (in function bind()) change self.rsocket.bind(("255.255.255.255", self.RECPORT)) to self.rsocket.bind(("", self.RECPORT)) This will effectively change the listening address from INADDR_BROADCAST to INADDR_ANY; the first apparently does not work reliably (on linux?). The latter works correctly. Just in case this is important for someone: I tested this on linux 3.9.4

josn0 avatar Jun 16 '13 00:06 josn0

Thanks josn0! I've fixed the problem and created a pull request. I don't know why binding to INADDR_BROADCAST doesn't work here, but as setting to INADDR_ANY fixes the thing that should be fine. The only way to use INADDR_ANY and additionally binding to a specific interface would need us to use SO_BINDTODEVICE which is a privileged option and i don't think the netgear client should be run as root :) Package sending is correctly bind to the given INTERFACE so that change should fix the problem.

Z3po avatar Jun 18 '13 18:06 Z3po