markqvist / Reticulum

The cryptography-based networking stack for building unstoppable networks with LoRa, Packet Radio, WiFi and everything in between.
https://reticulum.network
MIT License
2k stars 124 forks source link

Fix interface values not being set on RNodeSubInterface instances #556

Open jacobeva opened 1 week ago

jacobeva commented 1 week ago

This one's on me. So, when I designed RNodeMultiInterface, it didn't occur to me that the interface values being set in Reticulum.py would not actually be set until after the class was initialised. And since these values are passed on to the RNodeSubInterface before they're actually initialised, this created a problem. The actual values will never be set in the subinterface (which is the one actually processing packets).

The way this manifested as a bug was in the fact that self.OUT would be set to false on all RNodeSubInterface instances until the interface was destroyed and recreated (i.e. through pulling the connection to the RNode). So, every first connection when the RNS daemon started would result in it not being able to transmit on any of the RNodeSubInterface instances. This would likely have other implications if not fixed as well, such as affecting IFAC or other things which are set on the interface after it is started.

I don't know how you'll feel about the .start() call I made in this PR Mark. It would be entirely possible to create a thread to run in a second or so in the future after the __init__() is called for RNodeMultiInterface in the actual class. That could be done, but I do have reservations about it potentially creating race conditions. At least in this current implementation, it should guarantee this issue does not resurface, but may not be to your liking as of current.

jacobeva commented 1 week ago

Sorry for the mess, I accidentally deleted some lines so I had to add them back.