slirp4netns
slirp4netns copied to clipboard
Why can't you do add_hostfwd with a host_port of 0?
I would like to be able to forward a host port to a guest port, with the host port automatically determined by the OS to avoid race conditions. I tried to do this by passing "host_port": 0 in a command to the API socket.
However, this returns an error that says bad arguments.host_port.
I found that this case is specifically excluded here:
https://github.com/rootless-containers/slirp4netns/blob/9996a4e014ddb100010146b082047314ef228ba3/api.c#L135-L142
Why is this not possible? Is it some limitation of libslirp? (This maybe an awkward time to ask as libslirp seems to be migrating its Gitlab instance and is down at the moment, so I'm having trouble checking over there...)
Because libslirp doesn't seem to support that feature. At least it doesn't seem to support reporting the actual host port that was resolved from zero.