Enable arbitrary port forwarding via config file (#40)

* Add the possibility to forward ports from host to guest

* Reorganized code, fixed a bug, updated the README

* Updated the README

* Forgot to remove 'exit' ....
This commit is contained in:
Yannick Mauray 2020-08-10 13:15:18 +02:00 committed by GitHub
parent 76670511dd
commit 63f5c11a8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -370,6 +370,17 @@ function vm_boot() {
echo " - ssh: All ports for exposing ssh have been exhausted."
fi
# Have any port forwards been requested?
if (( ${#port_forwards[@]} )); then
echo " - PORTS: Port forwards requested:"
for FORWARD in "${port_forwards[@]}"; do
HOST_PORT=$(echo ${FORWARD} | cut -d':' -f1)
GUEST_PORT=$(echo ${FORWARD} | cut -d':' -f2)
echo " - ${HOST_PORT} => ${GUEST_PORT}"
NET="${NET},hostfwd=tcp::${HOST_PORT}-:${GUEST_PORT}"
done
fi
# Find a free port for spice
local SPICE_PORT=$(get_port 5930 9)
if [ ! -n "${SPICE_PORT}" ]; then