From 17842921159b81dfecc881f56041e13a0c43a7d5 Mon Sep 17 00:00:00 2001 From: "xiongdian.me" Date: Thu, 25 May 2023 12:01:36 +0800 Subject: [PATCH] riot: if remote ends with dot, treat it as a full-hostname; add tests --- scripts/riot | 8 ++------ tools/test.zsh | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/riot b/scripts/riot index 2342bcc..a742801 100755 --- a/scripts/riot +++ b/scripts/riot @@ -29,10 +29,6 @@ get_server_meta() { # presets -- match domain local domain=${remote##*.} local host=${remote%.*} - # if ends with dot - if [[ -z "$domain" ]]; then - domain="ibd" - fi # if there's no dot if [[ "$host" == "$domain" ]]; then domain="ibd" @@ -51,7 +47,7 @@ get_server_meta() { RET_JUMP_SERVER="ssh@nasp.ob.ac.cn:36022" RET_TRUST_SERVER=1 ;; - proxied ) + x|proxied ) RET_HOSTNAME=proxy.beardic.cn local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]") tmp=${tmp:0:4} @@ -60,7 +56,7 @@ get_server_meta() { RET_TRUST_SERVER=1 ;; * ) - fmt_warning "unknown domain: $domain. will try as host name" + test -z "$domain" || fmt_warning "unknown domain: \"$domain\". will try as host name" RET_HOSTNAME="$remote" esac } diff --git a/tools/test.zsh b/tools/test.zsh index 5a0b3f2..039d7c6 100644 --- a/tools/test.zsh +++ b/tools/test.zsh @@ -31,6 +31,7 @@ test $(echo n | tools/common.sh ask_for_yN "test") = "0" test $(echo | tools/common.sh ask_for_yN "test") = "0" test $(echo | tools/common.sh ask_for_Yn "test") = "1" test $(DFS_QUIET=1 tools/common.sh ask_for_Yn "test") = "1" +test "$(DFS_TRUST=1 riot time@is.impt:2222,yes@you-r.right,you@are.really.recht.,ibd.,try@it scp /tmp/ ./tmp -D 2>/dev/null)" = 'scp -P 12022 -o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes -o ProxyJump=time@is.impt:2222,yes@you-r.right,you@are.really.recht.,ibd. -r try@it.ibd.ink:"/tmp/" "./tmp"' # check alias alias p114