feat: add UDP support to USER_PORTS (#1011)

Allow USER_PORTS entries in the form PORT or PORT/PROTO (tcp or udp). When the protocol is omitted, TCP is assumed for backward compatibility. This enables forwarding of UDP services when running the container in user‑mode networking.
This commit is contained in:
Kroese 2025-09-17 21:49:20 +02:00 committed by GitHub
parent a7e229aaae
commit 57a902ad9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -152,7 +152,18 @@ getUserPorts() {
list="${list%% }" list="${list%% }"
for port in $list; do for port in $list; do
args+="hostfwd=tcp::$port-$VM_NET_IP:$port," proto="tcp"
num="$port"
if [[ "$port" == */udp ]]; then
proto="udp"
num="${port%/udp}"
elif [[ "$port" == */tcp ]]; then
proto="tcp"
num="${port%/tcp}"
fi
args+="hostfwd=$proto::$num-$VM_NET_IP:$num,"
done done
echo "${args%?}" echo "${args%?}"