Skip to content

Allow server to bind on zero port number #1185

@joy4eg

Description

@joy4eg

Currently, you must set port number each time either via config or via API.
Every so often that port could be busy, sometimes not, which adds additional cost to error handling and synchronizations. That becomes really complicated with ssmanager and when you add-remove users fast enough.

The proposal is that:

  • Allow to bind on port zero, and let the OS find the first free port for you (or fail fast in case if there are no open ports available)
  • Return that port number via API:
    • Add a new command like add_dynamic (so as not to break any backward compatibility)
    • As a response, return the port number: OK:{"port": 42}

Regarding UDP, I see two options here:

  • We could try to bind to the same port as TCP, and raise an error if something went wrong.
  • Add a flag to the new API command, like protocol (tcp, tcpudp, etc)

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions