snstac / pytak

PyTAK is a Python package for rapid TAK integration.
https://pytak.readthedocs.io/en/stable/
Apache License 2.0
156 stars 42 forks source link

Allow asyncio to configure UDP broadcast. #43

Closed wtokumaru closed 1 year ago

wtokumaru commented 1 year ago

This line appears to error when asyncio tries to bind because we have not yet specified that we are using a UDP broadcast url: https://github.com/snstac/pytak/blob/main/pytak/asyncio_dgram/aio.py#L270

Passing the broadcast argument appears to enable broadcast without breaking other UDP use-cases, but I am not certain what suite of tests to run to verify full robustness.

Please let me know if I am missing anything.

ampledata commented 1 year ago

Is the expected use-case something along the lines of:

As a user I would like to send CoT to a UDP broadcast address of udp+broadcast://192.168.1.255

?

wtokumaru commented 1 year ago

Yep, we are using something like udp+wobroadcast://192.168.1.255:1234. Is there perhaps an alternative way we should be doing this?

ampledata commented 1 year ago

I think you've got the right approach. The URL schema I'm using isn't rooted in any standard, and so I introduced '+wo' as a "modifier" to the given URL (making it write-only). Similarly (but not implemented) might be a '+ro' modifier, for 'read-only' (again, not actually implemented). For 'broadcast' I would recommend '+broadcast' as a modifier, similar to '+wo'. Given you've already implemented syntax looking for the substring 'broadcast', I think keeping your conditional would allow support for both 'broadcast' and '+broadcast'.

As far as HOW you implemented it.. This is how we detect if an address is multicast vs. unicast and set the right setsockopt: https://github.com/snstac/pytak/blob/main/pytak/client_functions.py#L85 My swag at doing automatic broadcast detect could involve some other method in the ip_address module.

But for now, if your method works for you it works for me too, I'll try to get this into the next minor rev of PyTAK.

wtokumaru commented 1 year ago

Thank you, I really appreciate how detailed your explanation is and how actively you are maintaining this repository!

wtokumaru commented 1 year ago

@ampledata Since it has been a couple months, do you know when the next minor rev of PyTAK might be?