Closed sander76 closed 6 years ago
Hi @sander76. Yes, this code allows others to find your IP address using mDNS. It absolutely can be made to work on cPython (and that's how I did most of my initial testing). The changes that are needed mostly are in the _make_socket()
function where you need to set a bunch of other socket options. Adding this code into this version would increase the code size, so I'd rather not do it here but you are welcome to try.
That said, there are other projects for pure Python mDNS implementations which do not have small size as a primary goal. You should take a look at the standard Python ZeroConf library. This supports everything that my code does and a great deal more, at the expense of a much, much larger memory footprint, the need for threads and some rather less efficient packet handling. You can advertise your IP address (and other services) using the register_service()
method of a Zeroconf
object. The release notes indicate that it should work on Windows.
I hope that this helps.
@nickovs Thanks for the detailled response. The thing with ZeroConf library is that it requires NetIfaces. This is a library that cannot be just pip installed on windows: You need to compile it yourself or use a precompiled binary from https://www.lfd.uci.edu/~gohlke/pythonlibs/
As I am targeting windows users that is not a procedure I prefer. I'll have a go with your suggestions... If you can share any more tips they are more than welcome !!
Just linking this here for anyone that may want to try get slimDNS to work on their dev machine: https://gist.github.com/aaroncohen/4630685
I failed to get slimDNS running in Python 3.6 in Windows, and I couldn't afford the development time to investigate it further. I too suspect there is a missing socket option or the like that is required.
If there is interest then I could certainly look at creating a version that is designed to work on other platforms. There seem to be three areas necessary to make this happen:
For the last item I can test on macOS and Linux but I'd need someone else to test the Windows version.
If people want to run slimDNS on full-size Python then click the smiley on this comment. If I get enough smiles I'll do it!
If I understand correctly this code allows for getting the ip address of devices which are registered on mDNS with a certain name ?
If so I wonder whether this library can be adapted to work on "normal" python too (and more specifically on windows..) ? I did give it a go myself, but I failed.. I know there are libraries out there doing this already, but they are hard to install or are non-windows.