Repository navigation
feat: allow listen on ANY port - #1203
flaneur2020 wants to merge 8 commits into
Conversation
Adapt UDP sockets to optional listen ports while preserving the unbound default. Carry local ports in packet metadata, validate outgoing source ports, and cover wildcard receive/reply flows.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1203 +/- ##
==========================================
+ Coverage 82.57% 82.67% +0.10%
==========================================
Files 83 83
Lines 26174 26321 +147
==========================================
+ Hits 21613 21761 +148
+ Misses 4561 4560 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I think it's a great feature! I'll give it a closer look during the workweek. |
| impl defmt::Format for ListenEndpoint { | ||
| fn format(&self, f: defmt::Formatter) { | ||
| defmt::write!(f, "{:?}:{=u16}", self.addr, self.port); | ||
| defmt::write!(f, "{:?}:{:?}", self.addr, self.port); |
There was a problem hiding this comment.
This will print Some(<num>) in defmt won't it?
It's not unreadable it will just be a bit different than before. So <num>.<num>.<num>.<num>:Some(<num>) now I could be wrong so feel free to ignore it.
There was a problem hiding this comment.
yeah, it really doesn't look great. i think it would look better if it followed the same format as the Display above. i've fixed it in 0e05e3b, PTAL. thanks for pointing this out!
(though I suspect it was originally showing up as Some(<num>.<num>.<num>.<num>):<num>, since self.addr is also an Option 😲...)
I've been trying to build something like tun2socks (which based on gVisor's network stack) in Rust using smoltcp to route TUN traffic through a SOCKS proxy.
However, I've run into a limitation: smoltcp does not yet support listening on any ports. In the context of a TUN device, we really need to be able to catch traffic on any port to forward it to the proxy.
I found @chayleaf's PR #814 which was tackling this, but it hasn't been merged yet. I decide to build on top of the code from PR #814 and incorporated the comment from @raftario.
I think this functionality would be super useful for anyone building VPN-like tools. I've passed the tests in my tun2socks impl with this branch here: https://github.com/flaneur2020/smoltcp-socks/blob/master/src/netstack/actor.rs#L288
Any feedback would be appreciated!