diff --git a/.github/workflows/codacy-outdated.yml b/.github/workflows/codacy-outdated.yml deleted file mode 100644 index 5069859..0000000 --- a/.github/workflows/codacy-outdated.yml +++ /dev/null @@ -1,60 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow checks out code, performs a Codacy security scan -# and integrates the results with the -# GitHub Advanced Security code scanning feature. For more information on -# the Codacy security scan action usage and parameters, see -# https://github.com/codacy/codacy-analysis-cli-action. -# For more information on Codacy Analysis CLI in general, see -# https://github.com/codacy/codacy-analysis-cli. - -name: Codacy Security Scan - -on: - push: - branches: [ "master", "dev" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '45 16 * * 5' - -permissions: - contents: read - -jobs: - codacy-security-scan: - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - name: Codacy Security Scan - runs-on: ubuntu-latest - steps: - # Checkout the repository to the GitHub Actions runner - - name: Checkout code - uses: actions/checkout@v3 - - # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b - with: - # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository - # You can also omit the token and run the tools that support default configurations - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - verbose: true - output: results.sarif - format: sarif - # Adjust severity of non-security issues - gh-code-scanning-compat: true - # Force 0 exit code to allow SARIF file generation - # This will handover control about PR rejection to the GitHub side - max-allowed-issues: 2147483647 - - # Upload the SARIF file generated in the previous step - - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: results.sarif diff --git a/run.sh b/run.sh index df544de..6a2ab71 100755 --- a/run.sh +++ b/run.sh @@ -136,7 +136,7 @@ while true ; do done # Invoking all hook-URLs -if [ -n "${HOOKURL}" ]; then +if [ "${#HOOKURL[@]}" -gt 0 ]; then for URL in "${HOOKURL[@]}" do echo "curl -sSL $URL" @@ -185,7 +185,7 @@ if [ -n "${STSVR}" ]; then done fi -if [ -n "${NGSVR}" ]; then +if [ "${#NGSVR[@]}" -gt 0 ]; then for svropt in "${NGSVR[@]}" do NGOPT="${NGOPT} --ng-server ${svropt},$xopt" diff --git a/server-lgp.sh b/server-lgp.sh index 364266d..c96b246 100755 --- a/server-lgp.sh +++ b/server-lgp.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) domain="${kv[1]}" @@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -99,5 +99,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-lgr.sh b/server-lgr.sh index dbaa122..f3503cb 100755 --- a/server-lgr.sh +++ b/server-lgr.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|dest) dest="${kv[1]}" @@ -64,7 +64,7 @@ fi if [ -z "${prvkey}" ]; then >&2 echo -e "Warning: PrivateKey undefined, Generated new...\n" - kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' ')) + read -ra kv <<< "$(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr '\r\n' ' ')" prvkey="${kv[0]}" pubkey="${kv[1]}" >&2 echo -e "PublicKey: $pubkey\n" @@ -88,7 +88,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -136,5 +136,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-lgt.sh b/server-lgt.sh index 58c22cf..a2dd55c 100755 --- a/server-lgt.sh +++ b/server-lgt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -117,5 +117,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-lsp.sh b/server-lsp.sh index ab0d48b..f36a1f0 100755 --- a/server-lsp.sh +++ b/server-lsp.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) domain="${kv[1]}" @@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi diff --git a/server-lst.sh b/server-lst.sh index e9382ba..9eb0ed9 100755 --- a/server-lst.sh +++ b/server-lst.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi diff --git a/server-ltr.sh b/server-ltr.sh index 9f4e9be..9a007fa 100755 --- a/server-ltr.sh +++ b/server-ltr.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|dest) dest="${kv[1]}" @@ -61,7 +61,7 @@ fi if [ -z "${prvkey}" ]; then >&2 echo -e "Warning: PrivateKey undefined, Generated new...\n" - kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' ')) + read -ra kv <<< "$(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr '\r\n' ' ')" prvkey="${kv[0]}" pubkey="${kv[1]}" >&2 echo -e "PublicKey: $pubkey\n" @@ -80,7 +80,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -128,5 +128,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-ltt.sh b/server-ltt.sh index 9e13c1c..0d20fcb 100755 --- a/server-ltt.sh +++ b/server-ltt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -109,5 +109,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 \ No newline at end of file diff --git a/server-lwp.sh b/server-lwp.sh index cfb181e..93920af 100755 --- a/server-lwp.sh +++ b/server-lwp.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) domain="${kv[1]}" @@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -99,5 +99,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-lwt.sh b/server-lwt.sh index 3245a99..a5e001a 100755 --- a/server-lwt.sh +++ b/server-lwt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -117,5 +117,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-mtt.sh b/server-mtt.sh index 98b9778..190096b 100755 --- a/server-mtt.sh +++ b/server-mtt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -109,5 +109,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-mwp.sh b/server-mwp.sh index 376fe33..45e4db2 100755 --- a/server-mwp.sh +++ b/server-mwp.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) domain="${kv[1]}" @@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -102,5 +102,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-mwt.sh b/server-mwt.sh index 2f5d54a..107672e 100755 --- a/server-mwt.sh +++ b/server-mwt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -120,5 +120,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-nginx.sh b/server-nginx.sh index 51e6faa..fcebb51 100755 --- a/server-nginx.sh +++ b/server-nginx.sh @@ -69,10 +69,10 @@ sed -i '/\#STREAM_TAG/d' $NGCONF # Generate Nginx Stream server configuration. if [ -n "${STSVR}" ]; then -options=($(echo $STSVR |tr ',' ' ')) + IFS=',' read -ra options <<< "$STSVR" for option in "${options[@]}" do - kv=($(echo $option |tr '=' ' ')) + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in p|port) STPORT="${kv[1]}" @@ -82,6 +82,7 @@ options=($(echo $STSVR |tr ',' ' ')) ;; esac done + unset IFS if [ -z "${STPORT}" ]; then STPORT=443; fi if ! [ "${STPORT}" -eq "${STPORT}" ] 2>/dev/null; then >&2 echo "Stream port number must be numeric"; exit 1; fi @@ -90,10 +91,10 @@ options=($(echo $STSVR |tr ',' ' ')) cat ${STREAM_TPL} >> $NGCONF for stmap in "${STMAP[@]}" do - options=($(echo $stmap |tr ',' ' ')) + IFS=',' read -ra options <<< "$stmap" for option in "${options[@]}" do - kv=($(echo $option |tr '=' ' ')) + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in sni) sni="${kv[1]}" @@ -103,6 +104,7 @@ options=($(echo $STSVR |tr ',' ' ')) ;; esac done + unset IFS # Naming the upstream as yahoo_com_jp for SNI yahoo.com.jp upsname="${sni//\./_}" echo " $sni $upsname;" >>/tmp/stmap.conf @@ -132,10 +134,10 @@ do unset certhome NGPROTOCOL # removing site default config file if any. rm -rf /etc/nginx/conf.d/00_default_*.conf - options=($(echo $ngsvr |tr ',' ' ')) + IFS=',' read -ra options <<< "$ngsvr" for option in "${options[@]}" do - kv=($(echo $option |tr '=' ' ')) + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -153,6 +155,7 @@ do ;; esac done + unset IFS if [ -z "${certhome}" ]; then echo -e "Error: Nginx certhome undefined.\n"; usage; exit 1; fi if [ "${#SITEDOMAINS[@]}" -eq 0 ]; then echo -e "Error: Nginx site domain undefined.\n"; usage; exit 1; fi @@ -199,10 +202,10 @@ done for ngproxy in "${NGPROXY[@]}" do unset XDOMAINS xhost xport xlocation xnetwork - options=($(echo $ngproxy |tr ',' ' ')) + IFS=',' read -ra options <<< "$ngproxy" for option in "${options[@]}" do - kv=($(echo $option |tr '=' ' ')) + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) XDOMAINS+=("${kv[1]}") @@ -221,6 +224,7 @@ do ;; esac done + unset IFS if [ -z "${xhost}" ]; then xhost="127.0.0.1"; fi if [ "${#XDOMAINS[@]}" -eq 0 ]; then XDOMAINS=("${ALLDOMAINS[@]}"); fi diff --git a/server-ttt.sh b/server-ttt.sh index 897c264..c7aa4e2 100755 --- a/server-ttt.sh +++ b/server-ttt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user|u=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi diff --git a/server-twp.sh b/server-twp.sh index ac523fb..2f47265 100755 --- a/server-twp.sh +++ b/server-twp.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in d|domain) domain="${kv[1]}" @@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -102,5 +102,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0 diff --git a/server-twt.sh b/server-twt.sh index 1565d6a..adda0cf 100755 --- a/server-twt.sh +++ b/server-twt.sh @@ -7,10 +7,10 @@ usage() { >&2 echo -e "User format: user=[:level:email]" } -IFS=',' read -a options <<< "$1" +IFS=',' read -ra options <<< "$1" for option in "${options[@]}" do - IFS='=' read -a kv <<< "$option" + IFS='=' read -ra kv <<< "$option" case "${kv[0]}" in c|certhome) certhome="${kv[1]}" @@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj # User settings for user in "${xuser[@]}" do - IFS=':'; uopt=(${user}); uopt=(${uopt[@]}) + IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}") uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}" unset IFS if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi @@ -120,5 +120,5 @@ do inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]') done -echo $inbound +echo "$inbound" exit 0