feat: add UDP support to USER_PORTS

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:48:43 +02:00 committed by GitHub
parent a7e229aaae
commit 1cb0dbe5c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -152,7 +152,18 @@ getUserPorts() {
list="${list%% }"
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
echo "${args%?}"