Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support listening on multiple ports with a single socket #809

Open
chayleaf opened this issue Jun 28, 2023 · 1 comment · May be fixed by #814
Open

Support listening on multiple ports with a single socket #809

chayleaf opened this issue Jun 28, 2023 · 1 comment · May be fixed by #814

Comments

@chayleaf
Copy link
Contributor

chayleaf commented Jun 28, 2023

For VPN/proxy-like programs, it's useful to listen to all traffic on all ports. For example, see this library. I'm currently using it, but it would be nice to be able to use smoltcp for this use case as well.

How this would be implemented:

  • For TCP sockets, very little has to change - port 0 should listen on all ports instead of being forbidden (the address tuple will be changed after accepting a packet so this is fine), the state machine is obviously socket-specific so the user will be responsible for creating additional sockets as necessary.
  • For UDP sockets, it's somewhat harder as the implementation is very tied to being available only for a single port right now. Nonetheless, even just implementing sockets that listen for any traffic, then bind to the port where traffic arrived would probably be helpful. Alternatively, new code for wildcard UDP sockets with recv_to and send_from functions can be added, as UDP is a relatively simple protocol.
  • For other sockets, nothing needs to be done as they are either port-specific or port-agnostic
@SajjadPourali
Copy link

@chayleaf: I've created a basic TCP/IP stack for Narrowlink, currently in a somewhat unstable state but functioning adequately. I invite you to review it and contribute if you're interested until this issue gets merged.
https://github.com/narrowlink/ipstack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants