[debug+dev] riot checks and fix ipv6 support, fix crontab installation; antigen use F-Sy-H (#39)

* format: remove space

* sry but..., riot: 'i' for 'ibd', and remove support for ebd

* fix ipv6 support

* validate port and username

* install.sh: failed to add to crontab when there's no crontab

* sync zdharma-continuum/fast-syntax-highlighting

* use fast-syntax-highlighting instead

---------

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
2023-06-20 15:10:59 +08:00
committed by GitHub
parent 2cc2ab48b8
commit 1a62ffe74b
4 changed files with 42 additions and 7 deletions

View File

@@ -5,6 +5,19 @@ source "$THIS_DIR/../tools/common.sh"
RIOT_TRUST_CLIENT=${RIOT_TRUST_CLIENT:-${DFS_TRUST:-0}}
RIOT_TRUST_SERVER=${RIOT_TRUST_SERVER:-0}
# check if port number valid
check_port() {
( echo $1 | grep -qxE "[1-9][0-9]{0,4}" ) || return 1
test $1 -lt 65536 -a $1 -gt 0 || return 1
return 0
}
# check if username valid
check_username() {
( echo $1 | grep -qxE "^[a-z][-a-z0-9_]*\$" ) || return 1
return 0
}
# get single server setting
# may be called more than once
get_server_meta() {
@@ -20,22 +33,24 @@ get_server_meta() {
if [[ "$remote" == *@* ]]; then
RET_USERNAME=${remote%%@*}
remote=${remote#*@}
check_username $RET_USERNAME || fmt_fatal invalid username \"$RET_USERNAME\"
fi
# if in the form ...:22
if [[ "$remote" == *:* ]]; then
if [[ "$remote" == "["*"]":* || ( "$remote" != "["*"]" && "$remote" == *:* ) ]]; then
RET_PORT=${remote##*:}
remote=${remote%:*}
check_port $RET_PORT || fmt_fatal invalid port number \"$RET_PORT\"
fi
# presets -- match domain
local domain=${remote##*.}
local host=${remote%.*}
# if there's no dot
if [[ "$host" == "$domain" ]]; then
if [[ "$host" == "$domain" && "$host" != "["*"]" ]]; then
domain="ibd"
fi
case $domain in
ibd|ebd )
RET_HOSTNAME=$host.$domain.ink
i|ibd )
RET_HOSTNAME=$host.ibd.ink
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-root}
RET_TRUST_SERVER=1
@@ -76,7 +91,7 @@ parse_remote() {
local remote="$1"
local jump_servers=""
# loop for jump servers
while [[ -n $remote ]]; do
while [[ -n $remote ]]; do
local server=${remote%%,*}
remote=${remote#*,}
get_server_meta "$server"