From 57a902ad9f55ec746266efb2f3c4b41dc369c693 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 17 Sep 2025 21:49:20 +0200 Subject: [PATCH] feat: add UDP support to USER_PORTS (#1011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/network.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/network.sh b/src/network.sh index ceac94f..73553c2 100644 --- a/src/network.sh +++ b/src/network.sh @@ -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%?}"