Unverified Commit e70ed190 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Port forwarding (#530)

parent d65b5a08
Loading
Loading
Loading
Loading
+7 −21
Original line number Diff line number Diff line
@@ -94,34 +94,20 @@ configureDNS() {
getPorts() {

  local list=$1
  local args=""
  local vnc="5900"

  list="${list//,/ }"
  list="${list## }"
  list="${list%% }"

  if [[ "${DISPLAY,,}" == "vnc" ]] && [[ "$list" != *"$vnc"* ]]; then
    if [ -z "$list" ]; then
      list="$vnc"
    else
      list="$list $vnc"
    fi
    [ -z "$list" ] && list="$vnc" || list="$list,$vnc"
  fi

  if [ -n "$list" ]; then
    if [[ "$list" != *" "* ]]; then
      args=" ! --dport $list"
  [ -z "$list" ] && return 0
  
  if [[ "$list" != *","* ]]; then
    echo " ! --dport $list"
  else
      args=" -m multiport ! --dports "
      for port in $list; do
        args="${args}${port},"
      done
      args="${args%?}"
    fi
    echo " -m multiport ! --dports $list"
  fi

  echo "$args"
  return 0
}