diff --git a/README.md b/README.md index df6f1ef..bc94745 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [LianHuanHua](#lianhuanhua) - [Docker](#docker) - [HAProxy](#haproxy) +- [tests](#tests) - [Dev](#dev) @@ -360,6 +361,12 @@ wget https://woniuzfb.github.io/iptv/iptv.sh && bash iptv.sh +## tests + +```bash +./debug tt +``` + ## Dev v2.0.0 broken atm diff --git a/debug b/debug index f5ff3c4..c819bdf 100755 --- a/debug +++ b/debug @@ -44,9 +44,9 @@ then if [ "$debug_options_index" -eq 0 ] then echo - inquirer list_input_index "是否部署" ny_options ny_options_index + inquirer list_input_index "是否部署" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then "$DEV_PATH"/make else @@ -69,9 +69,9 @@ then inquirer list_input "选择测试的程序" self_options self echo - inquirer text_input "输入参数" args_input "$i18n_not_set" + inquirer text_input "输入参数" args_input "$i18n_blank" - if [ "$args_input" == "$i18n_not_set" ] + if [ "$args_input" == "$i18n_blank" ] then args=() else diff --git a/docs/iptv.sh b/docs/iptv.sh index e6729e8..f2c4a2d 100755 --- a/docs/iptv.sh +++ b/docs/iptv.sh @@ -2466,11 +2466,18 @@ inquirer() trap inquirer:control_c EXIT + read -e text_input + + until validate_failed_msg=$($text_input_validator "$text_input") + do + inquirer:print "\n${bg_black}${red}${validate_failed_msg:-$text_input_validate_failed_msg}${normal}\n\n" + read -e text_input + done + #stty -echo #tput cnorm - - read -e text_input #inquirer:on_keypress inquirer:on_default inquirer:on_default inquirer:on_text_input_ascii inquirer:on_text_input_enter inquirer:on_text_input_left inquirer:on_text_input_right inquirer:on_text_input_ascii inquirer:on_text_input_backspace inquirer:on_text_input_not_ascii + read -r ${var_name?} <<< "${text_input:-$text_default}" inquirer:cleanup @@ -31995,9 +32002,11 @@ AcmeCheck() if [ ! -f "$HOME/.acme.sh/acme.sh" ] then DepInstall socat - { curl -s -m 10 https://get.acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ + { curl -s -m 20 https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ | sed "s+https://raw.githubusercontent.com/acmesh-official+$FFMPEG_MIRROR_LINK/acmesh-content+g" \ - | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" | bash + | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" > ~/acme.sh + cd ~ + bash acme.sh --install else echo inquirer list_input_index "更新 acme.sh" ny_options ny_options_index @@ -53578,7 +53587,7 @@ then fi Println "$info 下载 acme.sh ..." - if curl -s -L https://get.acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" + if curl -s -L https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" then mv "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" "$FFMPEG_MIRROR_ROOT/acme.sh" else diff --git a/iptv.sh b/iptv.sh index e6729e8..f2c4a2d 100755 --- a/iptv.sh +++ b/iptv.sh @@ -2466,11 +2466,18 @@ inquirer() trap inquirer:control_c EXIT + read -e text_input + + until validate_failed_msg=$($text_input_validator "$text_input") + do + inquirer:print "\n${bg_black}${red}${validate_failed_msg:-$text_input_validate_failed_msg}${normal}\n\n" + read -e text_input + done + #stty -echo #tput cnorm - - read -e text_input #inquirer:on_keypress inquirer:on_default inquirer:on_default inquirer:on_text_input_ascii inquirer:on_text_input_enter inquirer:on_text_input_left inquirer:on_text_input_right inquirer:on_text_input_ascii inquirer:on_text_input_backspace inquirer:on_text_input_not_ascii + read -r ${var_name?} <<< "${text_input:-$text_default}" inquirer:cleanup @@ -31995,9 +32002,11 @@ AcmeCheck() if [ ! -f "$HOME/.acme.sh/acme.sh" ] then DepInstall socat - { curl -s -m 10 https://get.acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ + { curl -s -m 20 https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ | sed "s+https://raw.githubusercontent.com/acmesh-official+$FFMPEG_MIRROR_LINK/acmesh-content+g" \ - | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" | bash + | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" > ~/acme.sh + cd ~ + bash acme.sh --install else echo inquirer list_input_index "更新 acme.sh" ny_options ny_options_index @@ -53578,7 +53587,7 @@ then fi Println "$info 下载 acme.sh ..." - if curl -s -L https://get.acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" + if curl -s -L https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" then mv "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" "$FFMPEG_MIRROR_ROOT/acme.sh" else diff --git a/src/_4gtv/start_link b/src/_4gtv/start_link index f4b1259..b2d072b 100644 --- a/src/_4gtv/start_link +++ b/src/_4gtv/start_link @@ -93,9 +93,9 @@ Start4gtvLink() then choose_asked=true echo - inquirer list_input_index "是否按分辨率自动选择" yn_options yn_options_index + inquirer list_input_index "是否按分辨率自动选择" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then i=$((i-1)) continue diff --git a/src/_4gtv/use_proxy b/src/_4gtv/use_proxy index 43065bc..d2a07c5 100644 --- a/src/_4gtv/use_proxy +++ b/src/_4gtv/use_proxy @@ -3,8 +3,8 @@ Use4gtvProxy() GetDefault d_4gtv_proxy=${d_4gtv_proxy:-$d_proxy} Println "$tip 可以使用脚本自带的 v2ray 管理面板添加代理, 可以输入 omit 省略此选项" - inquirer text_input "请输入 4gtv 代理, 比如 http://username:passsword@127.0.0.1:5555 : " _4gtv_proxy "${d_4gtv_proxy:-$i18n_not_set}" - if [ "$_4gtv_proxy" == "omit" ] || [ "$_4gtv_proxy" == "$i18n_not_set" ] + inquirer text_input "请输入 4gtv 代理, 比如 http://username:passsword@127.0.0.1:5555 : " _4gtv_proxy "${d_4gtv_proxy:-$i18n_blank}" + if [ "$_4gtv_proxy" == "omit" ] || [ "$_4gtv_proxy" == "$i18n_blank" ] then _4gtv_proxy="" _4gtv_proxy_command=() diff --git a/src/alist/acc b/src/alist/acc index 777603d..5e9755b 100644 --- a/src/alist/acc +++ b/src/alist/acc @@ -46,9 +46,9 @@ AlistAccAdd() ExitOnText "输入登录名" alist_acc_username echo - inquirer text_input "输入密码" alist_acc_password "$i18n_not_set" + inquirer text_input "输入密码" alist_acc_password "$i18n_blank" - if [ "$alist_acc_password" == "$i18n_not_set" ] + if [ "$alist_acc_password" == "$i18n_blank" ] then alist_acc_password="" fi diff --git a/src/alist/act b/src/alist/act index 21b4b6a..15fbec5 100644 --- a/src/alist/act +++ b/src/alist/act @@ -61,9 +61,9 @@ AlistAct() if [ -n "${alist_accs_token[alist_accs_index]}" ] then echo - inquirer list_input_index "是否重新登陆账号" ny_options ny_options_index + inquirer list_input_index "是否重新登陆账号" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then alist_acc_token="${alist_accs_token[alist_accs_index]}" else @@ -248,9 +248,9 @@ AlistAct() done Println "$alist_files_txt\n" - inquirer list_input_index "确认删除以上文件" ny_options ny_options_index + inquirer list_input_index "确认删除以上文件" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then for alist_file_delete_name in "${alist_files_delete_names[@]}" do diff --git a/src/alist/app b/src/alist/app index b416520..44d7948 100644 --- a/src/alist/app +++ b/src/alist/app @@ -14,9 +14,9 @@ AlistAppAdd() fi echo - inquirer text_input "输入 Alist 名称" alist_name "$i18n_not_set" + inquirer text_input "输入 Alist 名称" alist_name "$i18n_blank" - if [ "$alist_name" == "$i18n_not_set" ] + if [ "$alist_name" == "$i18n_blank" ] then alist_name="" fi diff --git a/src/arm b/src/arm index 959640e..53090f5 100644 --- a/src/arm +++ b/src/arm @@ -823,8 +823,8 @@ EOF fi echo - inquirer text_input "输入当前配置保存名称: " config_name "$i18n_not_set" - if [ "$config_name" == "$i18n_not_set" ] + inquirer text_input "输入当前配置保存名称: " config_name "$i18n_blank" + if [ "$config_name" == "$i18n_blank" ] then config_name="" else diff --git a/src/calibre/install b/src/calibre/install index bc472ac..25e602e 100644 --- a/src/calibre/install +++ b/src/calibre/install @@ -12,18 +12,22 @@ CalibreInstall() DepInstall libglvnd-opengl DepInstall libxcb-cursor-devel DepInstall nss + DepInstall libxkbcommon + DepInstall mesa-libEGL else DepInstall xz-utils DepInstall libopengl0 DepInstall libxcb-cursor0 DepInstall libnss3 + DepInstall libxkbcommon-x11-0 + DepInstall libglx0 + DepInstall libegl1 fi ImageMagickInstall - DepInstall libegl1 PythonInstall pip3 install pyqt6 mkdir -p "$CALIBRE_ROOT"/bin - sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin install_dir="$CALIBRE_ROOT"/bin + sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin install_dir="$CALIBRE_ROOT"/bin version=7.16.0 fi Println "$info calibre 安装/更新成功\n" diff --git a/src/calibre/kcc b/src/calibre/kcc index 6674b5d..c3543ad 100644 --- a/src/calibre/kcc +++ b/src/calibre/kcc @@ -90,8 +90,8 @@ KccConfig() else kcc_process=true echo - inquirer text_input "输入额外参数" kcc_args "$i18n_not_set" - if [ "$kcc_args" == "$i18n_not_set" ] + inquirer text_input "输入额外参数" kcc_args "$i18n_blank" + if [ "$kcc_args" == "$i18n_blank" ] then kcc_args="" fi @@ -185,8 +185,8 @@ KccConfigEdit() ;; 2) echo - inquirer text_input "输入额外参数" new_kcc_args "$i18n_not_set" - if [ "$new_kcc_args" == "$i18n_not_set" ] + inquirer text_input "输入额外参数" new_kcc_args "$i18n_blank" + if [ "$new_kcc_args" == "$i18n_blank" ] then new_kcc_args="" fi @@ -212,8 +212,8 @@ KccConfigEdit() while true do echo - inquirer text_input "输入源图片目录" new_kcc_source "$i18n_not_set" - if [ "$new_kcc_source" == "$i18n_not_set" ] + inquirer text_input "输入源图片目录" new_kcc_source "$i18n_blank" + if [ "$new_kcc_source" == "$i18n_blank" ] then break fi @@ -256,8 +256,8 @@ KccConfigEdit() while true do echo - inquirer text_input "修改源图片目录 ${kcc_sources[kcc_sources_index]}" new_kcc_source "$i18n_not_set" - if [ "$new_kcc_source" == "$i18n_not_set" ] + inquirer text_input "修改源图片目录 ${kcc_sources[kcc_sources_index]}" new_kcc_source "$i18n_blank" + if [ "$new_kcc_source" == "$i18n_blank" ] then continue 2 fi diff --git a/src/calibre/web b/src/calibre/web index 193277b..9fa1d91 100644 --- a/src/calibre/web +++ b/src/calibre/web @@ -3,7 +3,9 @@ CalibreWebInstall() if [ -d "$CALIBRE_ROOT/web" ] then cd "$CALIBRE_ROOT/web" + git stash git pull + git stash pop Println "$info Calibre Web 更新成功\n" return fi diff --git a/src/cloudflare/config_route b/src/cloudflare/config_route index 6193f33..d31a1cd 100644 --- a/src/cloudflare/config_route +++ b/src/cloudflare/config_route @@ -155,9 +155,9 @@ CloudflareConfigWorkerRoute() then cf_workers_index=$((script-1)) echo - inquirer list_input_index "是想要输入 ${cf_workers_project_name[cf_workers_index]}" yn_options yn_options_index + inquirer list_input_index "是想要输入 ${cf_workers_project_name[cf_workers_index]}" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then script=${cf_workers_project_name[cf_workers_index]} fi diff --git a/src/cloudflare/edit_user b/src/cloudflare/edit_user index 4aa2769..2865910 100644 --- a/src/cloudflare/edit_user +++ b/src/cloudflare/edit_user @@ -45,14 +45,14 @@ CloudflareEditUser() Println " 用户密码: ${green} $cf_user_pass_new ${normal}\n" Println "请输入用户 Token" - read -p "(默认: ${cf_user_token:-$i18n_not_set}): " cf_user_token_new + read -p "(默认: ${cf_user_token:-$i18n_blank}): " cf_user_token_new cf_user_token_new=${cf_user_token_new:-$cf_user_token} - Println " 用户 Token: ${green} ${cf_user_token_new:-$i18n_not_set} ${normal}\n" + Println " 用户 Token: ${green} ${cf_user_token_new:-$i18n_blank} ${normal}\n" Println "请输入用户 Key" - read -p "(默认: ${cf_user_api_key:-$i18n_not_set}): " cf_user_api_key_new + read -p "(默认: ${cf_user_api_key:-$i18n_blank}): " cf_user_api_key_new cf_user_api_key_new=${cf_user_api_key_new:-$cf_user_api_key} - Println " 用户 Token: ${green} ${cf_user_api_key_new:-$i18n_not_set} ${normal}\n" + Println " 用户 Token: ${green} ${cf_user_api_key_new:-$i18n_blank} ${normal}\n" new_user=$( $JQ_FILE -n --arg email "$cf_user_email_new" --arg pass "$cf_user_pass_new" \ diff --git a/src/cloudflare/edit_worker b/src/cloudflare/edit_worker index 9c7ebc2..200df26 100644 --- a/src/cloudflare/edit_worker +++ b/src/cloudflare/edit_worker @@ -75,9 +75,9 @@ CloudflareEditWorker() if [ -d "$CF_WORKERS_ROOT/${cf_workers_path[cf_workers_index]:-notfound}" ] then echo - inquirer list_input_index "是否删除原路径目录" yn_options yn_options_index + inquirer list_input_index "是否删除原路径目录" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then rm -rf "$CF_WORKERS_ROOT/${cf_workers_path[cf_workers_index]:-notfound}" fi diff --git a/src/cloudflare/set_user b/src/cloudflare/set_user index 808743e..f327cae 100644 --- a/src/cloudflare/set_user +++ b/src/cloudflare/set_user @@ -33,8 +33,8 @@ CloudflareSetUserPass() CloudflareSetUserToken() { Println "$tip 需要 workers 和 zone(区域) 编辑权限, 以及 zone(区域) 的 Analytics 读取权限" - inquirer text_input "请输入用户 Token: " cf_user_token "$i18n_not_set" - if [ "$cf_user_token" == "$i18n_not_set" ] + inquirer text_input "请输入用户 Token: " cf_user_token "$i18n_blank" + if [ "$cf_user_token" == "$i18n_blank" ] then cf_user_token="" else @@ -51,8 +51,8 @@ CloudflareSetUserToken() CloudflareSetUserKey() { echo - inquirer text_input "请输入用户 Global API KEY: " cf_user_api_key "$i18n_not_set" - if [ "$cf_user_api_key" == "$i18n_not_set" ] + inquirer text_input "请输入用户 Global API KEY: " cf_user_api_key "$i18n_blank" + if [ "$cf_user_api_key" == "$i18n_blank" ] then cf_user_api_key="" fi diff --git a/src/cx b/src/cx index fd01454..bffcd7d 100644 --- a/src/cx +++ b/src/cx @@ -129,9 +129,9 @@ case $xtream_codes_num in echo -e "$result" >> "$XTREAM_CODES_EXAM" echo && echo - inquirer list_input_index "验证 mac" ny_options ny_options_index + inquirer list_input_index "验证 mac" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then verify_mac=1 fi diff --git a/src/haproxy/install b/src/haproxy/install index 2c47ce4..1236a6b 100644 --- a/src/haproxy/install +++ b/src/haproxy/install @@ -198,7 +198,6 @@ HAProxyInstall() fi cd haproxy-"${haproxy_ver}" - make clean if [ "$dist" == "mac" ] then diff --git a/src/ibm_cf/set_app b/src/ibm_cf/set_app index def7e89..4ce16fa 100644 --- a/src/ibm_cf/set_app +++ b/src/ibm_cf/set_app @@ -77,8 +77,8 @@ IbmSetCfAppRouteHostname() IbmSetCfAppRoutePath() { echo - inquirer text_input "请输入 http 路由 path: " ibm_cf_app_route_path "$i18n_not_set" - if [ "$ibm_cf_app_route_path" == "$i18n_not_set" ] + inquirer text_input "请输入 http 路由 path: " ibm_cf_app_route_path "$i18n_blank" + if [ "$ibm_cf_app_route_path" == "$i18n_blank" ] then ibm_cf_app_route_path="" fi diff --git a/src/iptv/add_schedule b/src/iptv/add_schedule index 9b1504a..bf0441a 100644 --- a/src/iptv/add_schedule +++ b/src/iptv/add_schedule @@ -87,16 +87,16 @@ AddChannelsSchedule() inquirer date_pick "设置结束日期" schedule_end_time echo - inquirer list_input_index "每日循环" ny_options ny_options_index + inquirer list_input_index "每日循环" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_loop=false echo - inquirer list_input_index "结束后自动清除" ny_options ny_options_index + inquirer list_input_index "结束后自动清除" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_auto_remove=false else @@ -108,16 +108,16 @@ AddChannelsSchedule() fi echo - inquirer list_input_index "防盗链" yn_options yn_options_index + inquirer list_input_index "防盗链" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change=true echo - inquirer list_input_index "防盗链一次" ny_options yn_options_index + inquirer list_input_index "防盗链一次" ny_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change_once=false else @@ -182,16 +182,16 @@ AddChannelsSchedule() inquirer date_pick "设置结束日期" schedule_end_time echo - inquirer list_input_index "每日循环" ny_options ny_options_index + inquirer list_input_index "每日循环" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_loop=false echo - inquirer list_input_index "结束后自动清除" ny_options ny_options_index + inquirer list_input_index "结束后自动清除" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_auto_remove=false else @@ -203,16 +203,16 @@ AddChannelsSchedule() fi echo - inquirer list_input_index "防盗链" yn_options yn_options_index + inquirer list_input_index "防盗链" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change=true echo - inquirer list_input_index "防盗链一次" ny_options yn_options_index + inquirer list_input_index "防盗链一次" ny_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change_once=false else @@ -224,9 +224,9 @@ AddChannelsSchedule() fi echo - inquirer text_input "输入频道名称" schedule_channel_name "$i18n_not_set" + inquirer text_input "输入频道名称" schedule_channel_name "$i18n_blank" - if [ "$schedule_channel_name" == "$i18n_not_set" ] + if [ "$schedule_channel_name" == "$i18n_blank" ] then schedule_channel_name="" fi @@ -258,9 +258,9 @@ AddChannelsSchedule() Println "$info 频道 [ ${schedule_channel_name:-${chnls_channel_name[chnls_index]}} ] 计划添加成功\n" echo - inquirer list_input_index "是否继续添加此频道计划" ny_options ny_options_index + inquirer list_input_index "是否继续添加此频道计划" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then break fi diff --git a/src/iptv/edit_channel b/src/iptv/edit_channel index b4a7985..ae3ab93 100644 --- a/src/iptv/edit_channel +++ b/src/iptv/edit_channel @@ -90,12 +90,12 @@ EditStreamLink() if [ "$xc_select" = false ] then - inquirer text_input "输入新的直播源( mpegts / hls / flv / youtube ...): " stream_link "$i18n_not_set" + inquirer text_input "输入新的直播源( mpegts / hls / flv / youtube ...): " stream_link "$i18n_blank" else stream_link="${chnl_stream_links[chnl_stream_links_index]//${chnl_stream_links[chnl_stream_links_index]##*|}/$new_mac}" fi - if [ "$stream_link" == "$i18n_not_set" ] + if [ "$stream_link" == "$i18n_blank" ] then continue fi diff --git a/src/iptv/edit_schedule b/src/iptv/edit_schedule index 36b3af0..824f094 100644 --- a/src/iptv/edit_schedule +++ b/src/iptv/edit_schedule @@ -23,9 +23,9 @@ EditChannelSchedule() JQ update "$CHANNELS_FILE" "$schedule_end_time" elif [ "$channel_schedule_options_index" -eq 2 ] then - inquirer list_input_index "每日循环" ny_options ny_options_index + inquirer list_input_index "每日循环" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_loop=false else @@ -37,9 +37,9 @@ EditChannelSchedule() JQ update "$CHANNELS_FILE" "$schedule_loop" elif [ "$channel_schedule_options_index" -eq 3 ] then - inquirer list_input_index "自动清除" ny_options ny_options_index + inquirer list_input_index "自动清除" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then schedule_auto_remove=false else @@ -51,16 +51,16 @@ EditChannelSchedule() JQ update "$CHANNELS_FILE" "$schedule_auto_remove" elif [ "$channel_schedule_options_index" -eq 4 ] then - inquirer list_input_index "防盗链" yn_options yn_options_index + inquirer list_input_index "防盗链" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change=true echo - inquirer list_input_index "防盗链一次" ny_options yn_options_index + inquirer list_input_index "防盗链一次" ny_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then schedule_hls_change_once=false else @@ -80,9 +80,9 @@ EditChannelSchedule() JQ update "$CHANNELS_FILE" "$schedule_hls_change_once" elif [ "$channel_schedule_options_index" -eq 5 ] then - inquirer text_input "输入频道名称" schedule_channel_name "$i18n_not_set" + inquirer text_input "输入频道名称" schedule_channel_name "$i18n_blank" - if [ "$schedule_channel_name" == "$i18n_not_set" ] + if [ "$schedule_channel_name" == "$i18n_blank" ] then schedule_channel_name="" fi @@ -93,9 +93,9 @@ EditChannelSchedule() if [ -n "$schedule_channel_name" ] && [ "${chnl_schedules_status[chnl_schedules_index]}" -eq 1 ] && [ "$schedule_channel_name" != "${chnls_channel_name[chnls_index]}" ] then echo - inquirer list_input_index "同步频道名称" ny_options ny_options_index + inquirer list_input_index "同步频道名称" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then jq_path='["channels",'"$chnls_index"',"channel_name"]' JQ update "$CHANNELS_FILE" "$schedule_channel_name" diff --git a/src/iptv/get_default b/src/iptv/get_default index 8936a82..8fa427e 100644 --- a/src/iptv/get_default +++ b/src/iptv/get_default @@ -50,7 +50,7 @@ GetDefault() d_audio_shift=${d_video_audio_shift#*_} d_video_audio_shift_text=$(eval_gettext "声音延迟 \$d_audio_shift 秒") else - d_video_audio_shift_text=$i18n_not_set + d_video_audio_shift_text=$i18n_blank fi d_const_cbr=${d_const_cbr:-false} @@ -82,7 +82,7 @@ GetDefault() if [ "$d_recheck_period" -eq 0 ] then - d_recheck_period_text=$i18n_not_set + d_recheck_period_text=$i18n_blank else d_recheck_period_text="$d_recheck_period" fi diff --git a/src/iptv/list_channel b/src/iptv/list_channel index debee5d..ba4b812 100644 --- a/src/iptv/list_channel +++ b/src/iptv/list_channel @@ -27,7 +27,7 @@ ListChannel() then chnl_seg_dir_name_text="${green}$chnl_seg_dir_name${normal}" else - chnl_seg_dir_name_text="${red}$i18n_not_set${normal}" + chnl_seg_dir_name_text="${red}$i18n_blank${normal}" fi if [ "$v_or_a" == "v" ] @@ -37,7 +37,7 @@ ListChannel() then chnl_video_audio_shift_text="${green}$i18n_audio_shift $chnl_audio_shift($i18n_seconds)${normal}" else - chnl_video_audio_shift_text="${green}$i18n_not_set${normal}" + chnl_video_audio_shift_text="${green}$i18n_blank${normal}" fi if [ "$chnl_encrypt" = false ] @@ -223,8 +223,8 @@ ListChannel() [ -n "$chnl_video_quality_text" ] && printf '%b' "$chnl_video_quality_text" - printf " %s${indent_20}${green}%s${normal}\n" "$i18n_input_flags" "${chnl_input_flags:-$i18n_not_set}" - printf " %s${indent_20}${green}%s${normal}\n" "$i18n_output_flags" "${chnl_output_flags:-$i18n_not_set}" + printf " %s${indent_20}${green}%s${normal}\n" "$i18n_input_flags" "${chnl_input_flags:-$i18n_blank}" + printf " %s${indent_20}${green}%s${normal}\n" "$i18n_output_flags" "${chnl_output_flags:-$i18n_blank}" printf ' %b' "EXT-X-ENDLIST${indent_20}$chnl_hls_end_list_text\n" printf ' %b' "sync${indent_20}$chnl_sync_text\n" diff --git a/src/iptv/list_channels b/src/iptv/list_channels index 2c67f93..08978ac 100644 --- a/src/iptv/list_channels +++ b/src/iptv/list_channels @@ -32,7 +32,7 @@ ListChannels() chnls_audio_shift=${chnls_video_audio_shift[chnls_index]#*_} chnls_video_audio_shift_text="$i18n_audio_shift $chnls_audio_shift($i18n_seconds)" else - chnls_video_audio_shift_text="$i18n_not_set" + chnls_video_audio_shift_text="$i18n_blank" fi IFS=, read -r -a chnl_qualities <<< "${chnls_quality[chnls_index]}" diff --git a/src/iptv/menu_edit_channel b/src/iptv/menu_edit_channel index ad49876..b239db0 100644 --- a/src/iptv/menu_edit_channel +++ b/src/iptv/menu_edit_channel @@ -107,9 +107,9 @@ EditChannelMenu() echo if [ "$chnl_status" == "on" ] || [ "$chnl_flv_status" == "on" ] then - inquirer list_input_index "重启频道" ny_options ny_options_index + inquirer list_input_index "重启频道" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then Println "不重启...\n" else @@ -123,9 +123,9 @@ EditChannelMenu() StartChannel fi else - inquirer list_input_index "启动频道" ny_options ny_options_index + inquirer list_input_index "启动频道" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then Println "不启动...\n" else diff --git a/src/iptv/menu_ts b/src/iptv/menu_ts index f5fa69e..2f10681 100644 --- a/src/iptv/menu_ts +++ b/src/iptv/menu_ts @@ -841,16 +841,16 @@ do fi echo - inquirer list_input_index "添加频道 ${chnl_name[chnl_index]}" yn_options yn_options_index + inquirer list_input_index "添加频道 ${chnl_name[chnl_index]}" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then stream_links=("$stream_link|$id|$user_name") echo - inquirer list_input_index "是否 添加/替换 现有频道直播源" ny_options ny_options_index + inquirer list_input_index "是否 添加/替换 现有频道直播源" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then ListChannels InputChannelsIndex @@ -883,9 +883,9 @@ do done else echo - inquirer list_input_index "是否推流 flv" ny_options ny_options_index + inquirer list_input_index "是否推流 flv" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then kind="flv" fi diff --git a/src/iptv/parse_stream b/src/iptv/parse_stream index e1a7d3c..308e786 100644 --- a/src/iptv/parse_stream +++ b/src/iptv/parse_stream @@ -345,10 +345,10 @@ ParseStream() fi Println "$info 使用输入源 ${stream_links[0]}" - inquirer list_input_index "自动检测" yn_options yn_options_index + inquirer list_input_index "自动检测" yn_options yn_index fi - if [ "${stream_link_parsed:-false}" = true ] || [ "$yn_options_index" -eq 0 ] + if [ "${stream_link_parsed:-false}" = true ] || [ "$yn_index" -eq 0 ] then Println "$info 检测中..." @@ -429,9 +429,9 @@ ParseStream() is_hls=true Println "$tip 输入源是多级索引列表的情况下可以选择是" - inquirer list_input_index "解析 hls 一级索引列表" ny_options ny_options_index + inquirer list_input_index "解析 hls 一级索引列表" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then if ParseHlsPlaylist then @@ -706,9 +706,9 @@ ParseStream() if [ "$is_hls" = true ] then Println "$tip 输入源是多级索引列表的情况下可以选择是" - inquirer list_input_index "解析 hls 一级索引列表" ny_options ny_options_index + inquirer list_input_index "解析 hls 一级索引列表" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then if ParseHlsPlaylist then diff --git a/src/iptv/set_stream b/src/iptv/set_stream index c2d3c72..4a3b770 100644 --- a/src/iptv/set_stream +++ b/src/iptv/set_stream @@ -16,9 +16,9 @@ SetStreamLink() SetIsHls() { Println "$tip 如果直播源重定向至 .m3u8 地址, 请选择 是" - inquirer list_input_index "是否是 HLS 链接" ny_options ny_options_index + inquirer list_input_index "是否是 HLS 链接" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then is_hls=false else @@ -33,7 +33,7 @@ SetMapValidate() for map in "${maps[@]}" do case "$map" in - "$i18n_not_set") + "$i18n_blank") indices_input="" return 0 ;; @@ -53,7 +53,7 @@ SetMapValidate() SetVideoMap() { Println "$tip 多个流用空格分隔" - inquirer text_input "输入使用的视频流序号" indices_input "$i18n_not_set" SetMapValidate "必须是大于等于0的数字" + inquirer text_input "输入使用的视频流序号" indices_input "$i18n_blank" SetMapValidate "必须是大于等于0的数字" if [ -n "${indices_input:-}" ] then @@ -66,7 +66,7 @@ SetVideoMap() SetAudioMap() { Println "$tip 多个流用空格分隔" - inquirer text_input "输入使用的音频流序号" indices_input "$i18n_not_set" SetMapValidate "必须是大于等于0的数字" + inquirer text_input "输入使用的音频流序号" indices_input "$i18n_blank" SetMapValidate "必须是大于等于0的数字" if [ -n "${indices_input:-}" ] then @@ -79,7 +79,7 @@ SetAudioMap() SetSubtitleMap() { Println "$tip 多个流用空格分隔" - inquirer text_input "输入使用的字幕流序号" indices_input "$i18n_not_set" SetMapValidate "必须是大于等于0的数字" + inquirer text_input "输入使用的字幕流序号" indices_input "$i18n_blank" SetMapValidate "必须是大于等于0的数字" if [ -n "${indices_input:-}" ] then @@ -97,17 +97,17 @@ SetSubtitle() while true do Println "$tip 比如 简体中文" - inquirer text_input "新增字幕语言名称" subtitle_name "$i18n_not_set" + inquirer text_input "新增字幕语言名称" subtitle_name "$i18n_blank" - if [ "$subtitle_name" == "$i18n_not_set" ] + if [ "$subtitle_name" == "$i18n_blank" ] then break fi Println "$tip 比如 chi" - inquirer text_input "设置字幕语言标识" subtitle_language "$i18n_not_set" + inquirer text_input "设置字幕语言标识" subtitle_language "$i18n_blank" - if [ "$subtitle_language" == "$i18n_not_set" ] + if [ "$subtitle_language" == "$i18n_blank" ] then subtitle_language="" fi @@ -117,9 +117,9 @@ SetSubtitle() subtitle_default=false echo - inquirer list_input_index "自动选择字幕 $subtitle_name" yn_options yn_options_index + inquirer list_input_index "自动选择字幕 $subtitle_name" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then subtitle_auto_select=true else @@ -127,9 +127,9 @@ SetSubtitle() fi else echo - inquirer list_input_index "默认并自动选择字幕 $subtitle_name" ny_options ny_options_index + inquirer list_input_index "默认并自动选择字幕 $subtitle_name" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then subtitle_default=true subtitle_auto_select=true @@ -137,9 +137,9 @@ SetSubtitle() subtitle_default=false echo - inquirer list_input_index "自动选择字幕 $subtitle_name" yn_options yn_options_index + inquirer list_input_index "自动选择字幕 $subtitle_name" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then subtitle_auto_select=true else @@ -186,8 +186,8 @@ SetSubtitle() SetDrawtext() { Println "$tip 比如 fontsize=25:fontfile=/usr/local/iptv/AlibabaSans-Regular.otf:fontcolor=white:box=1:boxcolor=black@0.5:x=50:y=10:text=yourdomain.com" - inquirer text_input "输入 drawtext 水印 : " draw_text "${d_draw_text:-$i18n_not_set}" - if [ "$draw_text" == "omit" ] || [ "$draw_text" == "$i18n_not_set" ] + inquirer text_input "输入 drawtext 水印 : " draw_text "${d_draw_text:-$i18n_blank}" + if [ "$draw_text" == "omit" ] || [ "$draw_text" == "$i18n_blank" ] then draw_text="" fi @@ -202,9 +202,9 @@ SetLive() Println "$tip 选择 否 则无法监控" fi - inquirer list_input_index "是否是无限时长直播源" yn_options yn_options_index + inquirer list_input_index "是否是无限时长直播源" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then live=true else @@ -222,9 +222,9 @@ SetProxy() fi Println "$tip 可以使用脚本自带的 v2ray 管理面板添加代理, 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg 代理, 比如 http://username:passsword@127.0.0.1:5555 : " proxy "${d_proxy:-$i18n_not_set}" + inquirer text_input "请输入 FFmpeg 代理, 比如 http://username:passsword@127.0.0.1:5555 : " proxy "${d_proxy:-$i18n_blank}" - if [ "$proxy" == "omit" ] || [ "$proxy" == "$i18n_not_set" ] + if [ "$proxy" == "omit" ] || [ "$proxy" == "$i18n_blank" ] then proxy="" fi @@ -240,9 +240,9 @@ SetXtreamCodesProxy() fi Println "$tip 可以使用脚本自带的 cloudflare workers 管理面板添加 xtream codes 代理 worker, 可以输入 omit 省略此选项" - inquirer text_input "请输入 xtream codes 代理: " xc_proxy "${d_xc_proxy:-$i18n_not_set}" + inquirer text_input "请输入 xtream codes 代理: " xc_proxy "${d_xc_proxy:-$i18n_blank}" - if [ "$xc_proxy" == "omit" ] || [ "$xc_proxy" == "$i18n_not_set" ] + if [ "$xc_proxy" == "omit" ] || [ "$xc_proxy" == "$i18n_blank" ] then xc_proxy="" fi @@ -252,14 +252,14 @@ SetUserAgent() { if [ "${stream_link_parsed:-false}" = true ] then - Println " FFmpeg UA: ${green} ${user_agent:-$i18n_not_set} ${normal}\n" + Println " FFmpeg UA: ${green} ${user_agent:-$i18n_blank} ${normal}\n" return 0 fi Println "$tip 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg 的 user agent: " user_agent "${d_user_agent:-$i18n_not_set}" + inquirer text_input "请输入 FFmpeg 的 user agent: " user_agent "${d_user_agent:-$i18n_blank}" - if [ "$user_agent" == "omit" ] || [ "$user_agent" == "$i18n_not_set" ] + if [ "$user_agent" == "omit" ] || [ "$user_agent" == "$i18n_blank" ] then user_agent="" fi @@ -269,14 +269,14 @@ SetHeaders() { if [ "${stream_link_parsed:-false}" = true ] then - Println " FFmpeg headers: ${green} ${headers:-$i18n_not_set} ${normal}\n" + Println " FFmpeg headers: ${green} ${headers:-$i18n_blank} ${normal}\n" return 0 fi Println "$tip 多个 header 用 \\\r\\\n 分隔, 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg headers: " headers "${d_headers:-$i18n_not_set}" + inquirer text_input "请输入 FFmpeg headers: " headers "${d_headers:-$i18n_blank}" - if [ "$headers" == "omit" ] || [ "$headers" == "$i18n_not_set" ] + if [ "$headers" == "omit" ] || [ "$headers" == "$i18n_blank" ] then headers="" fi @@ -296,14 +296,14 @@ SetCookies() { if [ "${stream_link_parsed:-false}" = true ] then - Println " FFmpeg cookies: ${green} ${cookies:-$i18n_not_set} ${normal}\n" + Println " FFmpeg cookies: ${green} ${cookies:-$i18n_blank} ${normal}\n" return 0 fi Println "$tip 多个 cookies 用 ; 分隔, 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg cookies: " cookies "${d_cookies:-$i18n_not_set}" + inquirer text_input "请输入 FFmpeg cookies: " cookies "${d_cookies:-$i18n_blank}" - if [ "$cookies" == "omit" ] || [ "$cookies" == "$i18n_not_set" ] + if [ "$cookies" == "omit" ] || [ "$cookies" == "$i18n_blank" ] then cookies="" fi @@ -351,9 +351,9 @@ SetPlaylistName() SetSegDirName() { Println "$tip 可以输入 omit 省略此选项" - inquirer text_input "请输入分片所在子目录名称: " seg_dir_name "${d_seg_dir_name:-$i18n_not_set}" + inquirer text_input "请输入分片所在子目录名称: " seg_dir_name "${d_seg_dir_name:-$i18n_blank}" - if [ "$seg_dir_name" == "omit" ] || [ "$seg_dir_name" == "$i18n_not_set" ] + if [ "$seg_dir_name" == "omit" ] || [ "$seg_dir_name" == "$i18n_blank" ] then seg_dir_name="" fi @@ -460,7 +460,7 @@ SetAudioCodec() SetVideoAudioShift() { - if [ "$d_video_audio_shift_text" == "$i18n_not_set" ] + if [ "$d_video_audio_shift_text" == "$i18n_blank" ] then video_audio_shift_options=( "$d_video_audio_shift_text" '设置 画面延迟' '设置 声音延迟' ) else @@ -474,7 +474,7 @@ SetVideoAudioShift() case $video_audio_shift_options_index in 0) - if [ "$d_video_audio_shift_text" != "$i18n_not_set" ] + if [ "$d_video_audio_shift_text" != "$i18n_blank" ] then if [ -n "${d_video_shift:-}" ] then @@ -513,7 +513,7 @@ SetVideoAudioShift() ;; 3) video_audio_shift="" - video_audio_shift_text="$i18n_not_set" + video_audio_shift_text="$i18n_blank" break ;; esac @@ -527,9 +527,9 @@ SetQuality() Println "$tip 多个 crf 固定码率因子用逗号分隔, 取值每 +/- 6 会大概导致码率的减半或加倍\nx264 和 x265 取值范围为 [0,51]\nx264 的默认值是 23, 视觉无损值 18\nx265 的默认值是 28, 视觉无损值 24\nVP9 取值范围为 [0,63], 建议取值范围为 [15,35]" while true do - inquirer text_input "请输入 crf 值: " quality "${d_quality:-$i18n_not_set}" + inquirer text_input "请输入 crf 值: " quality "${d_quality:-$i18n_blank}" case "$quality" in - "$i18n_not_set") + "$i18n_blank") quality="" break ;; @@ -552,9 +552,9 @@ SetBitrate() { Println "$tip 如果未设置 crf, 用于指定输出视频码率(ABR 或 CBR), 否则用于 VBV 的 -maxrate 和 -bufsize (capped CRF)\n多个码率(k)用逗号分隔, 比如: 800,1000,1500 可以输入 omit 省略此选项" - inquirer text_input "请输入码率: " bitrate "${d_bitrate:-$i18n_not_set}" + inquirer text_input "请输入码率: " bitrate "${d_bitrate:-$i18n_blank}" - if [ "$bitrate" == "omit" ] || [ "$bitrate" == "$i18n_not_set" ] + if [ "$bitrate" == "omit" ] || [ "$bitrate" == "$i18n_blank" ] then bitrate="" fi @@ -564,9 +564,9 @@ SetResolution() { Println "$tip 多个分辨率用逗号分隔, 比如: 960x540,1280x720 可以输入 omit 省略此选项" - inquirer text_input "请输入分辨率: " resolution "${d_resolution:-$i18n_not_set}" + inquirer text_input "请输入分辨率: " resolution "${d_resolution:-$i18n_blank}" - if [ "$resolution" == "omit" ] || [ "$resolution" == "$i18n_not_set" ] + if [ "$resolution" == "omit" ] || [ "$resolution" == "$i18n_blank" ] then resolution="" fi @@ -574,7 +574,7 @@ SetResolution() SetConst() { - const_options=( "$i18n_not_set" '限制性编码(VBV)' ) + const_options=( "$i18n_blank" '限制性编码(VBV)' ) if [ -z "${quality:-}" ] then @@ -771,9 +771,9 @@ SetInputFlags() fi Println "$tip 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg 额外的输入参数: " input_flags "${d_input_flags:-$i18n_not_set}" + inquirer text_input "请输入 FFmpeg 额外的输入参数: " input_flags "${d_input_flags:-$i18n_blank}" - if [ "$input_flags" == "omit" ] || [ "$input_flags" == "$i18n_not_set" ] + if [ "$input_flags" == "omit" ] || [ "$input_flags" == "$i18n_blank" ] then input_flags="" fi @@ -786,8 +786,8 @@ SetOutputFlags() d_output_flags=${d_output_flags//-sc_threshold 0/} fi Println "$tip 可以输入 omit 省略此选项" - inquirer text_input "请输入 FFmpeg 额外的输出参数: " output_flags "${d_output_flags:-$i18n_not_set}" - if [ "$output_flags" == "omit" ] || [ "$output_flags" == "$i18n_not_set" ] + inquirer text_input "请输入 FFmpeg 额外的输出参数: " output_flags "${d_output_flags:-$i18n_blank}" + if [ "$output_flags" == "omit" ] || [ "$output_flags" == "$i18n_blank" ] then output_flags="" fi @@ -829,9 +829,9 @@ SetSync() SetSyncFile() { Println "$tip 多个文件用空格分隔, 可以输入 omit 省略此选项" - inquirer text_input "设置默认 sync_file: " sync_file "${d_sync_file:-$i18n_not_set}" + inquirer text_input "设置默认 sync_file: " sync_file "${d_sync_file:-$i18n_blank}" - if [ "$sync_file" == "omit" ] || [ "$sync_file" == "${d_sync_file:-$i18n_not_set}" ] + if [ "$sync_file" == "omit" ] || [ "$sync_file" == "${d_sync_file:-$i18n_blank}" ] then sync_file="" fi @@ -840,9 +840,9 @@ SetSyncFile() SetSyncIndex() { Println "$tip 多个 sync_index 用空格分隔, 可以输入 omit 省略此选项" - inquirer text_input "设置默认 sync_index: " sync_index "${d_sync_index:-$i18n_not_set}" + inquirer text_input "设置默认 sync_index: " sync_index "${d_sync_index:-$i18n_blank}" - if [ "$sync_index" == "omit" ] || [ "$sync_index" == "${d_sync_index:-$i18n_not_set}" ] + if [ "$sync_index" == "omit" ] || [ "$sync_index" == "${d_sync_index:-$i18n_blank}" ] then sync_index="" fi @@ -851,9 +851,9 @@ SetSyncIndex() SetSyncPairs() { Println "$tip 多个 sync_pairs 用空格分隔, 可以输入 omit 省略此选项" - inquirer text_input "设置默认 sync_pairs: " sync_pairs "${d_sync_pairs:-$i18n_not_set}" + inquirer text_input "设置默认 sync_pairs: " sync_pairs "${d_sync_pairs:-$i18n_blank}" - if [ "$sync_pairs" == "omit" ] || [ "$sync_pairs" == "${d_sync_pairs:-$i18n_not_set}" ] + if [ "$sync_pairs" == "omit" ] || [ "$sync_pairs" == "${d_sync_pairs:-$i18n_blank}" ] then sync_pairs="" fi @@ -862,8 +862,8 @@ SetSyncPairs() SetScheduleFile() { Println "$tip 可以输入 omit 省略此选项" - inquirer text_input "设置节目表文件绝对路径: " schedule_file "${d_schedule_file:-$i18n_not_set}" - if [ "$schedule_file" == "omit" ] || [ "$schedule_file" == "$i18n_not_set" ] + inquirer text_input "设置节目表文件绝对路径: " schedule_file "${d_schedule_file:-$i18n_blank}" + if [ "$schedule_file" == "omit" ] || [ "$schedule_file" == "$i18n_blank" ] then schedule_file="" fi @@ -1345,8 +1345,8 @@ SetRecheckPeriod() SetFlvH265() { echo - inquirer list_input_index "是否推流 h265" ny_options ny_options_index - if [ "$ny_options_index" -eq 0 ] + inquirer list_input_index "是否推流 h265" ny_options ny_index + if [ "$ny_index" -eq 0 ] then flv_h265=false else @@ -1406,8 +1406,8 @@ SetFlvPullLink() d_flv_pull_link="http://127.0.0.1/flv?app=flv&stream=${chnl_flv_push_link##*/}" fi Println "$tip 比如 http://domain.com/flv?app=flv&stream=xxx 监控会验证此链接来确定是否重启频道, 如果不确定可以先留空, 可以输入 omit 省略此选项" - inquirer text_input "请输入拉流(播放)地址: " flv_pull_link "${d_flv_pull_link:-$i18n_not_set}" - if [ "$flv_pull_link" == "omit" ] || [ "$flv_pull_link" == "$i18n_not_set" ] + inquirer text_input "请输入拉流(播放)地址: " flv_pull_link "${d_flv_pull_link:-$i18n_blank}" + if [ "$flv_pull_link" == "omit" ] || [ "$flv_pull_link" == "$i18n_blank" ] then flv_pull_link="" fi diff --git a/src/iptv/start_channel b/src/iptv/start_channel index 85ebb66..786cdbe 100644 --- a/src/iptv/start_channel +++ b/src/iptv/start_channel @@ -635,9 +635,9 @@ StartChannel() then choose_asked=true echo - inquirer list_input_index "是否按分辨率自动选择" yn_options yn_options_index + inquirer list_input_index "是否按分辨率自动选择" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then i=$((i-1)) continue diff --git a/src/iptv/start_monitor b/src/iptv/start_monitor index 395e5e9..ac5beb6 100644 --- a/src/iptv/start_monitor +++ b/src/iptv/start_monitor @@ -16,9 +16,9 @@ MonitorStart() nginx_ctl="nx" else echo - inquirer list_input_index "没有检测到运行的 nginx, 是否使用 openresty" yn_options yn_options_index + inquirer list_input_index "没有检测到运行的 nginx, 是否使用 openresty" yn_options yn_index - if [ "$yn_options_index" -eq 0 ] + if [ "$yn_index" -eq 0 ] then nginx_prefix="/usr/local/openresty/nginx" nginx_name="openresty" diff --git a/src/lhh b/src/lhh index 933ad90..3b0e5d6 100644 --- a/src/lhh +++ b/src/lhh @@ -1104,13 +1104,234 @@ reduce ({id,behot_time,title}|keys_unsorted[]) as $key ([]; done } +DangValidateId() +{ + if [ "$1" == "$i18n_cancel" ] + then + return 0 + fi + + book_id=${1##*/} + book_id=${book_id%%_*} + + if [ "$books_total" -gt 0 ] + then + local id + for id in "${books_id[@]}" + do + if [ "$id" == "$book_id" ] + then + return 1 + fi + done + fi + + return 0 +} + +DangValidateStartPage() +{ + if [ "$1" == "$i18n_cancel" ] || [[ $1 =~ ^[0-9]+$ ]] + then + return 0 + fi + + return 1 +} + +DangValidateEndPage() +{ + if [ "$1" == "$i18n_cancel" ] || { [[ $1 =~ ^[0-9]+$ ]] && [ "$1" -ge "$book_start" ]; } + then + return 0 + fi + + return 1 +} + +DangCloudDownload() +{ + echo + inquirer text_input "输入存储文件夹目录" save_dir "${default_save_dir}" + RemoveQuotes save_dir + + if [ -z "$save_dir" ] + then + Println "已取消...\n" + return 1 + fi + + if [ "$save_dir" != "$default_save_dir" ] + then + jq_path='["default","save_dir"]' + JQ update "$LIANHUANHUA_CONFIG" "$save_dir" + fi + + local book_path="$save_dir/${book_title//\//_}" + local book_images_count=$((book_end-book_start+1)) + + local i=2 + until [ ! -d "$book_path" ] + do + if [ "$i" -gt 2 ] + then + book_path="${book_path%-*}" + fi + book_path="${book_path}-$i" + i=$((i+1)) + done + + mkdir -p "$book_path" + + book_image_format_num=${#book_end} + book_image_formated=$(printf "%0${book_image_format_num}d" $book_start) + LhhDownload -s -L -A "$USER_AGENT_BROWSER" -o "$book_path/${book_image_formated}.jpg" "${book_img%/*}/${book_id}_cover_epub.jpg" + + book_image_formated=$(printf "%0${book_image_format_num}d" $((book_start+1))) + LhhDownload -s -L -A "$USER_AGENT_BROWSER" -o "$book_path/${book_image_formated}.jpg" "${book_img%/*}/${book_id}_F001_epub.jpg" + + book_image_formated=$(printf "%0${book_image_format_num}d" $((book_start+2))) + LhhDownload -s -L -A "$USER_AGENT_BROWSER" -o "$book_path/${book_image_formated}.jpg" "${book_img%/*}/${book_id}_F002_epub.jpg" + + for((i=0;i "$LIANHUANHUA_CONFIG" + fi + + SetDelimiters + +IFS=$'\003\t' read -r default_save_dir m_id m_title m_cover m_start m_end m_downloaded m_fav < <(JQs flat "$LIANHUANHUA_CONFIG" '' \ +'(.default // ""| if (.|type == "string") then {} else . end) as $default | +(.books.dang | if . == "" then {} else . end) as $dang | +reduce ({save_dir}|keys_unsorted[]) as $key ([]; + $default[$key] as $val | if $val then + . + [$val + "\u0003"] + else + . + ["\u0003"] + end +) + +reduce ({id,title,cover,start,end,downloaded,fav}|keys_unsorted[]) as $key ([]; + $dang[$key] as $val | if $val then + . + [$val + "\u0002\u0003"] + else + . + ["\u0003"] + end + ) +|@tsv' "${delimiters[@]}") + + IFS="${delimiters[1]}" read -r -a books_id <<< "$m_id" + IFS="${delimiters[1]}" read -r -a books_title <<< "$m_title" + IFS="${delimiters[1]}" read -r -a books_cover <<< "$m_cover" + IFS="${delimiters[1]}" read -r -a books_start <<< "$m_start" + IFS="${delimiters[1]}" read -r -a books_end <<< "$m_end" + IFS="${delimiters[1]}" read -r -a books_downloaded <<< "$m_downloaded" + IFS="${delimiters[1]}" read -r -a books_fav <<< "$m_fav" + + local books_total=${#books_id[@]} + + dang_options_index=0 + + if [ "$books_total" -gt 0 ] + then + echo + dang_options=( '添加' '选择' ) + inquirer list_input_index "请选择操作" dang_options dang_options_index + fi + + if [ "$dang_options_index" -eq 0 ] + then + echo + ExitOnText "输入书名" book_title + + Println "$tip 比如 https://img7x6.ddimg.cn/imgother10/xx/xx/xxxxxxxxxx_cover_epub.jpg" + ExitOnText "输入图片链接" book_img DangValidateId "此书已经存在" + + book_id=${book_img##*/} + book_id=${book_id%%_*} + + echo + ExitOnText "输入起始页码" book_start DangValidateStartPage "请输入数字" + + echo + ExitOnText "输入结束页码" book_end DangValidateEndPage "请输入数字且不能小于起始页码" + + echo + inquirer list_input_index "收藏" ny_options ny_index + + if [ "$ny_index" -eq 0 ] + then + book_fav=false + else + book_fav=true + fi + + echo + inquirer list_input_index "下载" ny_options ny_index + + if [ "$ny_index" -eq 0 ] + then + book_downloaded=false + else + DangCloudDownload + book_downloaded=true + fi + + new_book=$( + $JQ_FILE -n --arg id "${book_id}" --arg title "$book_title" \ + --arg cover "${book_img%/*}/${book_id}_cover_epub.jpg" --arg start "$book_start" \ + --arg end "$book_end" --arg downloaded "$book_downloaded" \ + --arg fav "$book_fav" \ + '{ + id: $id | tonumber, + title: $title, + cover: $cover, + start: $start | tonumber, + end: $end | tonumber, + downloaded: $downloaded | test("true"), + fav: $fav | test("true") + }' + ) + + jq_path='["books","dang"]' + JQ add "$LIANHUANHUA_CONFIG" "[$new_book]" + + Println "$info ${book_title} 添加成功\n" + fi + + echo + +} + echo -lhh_options=( '中华连环画' '瀚大黎众连环画' ) +lhh_options=( '中华连环画' '瀚大黎众连环画' '当当云阅读(漫画)' ) inquirer list_input_index "选择连环画" lhh_options lhh_options_index -if [ "$lhh_options_index" -eq 0 ] -then - ZhLhh -else - HdlzLhh -fi +case $lhh_options_index in + 0) ZhLhh + ;; + 1) HdlzLhh + ;; + 2) DangCloud + ;; +esac + +return 0 diff --git a/src/nginx/check_acme b/src/nginx/check_acme index 17fbbf0..ac002ee 100644 --- a/src/nginx/check_acme +++ b/src/nginx/check_acme @@ -5,14 +5,17 @@ AcmeCheck() if [ ! -f "$HOME/.acme.sh/acme.sh" ] then DepInstall socat - { curl -s -m 10 https://get.acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ + mkdir -p "$DEPENDS_ROOT" + { curl -s -m 20 https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh || curl -s -m 20 "$FFMPEG_MIRROR_LINK/acme.sh"; } \ | sed "s+https://raw.githubusercontent.com/acmesh-official+$FFMPEG_MIRROR_LINK/acmesh-content+g" \ - | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" | bash + | sed "s+| sh+| sed 's~PROJECT=\"https://github.com/acmesh-official~PROJECT=\"$FFMPEG_MIRROR_LINK/acmesh-project~' | sed 's~https://api.github.com~$FFMPEG_MIRROR_LINK/acmesh-api~g' | sh+g" > "$DEPENDS_ROOT"/acme.sh + cd "$DEPENDS_ROOT" + bash acme.sh --install else echo - inquirer list_input_index "更新 acme.sh" ny_options ny_options_index + inquirer list_input_index "更新 acme.sh" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then ~/.acme.sh/acme.sh --upgrade fi diff --git a/src/nginx/input_args b/src/nginx/input_args index c5a2394..00218a0 100644 --- a/src/nginx/input_args +++ b/src/nginx/input_args @@ -4,9 +4,9 @@ NginxInputArgs() while true do Println "$tip 空字符用 '' 表示" - inquirer text_input "输入单个指令值: " arg "$i18n_not_set" + inquirer text_input "输入单个指令值: " arg "$i18n_blank" - if [ "$arg" == "$i18n_not_set" ] + if [ "$arg" == "$i18n_blank" ] then break fi diff --git a/src/nginx/install b/src/nginx/install index c65f13e..b958d08 100644 --- a/src/nginx/install +++ b/src/nginx/install @@ -451,7 +451,6 @@ NginxSourceInstall() nproc="-j$(nproc 2> /dev/null)" || nproc="-j1" - make clean make $nproc make install diff --git a/src/nx b/src/nx index 0d0db41..991ef5b 100644 --- a/src/nx +++ b/src/nx @@ -11,6 +11,7 @@ Include utils/iperf "$@" Include utils/swap "$@" Include utils/quictls "$@" Include utils/build "$@" +Include utils/vim "$@" Include src/nginx/view_status "$@" Include src/nginx/toggle "$@" Include src/nginx/restart "$@" diff --git a/src/openresty/install b/src/openresty/install index 216e500..7e63d23 100644 --- a/src/openresty/install +++ b/src/openresty/install @@ -383,8 +383,6 @@ OpenrestySourceInstall() cp -r ${openssl_name} ${openssl_name}-patched cd ${openssl_name}-patched - make clean - curl -L "$FFMPEG_MIRROR_LINK/openssl-1.1.1f-sess_set_get_cb_yield.patch" -o openssl-1.1.1f-sess_set_get_cb_yield.patch patch -p1 < openssl-1.1.1f-sess_set_get_cb_yield.patch || true cd "$DEPENDS_ROOT" @@ -438,7 +436,6 @@ OpenrestySourceInstall() nproc="-j$(nproc 2> /dev/null)" || nproc="-j1" - make clean make $nproc make install diff --git a/src/pve b/src/pve index fd62054..9a39054 100644 --- a/src/pve +++ b/src/pve @@ -659,8 +659,8 @@ case $pve_num in PveSelectVM Println "$tip 请确保已经安装过 openwrt-v2ray" - inquirer text_input "输入当前配置保存名称: " config_name "$i18n_not_set" - if [ "$config_name" == "$i18n_not_set" ] + inquirer text_input "输入当前配置保存名称: " config_name "$i18n_blank" + if [ "$config_name" == "$i18n_blank" ] then config_name="" else diff --git a/src/rc b/src/rc index 984a220..2efab0c 100644 --- a/src/rc +++ b/src/rc @@ -106,6 +106,7 @@ case $rclone_options_index in esac ;; 5) + DepInstall rsync if [[ -x $(command -v rclone) ]] then rclone selfupdate diff --git a/src/rclone/serve b/src/rclone/serve index fcad801..8d3e216 100644 --- a/src/rclone/serve +++ b/src/rclone/serve @@ -94,9 +94,9 @@ RcloneServeAdd() done echo - inquirer text_input "输入服务参数" rclone_serve_args "$i18n_not_set" + inquirer text_input "输入服务参数" rclone_serve_args "$i18n_blank" - if [ "$rclone_serve_args" == "$i18n_not_set" ] + if [ "$rclone_serve_args" == "$i18n_blank" ] then rclone_serve_args="" fi @@ -203,8 +203,8 @@ RcloneServeEdit() ;; 3) echo - inquirer text_input "输入服务参数" rclone_serve_args "${rclone_serves_args[rclone_serves_index]:-$i18n_not_set}" - if [ "$rclone_serve_args" == "${rclone_serves_args[rclone_serves_index]:-$i18n_not_set}" ] + inquirer text_input "输入服务参数" rclone_serve_args "${rclone_serves_args[rclone_serves_index]:-$i18n_blank}" + if [ "$rclone_serve_args" == "${rclone_serves_args[rclone_serves_index]:-$i18n_blank}" ] then continue fi diff --git a/src/rclone/sync b/src/rclone/sync index 5d5b6f7..074def0 100644 --- a/src/rclone/sync +++ b/src/rclone/sync @@ -137,16 +137,16 @@ RcloneSyncAdd() ExitOnText "输入同步的本地目录" rclone_sync_target RcloneSyncLocalValidator "路径错误" RemoveQuotes rclone_sync_target else - rclone_sync_target="${rclone_sync_target_options[rclone_sync_target_options_index-1]}" + rclone_sync_target="${rclone_sync_target_options[rclone_sync_target_options_index]}" echo ExitOnText "输入同步目标 $rclone_sync_target 的路径" rclone_sync_target_path rclone_sync_target="$rclone_sync_target:$rclone_sync_target_path" fi echo - inquirer text_input "输入同步参数" rclone_sync_args "$i18n_not_set" + inquirer text_input "输入同步参数" rclone_sync_args "$i18n_blank" - if [ "$rclone_sync_args" == "$i18n_not_set" ] + if [ "$rclone_sync_args" == "$i18n_blank" ] then rclone_sync_args="" fi @@ -336,7 +336,7 @@ RcloneSyncEdit() ExitOnText "输入同步的本地目录" rclone_sync_target RcloneSyncLocalValidator "路径错误" RemoveQuotes rclone_sync_target else - rclone_sync_target="${rclone_sync_target_options[rclone_sync_target_options_index-1]}" + rclone_sync_target="${rclone_sync_target_options[rclone_sync_target_options_index]}" echo ExitOnText "输入同步目标 $rclone_sync_target 的路径" rclone_sync_target_path rclone_sync_target="$rclone_sync_target:$rclone_sync_target_path" @@ -351,9 +351,9 @@ RcloneSyncEdit() ;; 2) echo - inquirer text_input "输入同步参数" rclone_sync_args "$i18n_not_set" + inquirer text_input "输入同步参数" rclone_sync_args "$i18n_blank" - if [ "$rclone_sync_args" == "$i18n_not_set" ] + if [ "$rclone_sync_args" == "$i18n_blank" ] then rclone_sync_args="" fi diff --git a/src/service/browse b/src/service/browse index ef0f750..92217ac 100644 --- a/src/service/browse +++ b/src/service/browse @@ -124,8 +124,8 @@ ServiceBrowse() elif [ "${lists_options[list_options_index]}" == "删除" ] then echo - inquirer list_input_index "确认删除" ny_options ny_options_index - if [ "$ny_options_index" -eq 1 ] + inquirer list_input_index "确认删除" ny_options ny_index + if [ "$ny_index" -eq 1 ] then for lists_index in "${lists_indices[@]}" do diff --git a/src/test/inquirer b/src/test/inquirer new file mode 100644 index 0000000..11fde87 --- /dev/null +++ b/src/test/inquirer @@ -0,0 +1,49 @@ +TestInquirerInputValidator() +{ + if [ "$1" == "$i18n_cancel" ] || [[ "$1" =~ ^[0-9]+$ ]] + then + return 0 + fi + + return 1 +} + +TestInquirerInput() +{ + Println "$tip 输入非数字会提示错误" + inquirer text_input "测试输入 validator" user_input "$i18n_cancel" TestInquirerInputValidator "请输入数字" +} + +TestInquirerList() +{ + Println "$tip 选择 是 得 true, 否 得 false" + inquirer list_input_yn "请选择" tf_options tf_result + Println "$info 结果为 $tf_result\n" + + Println "$tip 选择 是 得 0, 否 得 1" + inquirer list_input_ny "请选择" oz_options oz_result + Println "$info 结果为 $oz_result\n" +} + +TestInquirer() +{ + test_inquirer_options=( + '1. 输入非数字会提示错误' + '2. 选择获得正确值' + ) + + test_inquirer_actions=( + TestInquirerInput + TestInquirerList + ) + + echo + inquirer checkbox_input_indices "选择测试项目" test_inquirer_options test_inquirer_options_indices + + for test_inquirer_options_index in "${test_inquirer_options_indices[@]}" + do + ${test_inquirer_actions[test_inquirer_options_index]} + done + + return +} diff --git a/src/tt b/src/tt new file mode 100644 index 0000000..fdc01f4 --- /dev/null +++ b/src/tt @@ -0,0 +1,3 @@ +Include src/test/inquirer + +TestInquirer diff --git a/src/v2 b/src/v2 index 70c4fc4..f427eb9 100644 --- a/src/v2 +++ b/src/v2 @@ -2,8 +2,8 @@ Include utils/imagemagick "$@" Include utils/imgcat "$@" Include src/v2ray/get_free_tag "$@" Include src/v2ray/view_staus "$@" -Include src/v2ray/set_bound "$@" -Include src/v2ray/add_inbound "$@" +Include src/v2ray/inbound "$@" +Include src/v2ray/stream "$@" Include src/v2ray/get_inbounds "$@" Include src/v2ray/list_inbounds "$@" Include src/v2ray/select_inbound "$@" @@ -48,6 +48,7 @@ Include src/v2ray/select_nginx_proxy "$@" Include src/v2ray/list_nginx_domain "$@" Include src/v2ray/config_domain "$@" Include src/v2ray/install "$@" +Include src/v2ray/log "$@" Include src/service/control "$@" ShFileCheck diff --git a/src/v2ray/add_inbound b/src/v2ray/add_inbound index 303a463..1531858 100644 --- a/src/v2ray/add_inbound +++ b/src/v2ray/add_inbound @@ -339,7 +339,7 @@ V2rayAddInbound() V2raySetDetourTo - if [ "$detour_to" != "$i18n_not_set" ] + if [ "$detour_to" != "$i18n_blank" ] then V2raySetDetourDefault new_inbound=$( diff --git a/src/v2ray/inbound b/src/v2ray/inbound new file mode 100644 index 0000000..8ace783 --- /dev/null +++ b/src/v2ray/inbound @@ -0,0 +1,803 @@ +V2rayInboundProtocol() +{ + echo + inbound_protocols=( 'vmess' 'vless' 'vliteu' 'http' 'socks' 'shadowsocks' 'dokodemo-door' 'trojan' ) + inquirer list_input "选择入站代理协议" inbound_protocols inbound_protocol +} + +V2rayInboundSettings() +{ + return +} + +V2rayInboundPortValidator() +{ + if [ "$1" == "$i18n_random" ] || [[ "$1" =~ ^[1-9][0-9]*$ ]] || [[ "$1" =~ ^([1-9][0-9]*)-([1-9][0-9]*)$ ]] + then + return 0 + fi + + return 1 +} + +V2rayInboundPort() +{ + Println "$tip 数值或范围,比如 1234、5-10" + inquirer text_input "输入入站端口" inbound_port "$i18n_random" V2rayInboundPortValidator + + if [ "$inbound_port" == "$i18n_random" ] + then + inbound_port=$(GetFreePort) + Println " 入站端口: ${green}$inbound_port${normal}" + fi +} + +V2rayInboundListen() +{ + Println "$tip 填写 Unix domain socket 时, 入站端口将被忽略" + inquirer text_input "输入入站监听地址" inbound_listen 0.0.0.0 +} + +V2rayInboundTag() +{ + echo + inquirer text_input "输入入站标识" inbound_tag "$i18n_random" + + if [ "$inbound_tag" == "$i18n_random" ] + then + local free_tag + while true + do + free_tag=$(RandStr) + if ! grep -q '"tag": "'"$free_tag"'"' < "$V2_CONFIG" + then + inbound_tag="$free_tag" + break + fi + done + Println " 入站标识: ${green}$inbound_tag${normal}" + fi +} + +V2rayInboundSniffingEnabled() +{ + echo + inquirer list_input_index "是否开启流量探测" ny_options ny_index + + if [ "$ny_index" -eq 0 ] + then + inbound_sniffing_enabled=false + else + inbound_sniffing_enabled=true + fi +} + +V2rayInboundSniffingDestOverride() +{ + inbound_sniffing_dest_override_options=( 'http' 'tls' 'quic' 'fakedns' 'fakedns+others' ) + + Println "$tip 当流量为指定类型时,按其中包括的目标地址重置当前连接的目标" + inquirer checkbox_input "指定流量类型: " inbound_sniffing_dest_override_options inbound_sniffing_dest_override_options_selected + + inbound_sniffing_dest_override=$(JoinByChar , "${inbound_sniffing_dest_override_options_selected[@]}") +} + +V2rayInboundSniffingMetadataOnly() +{ + echo + inquirer list_input_index "仅使用元数据推断目标地址而不截取流量内容" ny_options ny_index + + if [ "$ny_index" -eq 0 ] + then + inbound_sniffing_metadata_only=false + else + inbound_sniffing_metadata_only=true + fi +} + +V2rayInboundSniffing() +{ + V2rayInboundSniffingEnabled + + if [ "$inbound_sniffing_enabled" = false ] + then + inbound_sniffing_dest_override="" + inbound_sniffing_metadata_only=false + return + fi + + V2rayInboundSniffingDestOverride + V2rayInboundSniffingMetadataOnly + + new_sniffing=$( + $JQ_FILE -n --arg enabled "$sniffing_enabled" \ + --argjson destOverride "[$sniffing_dest_override]" \ + --arg metadataOnly "$sniffing_metadata_only" \ + '{ + "enabled": $enabled | test("true"), + "destOverride": $destOverride, + "metadataOnly": $metadataOnly | test("true") + }') +} + +V2rayInboundAdd() +{ + V2rayInboundProtocol + V2rayInboundSettings + V2rayInboundPort + V2rayInboundListen + V2rayInboundTag + V2rayInboundSniffing + V2rayStream + + new_inbound=$( + $JQ_FILE -n --arg listen "$inbound_listen" \ + --arg port "$inbound_port" \ + --arg protocol "$inbound_protocol" \ + --argjson settings "$inbound_settings" \ + --argjson streamSettings "$new_stream" \ + --argjson sniffing "$new_sniffing" \ + --arg tag "$inbound_tag" \ + '{ + "listen": $listen, + "port": $port | tonumber, + "protocol": $protocol, + "settings": $settings, + "streamSettings": $streamSettings, + "sniffing": $sniffing, + "tag": $tag + }') + + if [ -n "$sockopt_tfo" ] + then + if [ "$sockopt_tfo" = true ] || [ "$sockopt_tfo" = false ] + then + new_inbound=$( + $JQ_FILE --arg tcpFastOpen "$sockopt_tfo" \ + '. * + { + "streamSettings": { + "sockopt": { + "tcpFastOpen": $tcpFastOpen | test("true") + } + } + }' <<< "$new_inbound") + else + new_inbound=$( + $JQ_FILE --arg tcpFastOpen "$sockopt_tfo" \ + '. * + { + "streamSettings": { + "sockopt": { + "tcpFastOpen": $tcpFastOpen | tonumber + } + } + }' <<< "$new_inbound") + fi + fi + + if [[ ! "$port" =~ ^[0-9]+$ ]] + then + SetV2rayAllocateStrategy + if [ "$allocate_strategy" == "random" ] + then + SetV2rayAllocateRefresh + SetV2rayAllocateConcurrency + new_inbound=$( + $JQ_FILE --arg strategy "$allocate_strategy" --arg refresh "$allocate_refresh" \ + --arg concurrency "$allocate_concurrency" \ + '. * + { + "allocate": { + "strategy": $strategy, + "refresh": $refresh | tonumber, + "concurrency": $concurrency | tonumber + } + }' <<< "$new_inbound") + fi + fi + + if [ "$security" == "tls" ] + then + V2rayTlsServerName + + if [ -n "$tls_server_name" ] + then + new_inbound=$( + $JQ_FILE --arg serverName "$tls_server_name" \ + '. * + { + "streamSettings": { + "tlsSettings": { + "serverName": $serverName + } + } + }' <<< "$new_inbound") + fi + + V2rayTlsAlpn + V2rayTlsDisableSystemRoot + V2rayTlsVerifyClientCertificate + + new_inbound=$( + $JQ_FILE --argjson alpn "[$tls_alpn]" --arg disableSystemRoot "$tls_disable_system_root" \ + --arg verifyClientCertificate "$tls_verify_client_certificate" \ + '. * + { + "streamSettings": { + "tlsSettings": { + "alpn": $alpn, + "disableSystemRoot": $disableSystemRoot | test("true"), + "verifyClientCertificate": $verifyClientCertificate | test("true") + } + } + }' <<< "$new_inbound") + + while true + do + if [ "$tls_disable_system_root" = false ] + then + echo + inquirer list_input "是否继续添加证书" ny_options continue_yn + if [ "$continue_yn" == "$i18n_no" ] + then + break + fi + fi + Println "$info 设置证书" + V2rayCertificates + merge=$( + $JQ_FILE -n --argjson certificates "[$certificate]" \ + '{ + "streamSettings": { + "tlsSettings": { + "certificates": $certificates + } + } + }') + JQs merge new_inbound "$merge" + if [ "$tls_disable_system_root" = true ] + then + echo + inquirer list_input "是否继续添加证书" ny_options continue_yn + if [ "$continue_yn" == "$i18n_no" ] + then + break + fi + fi + done + elif [ "$security" == "xtls" ] + then + V2rayTlsServerName + + if [ -n "$tls_server_name" ] + then + new_inbound=$( + $JQ_FILE --arg serverName "$tls_server_name" \ + '. * + { + "streamSettings": { + "xtlsSettings": { + "serverName": $serverName + } + } + }' <<< "$new_inbound") + fi + + V2rayTlsAlpn + V2rayTlsDisableSystemRoot + V2rayTlsMinVersion + V2rayTlsMaxVersion + V2rayTlsPreferServerCipherSuites + V2rayTlsCipherSuites + V2rayTlsRejectUnknownSni + + new_inbound=$( + $JQ_FILE --argjson alpn "[$tls_alpn]" --arg minVersion "$tls_min_version" \ + --arg maxVersion "$tls_max_version" --arg preferServerCipherSuites "$tls_prefer_server_cipher_suites" \ + --arg cipherSuites "$tls_cipher_suites" --arg disableSystemRoot "$tls_disable_system_root" \ + --arg rejectUnknownSni "$tls_reject_unknown_sni" \ + '. * + { + "streamSettings": { + "xtlsSettings": { + "alpn": $alpn, + "minVersion": $minVersion, + "maxVersion": $maxVersion, + "preferServerCipherSuites": $preferServerCipherSuites | test("true"), + "cipherSuites": $cipherSuites, + "disableSystemRoot": $disableSystemRoot | test("true"), + "rejectUnknownSni": $rejectUnknownSni | test("true") + } + } + }' <<< "$new_inbound") + + while true + do + if [ "$tls_disable_system_root" = false ] + then + echo + inquirer list_input "是否继续添加证书" ny_options continue_yn + if [ "$continue_yn" == "$i18n_no" ] + then + break + fi + fi + Println "$info 设置证书" + V2rayCertificates + merge=$( + $JQ_FILE -n --argjson certificates "[$certificate]" \ + '{ + "streamSettings": { + "xtlsSettings": { + "certificates": $certificates + } + } + }') + JQs merge new_inbound "$merge" + if [ "$tls_disable_system_root" = true ] + then + echo + inquirer list_input "是否继续添加证书" ny_options continue_yn + if [ "$continue_yn" == "$i18n_no" ] + then + break + fi + fi + done + fi + + if [ "$protocol" == "vmess" ] + then + V2rayDisableInsecureEncryption + + new_inbound=$( + $JQ_FILE --arg disableInsecureEncryption "$disable_insecure_encryption" \ + '. * + { + "settings": { + "clients": [], + "disableInsecureEncryption":$disableInsecureEncryption | test("true") + } + }' <<< "$new_inbound") + + V2rayDetourTo + + if [ "$detour_to" != "$i18n_blank" ] + then + V2rayDetourDefault + new_inbound=$( + $JQ_FILE --arg level "$level" --arg alterId "$alter_id" --arg to "$detour_to" \ + '. * + { + "settings": { + "default": { + "level": $level | tonumber, + "alterId": $alterId | tonumber + }, + "detour": { + "to": $to + } + } + }' <<< "$new_inbound") + fi + elif [ "$protocol" == "vless" ] || [ "$protocol" == "trojan" ] + then + new_inbound=$( + $JQ_FILE \ + '. * + { + "settings": { + "clients": [] + } + }' <<< "$new_inbound") + + if [ "$protocol" == "vless" ] + then + new_inbound=$( + $JQ_FILE \ + '. * + { + "settings": { + "decryption":"none" + } + }' <<< "$new_inbound") + fi + + if { [ "$security" == "tls" ] || [ "$security" == "xtls" ]; } && [ "$network" == "tcp" ] && [[ $tls_alpn == *"http/1.1"* ]] + then + V2rayFallbacks + + if [ "$v2ray_fallbacks" != "[]" ] + then + new_inbound=$( + $JQ_FILE --argjson fallbacks "$v2ray_fallbacks" \ + '. * + { + "settings": { + "fallbacks":$fallbacks + } + }' <<< "$new_inbound") + fi + fi + elif [ "$protocol" == "http" ] + then + V2rayTimeout + V2rayAllowTransparent + V2rayLevel + + new_inbound=$( + $JQ_FILE --arg timeout "$timeout" --arg allowTransparent "$allow_transparent" \ + --arg userLevel "$level" \ + '. * + { + "settings": { + "timeout": $timeout | tonumber, + "accounts": [], + "allowTransparent": $allowTransparent | test("true"), + "userLevel": $userLevel | tonumber + } + }' <<< "$new_inbound") + elif [ "$protocol" == "socks" ] + then + V2rayLevel + V2rayAuth + V2rayUdp + + new_inbound=$( + $JQ_FILE --arg auth "$auth" --arg udp "$udp" \ + --arg userLevel "$level" \ + '. * + { + "settings": { + "auth": $auth, + "udp": $udp | test("true"), + "userLevel": $userLevel | tonumber + } + }' <<< "$new_inbound") + + if [ "$udp" = true ] + then + V2rayIp + new_inbound=$( + $JQ_FILE --arg ip "$ip" \ + '. * + { + "settings": { + "ip": $ip + } + }' <<< "$new_inbound") + fi + elif [ "$protocol" == "shadowsocks" ] + then + if [ "$v2ray_name" == "xray" ] && [[ $($V2CTL_FILE version | head -1 | cut -d' ' -f2) =~ ([^.]+).([^.]+).([^.]+) ]] && \ + [ "${BASH_REMATCH[1]}" -ge 1 ] && [ "${BASH_REMATCH[2]}" -ge 2 ] && [ "${BASH_REMATCH[3]}" -ge 3 ] + then + V2raySettingsNetwork + + new_inbound=$( + $JQ_FILE --arg network "$settings_network" \ + '. * + { + "settings": { + "clients": [], + "network": $network + } + }' <<< "$new_inbound") + else + V2rayEmail + V2rayShadowsocksMethod + V2rayPassword + V2rayLevel + V2raySettingsNetwork + + new_inbound=$( + $JQ_FILE --arg email "$email" --arg method "$shadowsocks_method" \ + --arg password "$password" --arg level "$level" \ + --arg network "$settings_network" \ + '. * + { + "settings": { + "email": $email, + "method": $method, + "password": $password, + "level": $level | tonumber, + "network": $network + } + }' <<< "$new_inbound") + + if [ "$v2ray_name" == "v2ray" ] + then + V2rayIvCheck + + new_inbound=$( + $JQ_FILE --arg ivCheck "$iv_check" \ + '. * + { + "settings": { + "ivCheck": $ivCheck | test("true") + } + }' <<< "$new_inbound") + fi + fi + elif [ "$protocol" == "dokodemo-door" ] + then + echo + inquirer list_input "是否用于 api 查询" ny_options yn_option + + if [ "$yn_option" == "$i18n_yes" ] + then + new_inbound=$( + $JQ_FILE \ + '. * + { + "settings": { + "address": "127.0.0.1", + } + }' <<< "$new_inbound") + else + V2raySettingsNetwork + V2rayTimeout + V2rayLevel + V2rayFollowRedirect + + if [ "$follow_redirect" = true ] + then + new_inbound=$( + $JQ_FILE --arg network "$settings_network" --arg timeout "$timeout" \ + --arg followRedirect "$follow_redirect" --arg userLevel "$level" \ + '. * + { + "settings": { + "network": $network, + "timeout": $timeout | tonumber, + "followRedirect": $followRedirect | test("true"), + "userLevel": $userLevel | tonumber + } + }' <<< "$new_inbound") + else + V2rayAddress + V2rayAddressPort + + new_inbound=$( + $JQ_FILE --arg address "$address" --arg port "$address_port" \ + --arg network "$settings_network" --arg timeout "$timeout" \ + --arg followRedirect "$follow_redirect" --arg userLevel "$level" \ + '. * + { + "settings": { + "address": $address, + "port": $port | tonumber, + "network": $network, + "timeout": $timeout | tonumber, + "followRedirect": $followRedirect | test("true"), + "userLevel": $userLevel | tonumber + } + }' <<< "$new_inbound") + fi + fi + fi + + if [ "$network" == "ws" ] + then + V2rayAcceptProxyProtocol + V2rayPath + V2rayWsHeaders + + new_inbound=$( + $JQ_FILE --arg acceptProxyProtocol "$accept_proxy_protocol" \ + --arg path "$path" --argjson headers "{$ws_headers}" \ + '. * + { + "streamSettings": { + "wsSettings": { + "acceptProxyProtocol": $acceptProxyProtocol | test("true"), + "path": $path, + "headers": $headers + } + } + }' <<< "$new_inbound") + + if [ "$v2ray_name" == "v2ray" ] + then + V2rayInboundMaxEarlyData + + if [ "$max_early_data" -gt 0 ] + then + V2rayEarlyDataHeaderName + + if [ -n "$early_data_header_name" ] && [ "$early_data_header_name" != "Sec-WebSocket-Protocol" ] + then + use_browser_forwarding=false + else + V2rayUseBrowserForwarding + fi + else + early_data_header_name="" + use_browser_forwarding=false + fi + + new_inbound=$( + $JQ_FILE --arg maxEarlyData "$max_early_data" \ + --arg earlyDataHeaderName "$early_data_header_name" \ + --arg useBrowserForwarding "$use_browser_forwarding" \ + '. * + { + "streamSettings": { + "wsSettings": { + "maxEarlyData": $maxEarlyData | tonumber, + "earlyDataHeaderName": $earlyDataHeaderName, + "useBrowserForwarding": $useBrowserForwarding | test("true") + } + } + }' <<< "$new_inbound") + fi + elif [ "$network" == "tcp" ] + then + V2rayAcceptProxyProtocol + V2rayHeaderType + + new_inbound=$( + $JQ_FILE --arg acceptProxyProtocol "$accept_proxy_protocol" \ + --arg header_type "$header_type" --argjson request "$header_http_request" \ + --argjson response "$header_http_response" \ + '. * + { + "streamSettings": { + "tcpSettings": { + "acceptProxyProtocol": $acceptProxyProtocol | test("true"), + "header": { + "type": $header_type, + "request": $request, + "response": $response + } + } + } + }' <<< "$new_inbound") + elif [ "$network" == "kcp" ] + then + V2rayHeaderType + V2rayKcpMtu + V2rayKcpTti + V2rayKcpUplinkCapacity + V2rayKcpDownlinkCapacity + V2rayKcpCongestion + V2rayKcpReadBufferSize + V2rayKcpWriteBufferSize + V2rayKcpSeed + + new_inbound=$( + $JQ_FILE --arg mtu "$kcp_mtu" --arg tti "$kcp_tti" \ + --arg uplinkCapacity "$kcp_uplink_capacity" --arg downlinkCapacity "$kcp_downlink_capacity" \ + --arg congestion "$kcp_congestion" --arg readBufferSize "$kcp_read_buffer_size" \ + --arg writeBufferSize "$kcp_write_buffer_size" --arg header_type "$header_type" \ + --arg seed "$kcp_seed" \ + '. * + { + "streamSettings": { + "kcpSettings": { + "mtu": $mtu | tonumber, + "tti": $tti | tonumber, + "uplinkCapacity": $uplinkCapacity | tonumber, + "downlinkCapacity": $downlinkCapacity | tonumber, + "congestion": $congestion | test("true"), + "readBufferSize": $readBufferSize | tonumber, + "writeBufferSize": $writeBufferSize | tonumber, + "header": { + "type": $header_type + }, + "seed": $seed + } + } + }' <<< "$new_inbound") + elif [ "$network" == "http" ] + then + V2rayHttpHost + V2rayPath + V2rayHttpHeaders + + new_inbound=$( + $JQ_FILE --argjson host "[$http_host]" --arg path "$path" \ + --argjson headers "{$http_headers}" \ + '. * + { + "streamSettings": { + "httpSettings": { + "host": $host, + "path": $path, + "headers": $headers + } + } + }' <<< "$new_inbound") + + if [ "$v2ray_name" == "v2ray" ] + then + V2rayHttpMethod + + new_inbound=$( + $JQ_FILE --arg method "$http_method" \ + '. * + { + "streamSettings": { + "httpSettings": { + "method": $method + } + } + }' <<< "$new_inbound") + fi + elif [ "$network" == "quic" ] + then + V2rayQuicSecurity + V2rayQuicKey + V2rayHeaderType + + new_inbound=$( + $JQ_FILE --arg security "$quic_security" \ + --arg key "$quic_key" --arg header_type "$header_type" \ + '. * + { + "streamSettings": { + "quicSettings": { + "security": $security, + "key": $key, + "header": { + "type": $header_type + } + } + } + }' <<< "$new_inbound") + elif [ "$network" == "domainsocket" ] + then + V2rayDsPath + V2rayDsAbstract + V2rayDsPadding + + new_inbound=$( + $JQ_FILE --arg path "$ds_path" \ + --arg abstract "$ds_abstract" --arg padding "$ds_padding" \ + '. * + { + "streamSettings": { + "dsSettings": { + "path": $ds_path, + "abstract": $abstract | test("true"), + "padding": $padding | test("true") + } + } + }' <<< "$new_inbound") + else + V2rayGrpcServiceName + + new_inbound=$( + $JQ_FILE --arg grpcSettings "$grpc_service_name" \ + '. * + { + "streamSettings": { + "grpcSettings": { + "serviceName": $serviceName + } + } + }' <<< "$new_inbound") + + if [ "$v2ray_name" == "xray" ] + then + V2rayGrpcMultiMode + + new_inbound=$( + $JQ_FILE --arg multiMode "$grpc_multi_mode" \ + '. * + { + "streamSettings": { + "grpcSettings": { + "multiMode": $multiMode | test("true") + } + } + }' <<< "$new_inbound") + fi + fi + + jq_path='["inbounds"]' + JQ add "$V2_CONFIG" "[$new_inbound]" + + Println "$info 入站 $tag 添加成功\n" +} diff --git a/src/v2ray/log b/src/v2ray/log new file mode 100644 index 0000000..e69de29 diff --git a/src/v2ray/set_bound b/src/v2ray/set_bound index be0142b..59e52cb 100644 --- a/src/v2ray/set_bound +++ b/src/v2ray/set_bound @@ -1,3 +1,85 @@ +V2raySetTcpProxyProtocol() +{ + echo + inquirer list_input_yn "是否接收 Proxy Protocol" ft_options tcp_accept_proxy_protocol +} + +V2raySetWebSocketAcceptProxyProtocol() +{ + echo + inquirer list_input_yn "是否接收 Proxy Protocol" ft_options ws_accept_proxy_protocol +} + +V2raySetWebSocketPath() +{ + echo + inquirer text_input "输入 WebSocket 所使用的 HTTP 协议路径" ws_path / +} + +V2raySetWebSocketHeaders() +{ + ws_headers='{}' + while true + do + echo + inquirer text_input "输入自定义 HTTP 头的名称: " ws_header_name "$i18n_blank" + if [ "$ws_header_name" == "$i18n_blank" ] + then + break + fi + echo + inquirer text_input "输入自定义 HTTP 头 $ws_header_name 的值: " ws_header_value "$i18n_blank" + if [ "$ws_header_value" == "$i18n_blank" ] + then + ws_header_value="" + fi + JQs merge ws_headers --arg header_name "$ws_header_name" \ + --arg header_value "$ws_header_value" '. * { + $header_name: $header_value + }' + echo + inquirer list_input_index "是否继续添加" ny_options ny_index + if [ "$ny_index" -eq 0 ] + then + break + fi + done +} + +V2raySetWebsocketInboundMaxEarlyData() +{ + echo + inquirer list_input_yn "启用前置数据支持" oz_options ws_max_early_data +} + +V2raySetWebsocketOutboundMaxEarlyData() +{ + echo + inquirer text_input "输入发送的前置数据的最长长度" ws_max_early_data 0 +} + +V2raySetWebsocketUseBrowserForwarding() +{ + echo + inquirer list_input_yn "启用浏览器转发" tf_options ws_use_browser_forwarding +} + +V2raySetWebsocketEarlyDataHeaderName() +{ + echo + inquirer text_input "发送的前置数据的 HTTP 头的名字" ws_early_data_header_name "$i18n_blank" + + if [ "$ws_early_data_header_name" == "$i18n_blank" ] + then + ws_early_data_header_name="" + fi +} + + + + + + V2raySetListen() { echo @@ -121,9 +203,9 @@ V2raySetSettingsNetwork() V2raySetIvCheck() { echo - inquirer list_input_index "启用 IV 检查功能" ny_options ny_options_index + inquirer list_input_index "启用 IV 检查功能" ny_options ny_index - if [ "$ny_options_index" -eq 0 ] + if [ "$ny_index" -eq 0 ] then iv_check=false else @@ -197,8 +279,8 @@ V2raySetSecurity() V2raySetTlsServerName() { Println "$tip 在连接由 IP 建立时有用" - inquirer text_input "指定服务器端证书的域名" tls_server_name "$i18n_not_set" - if [ "$tls_server_name" == "$i18n_not_set" ] + inquirer text_input "指定服务器端证书的域名" tls_server_name "$i18n_blank" + if [ "$tls_server_name" == "$i18n_blank" ] then tls_server_name="" fi @@ -207,8 +289,8 @@ V2raySetTlsServerName() V2raySetTlsAllowInsecure() { Println "$tip 在自定义证书的情况开可以选 否" - inquirer list_input_index "是否检测证书有效性" yn_options yn_options_index - if [ "$yn_options_index" -eq 0 ] + inquirer list_input_index "是否检测证书有效性" yn_options yn_index + if [ "$yn_index" -eq 0 ] then tls_allow_insecure=false else @@ -252,9 +334,9 @@ V2raySetTlsDisableSystemRoot() V2raySetTlsMinVersion() { echo - inquirer text_input "输入可接受的最小 TLS 版本: " tls_min_version "$i18n_not_set" + inquirer text_input "输入可接受的最小 TLS 版本: " tls_min_version "$i18n_blank" - if [ "$tls_min_version" == "$i18n_not_set" ] + if [ "$tls_min_version" == "$i18n_blank" ] then tls_min_version="" fi @@ -263,9 +345,9 @@ V2raySetTlsMinVersion() V2raySetTlsMaxVersion() { echo - inquirer text_input "输入可接受的最大 TLS 版本: " tls_max_version "$i18n_not_set" + inquirer text_input "输入可接受的最大 TLS 版本: " tls_max_version "$i18n_blank" - if [ "$tls_max_version" == "$i18n_not_set" ] + if [ "$tls_max_version" == "$i18n_blank" ] then tls_max_version="" fi @@ -287,9 +369,9 @@ V2raySetTlsPreferServerCipherSuites() V2raySetTlsCipherSuites() { Println "$tip 每个套件名称之间用:进行分隔" - inquirer text_input "输入密码套件" tls_cipher_suites "$i18n_not_set" + inquirer text_input "输入密码套件" tls_cipher_suites "$i18n_blank" - if [ "$tls_cipher_suites" == "$i18n_not_set" ] + if [ "$tls_cipher_suites" == "$i18n_blank" ] then tls_cipher_suites="" fi @@ -314,7 +396,7 @@ V2raySetTlsFingerprint() tls_fingerprint_options=( '不设置' 'chrome' 'firefox' 'safari' 'randomized' ) inquirer list_input "指定 TLS Client Hello 的指纹" tls_fingerprint_options tls_fingerprint - if [ "$tls_fingerprint" == "$i18n_not_set" ] + if [ "$tls_fingerprint" == "$i18n_blank" ] then tls_fingerprint="" fi @@ -349,9 +431,9 @@ V2raySetTlsVerifyClientCertificate() V2raySetTlsPinnedPeerCertificateChainSha256() { echo - inquirer text_input "证书链的SHA256散列值" tls_pinned_peer_certificate_chain_sha256 "$i18n_not_set" + inquirer text_input "证书链的SHA256散列值" tls_pinned_peer_certificate_chain_sha256 "$i18n_blank" - if [ "$tls_pinned_peer_certificate_chain_sha256" == "$i18n_not_set" ] + if [ "$tls_pinned_peer_certificate_chain_sha256" == "$i18n_blank" ] then tls_pinned_peer_certificate_chain_sha256="" fi @@ -626,9 +708,9 @@ V2raySetSockoptDomainStrategy() V2raySetSockoptDialerProxy() { Println "$tip 此选项可用于支持底层传输方式的链式转发" - inquirer text_input "出站代理的标识: " sockopt_dialer_proxy "$i18n_not_set" + inquirer text_input "出站代理的标识: " sockopt_dialer_proxy "$i18n_blank" - if [ "$sockopt_dialer_proxy" == "$i18n_not_set" ] + if [ "$sockopt_dialer_proxy" == "$i18n_blank" ] then sockopt_dialer_proxy="" fi @@ -664,14 +746,14 @@ V2raySetWsHeaders() while true do echo - inquirer text_input "输入自定义 HTTP 头的名称: " ws_header_name "$i18n_not_set" - if [ "$ws_header_name" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 头的名称: " ws_header_name "$i18n_blank" + if [ "$ws_header_name" == "$i18n_blank" ] then break fi echo - inquirer text_input "输入自定义 HTTP 头 $ws_header_name 的值: " ws_header_value "$i18n_not_set" - if [ "$ws_header_value" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 头 $ws_header_name 的值: " ws_header_value "$i18n_blank" + if [ "$ws_header_value" == "$i18n_blank" ] then break fi @@ -708,9 +790,9 @@ V2raySetOutboundMaxEarlyData() V2raySetEarlyDataHeaderName() { Println "$tip 当且仅当 HTTP 头的名字为 Sec-WebSocket-Protocol 时可以启用基于 HTTP 头的前置数据浏览器转发功能" - inquirer text_input "输入发送的前置数据的 HTTP 头的名字: " early_data_header_name "$i18n_not_set" + inquirer text_input "输入发送的前置数据的 HTTP 头的名字: " early_data_header_name "$i18n_blank" - if [ "$early_data_header_name" == "$i18n_not_set" ] + if [ "$early_data_header_name" == "$i18n_blank" ] then earlyDataHeaderName="" fi @@ -741,8 +823,8 @@ V2raySetHttpHeaders() while true do echo - inquirer text_input "输入自定义 HTTP 头的名称: " http_header_name "$i18n_not_set" - if [ "$http_header_name" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 头的名称: " http_header_name "$i18n_blank" + if [ "$http_header_name" == "$i18n_blank" ] then break fi @@ -753,9 +835,9 @@ V2raySetHttpHeaders() while true do echo - inquirer text_input "输入自定义 HTTP 头 $http_header_name 的值: " http_header_value "$i18n_not_set" + inquirer text_input "输入自定义 HTTP 头 $http_header_name 的值: " http_header_value "$i18n_blank" - if [ "$http_header_value" == "$i18n_not_set" ] + if [ "$http_header_value" == "$i18n_blank" ] then http_header_value="" else @@ -1095,7 +1177,7 @@ V2raySetGrpcMultiMode() V2raySetDetourTo() { Println "$tip 指定的入站协议必须是 VMess" - inquirer text_input "使用另一个入站的出站(输入指定的另一个入站的标签): " detour_to "$i18n_not_set" + inquirer text_input "使用另一个入站的出站(输入指定的另一个入站的标签): " detour_to "$i18n_blank" Println " 指定的另一个入站: ${green} $detour_to ${normal}" } @@ -1108,8 +1190,8 @@ V2raySetDetourDefault() V2raySetDisableInsecureEncryption() { Println "$tip 当客户端使用 none / aes-128-cfb 加密方式时, 服务器会主动断开连接" - inquirer list_input_index "是否禁止客户端使用不安全的加密方式" yn_options yn_options_index - if [ "$yn_options_index" == "$i18n_yes" ] + inquirer list_input_index "是否禁止客户端使用不安全的加密方式" yn_options yn_index + if [ "$yn_index" == "$i18n_yes" ] then disable_insecure_encryption=true else @@ -1148,15 +1230,15 @@ V2raySetHeaderType() while true do echo - inquirer text_input "输入自定义 HTTP 请求头的名称: " header_name "$i18n_not_set" - if [ "$header_name" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 请求头的名称: " header_name "$i18n_blank" + if [ "$header_name" == "$i18n_blank" ] then break fi Println "$tip 多个值用 | 分隔" - inquirer text_input "输入自定义 HTTP 请求头 $header_name 的值: " header_value "$i18n_not_set" - if [ "$header_value" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 请求头 $header_name 的值: " header_value "$i18n_blank" + if [ "$header_value" == "$i18n_blank" ] then break fi @@ -1212,15 +1294,15 @@ V2raySetHeaderType() while true do echo - inquirer text_input "输入自定义 HTTP 响应头的名称: " header_name "$i18n_not_set" - if [ "$header_name" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 响应头的名称: " header_name "$i18n_blank" + if [ "$header_name" == "$i18n_blank" ] then break fi Println "$tip 多个值用|分隔" - inquirer text_input "输入自定义 HTTP 响应头 $header_name 的值: " header_value "$i18n_not_set" - if [ "$header_value" == "$i18n_not_set" ] + inquirer text_input "输入自定义 HTTP 响应头 $header_name 的值: " header_value "$i18n_blank" + if [ "$header_value" == "$i18n_blank" ] then break fi @@ -1317,9 +1399,9 @@ V2raySetKcpWriteBufferSize() V2raySetKcpSeed() { echo - inquirer text_input "输入混淆密码: " kcp_write_buffer_size "$i18n_not_set" + inquirer text_input "输入混淆密码: " kcp_write_buffer_size "$i18n_blank" - if [ "$kcp_write_buffer_size" == "$i18n_not_set" ] + if [ "$kcp_write_buffer_size" == "$i18n_blank" ] then kcp_write_buffer_size="" fi @@ -1376,8 +1458,8 @@ V2raySetSniffingMetadataOnly() V2raySetSniffingDomainsExcluded() { Println "$tip 多个域名用空格分隔" - inquirer text_input "输入排除流量探测的域名: " sniffing_domains_excluded "$i18n_not_set" - if [ "$sniffing_domains_excluded" == "$i18n_not_set" ] + inquirer text_input "输入排除流量探测的域名: " sniffing_domains_excluded "$i18n_blank" + if [ "$sniffing_domains_excluded" == "$i18n_blank" ] then sniffing_domains_excluded="" else @@ -1455,8 +1537,8 @@ V2raySetSendThrough() V2raySetProxyTag() { Println "$tip 如果指定另一个出站协议, 当前协议发出的数据, 将从指定的出站协议发出" - inquirer text_input "输入指定的另一个出站协议的标签: " proxy_tag "$i18n_not_set" - if [ "$proxy_tag" == "$i18n_not_set" ] + inquirer text_input "输入指定的另一个出站协议的标签: " proxy_tag "$i18n_blank" + if [ "$proxy_tag" == "$i18n_blank" ] then proxy_tag="" fi @@ -1509,8 +1591,8 @@ V2raySetFreedomDomainStrategy() V2raySetFreedomRedirect() { Println "例如 127.0.0.1:80, :1234 - 不改变原先的目标地址, v2ray.com:0 - 不改变原先的端口" - inquirer text_input "强制将所有数据发送到指定地址: " freedom_redirect "$i18n_not_set" - if [ "$freedom_redirect" == "$i18n_not_set" ] + inquirer text_input "强制将所有数据发送到指定地址: " freedom_redirect "$i18n_blank" + if [ "$freedom_redirect" == "$i18n_blank" ] then freedom_redirect="" fi @@ -1550,8 +1632,8 @@ V2raySetFallbacks() if [ "$v2ray_name" == "xray" ] then Println "$tip 一般不用设置" - inquirer text_input "输入 SNI 分流匹配值: " v2ray_fallback_name "$i18n_not_set" - if [ "$v2ray_fallback_name" == "$i18n_not_set" ] + inquirer text_input "输入 SNI 分流匹配值: " v2ray_fallback_name "$i18n_blank" + if [ "$v2ray_fallback_name" == "$i18n_blank" ] then v2ray_fallback_name="" fi @@ -1559,8 +1641,8 @@ V2raySetFallbacks() v2ray_fallback_name="" fi Println "$tip 请输入单个, 比如 http/1.1 或 h2" - inquirer text_input "输入尝试匹配 $tls_name ALPN 协商结果: " v2ray_fallback_alpn "$i18n_not_set" - if [ "$v2ray_fallback_alpn" == "$i18n_not_set" ] + inquirer text_input "输入尝试匹配 $tls_name ALPN 协商结果: " v2ray_fallback_alpn "$i18n_blank" + if [ "$v2ray_fallback_alpn" == "$i18n_blank" ] then v2ray_fallback_alpn="" elif [ "$v2ray_fallback_alpn" == "h2" ] && [[ ! $tls_alpn =~ h2 ]] diff --git a/src/v2ray/set_dns b/src/v2ray/set_dns index 01cf95f..38a875f 100644 --- a/src/v2ray/set_dns +++ b/src/v2ray/set_dns @@ -30,20 +30,20 @@ V2raySetDns() echo inquirer text_input "输入服务器端口: " dns_server_port 53 Println "$tip 用于 DNS 查询时通知 DNS 服务器, 客户端所在的地理位置" - inquirer text_input "输入通知 DNS 的 IP 地址: " dns_server_client_ip "$i18n_not_set" - if [ "$dns_server_client_ip" == "$i18n_not_set" ] + inquirer text_input "输入通知 DNS 的 IP 地址: " dns_server_client_ip "$i18n_blank" + if [ "$dns_server_client_ip" == "$i18n_blank" ] then dns_server_client_ip="" fi Println "$tip 优先使用此服务器进行查询, 多个域名用空格分隔, 格式和路由配置中相同" - inquirer text_input "输入域名: " dns_server_domain "$i18n_not_set" - if [ "$dns_server_domain" == "$i18n_not_set" ] + inquirer text_input "输入域名: " dns_server_domain "$i18n_blank" + if [ "$dns_server_domain" == "$i18n_blank" ] then dns_server_domain="" fi Println "$tip 当配置此项时, $v2ray_name DNS 会对返回的 IP 的进行校验, 只返回包含列表中的地址, 多个 IP 范围用空格分隔, 格式和路由配置中相同" - inquirer text_input "输入 IP 范围: " dns_server_expect_ips "$i18n_not_set" - if [ "$dns_server_expect_ips" == "$i18n_not_set" ] + inquirer text_input "输入 IP 范围: " dns_server_expect_ips "$i18n_blank" + if [ "$dns_server_expect_ips" == "$i18n_blank" ] then dns_server_expect_ips="" fi diff --git a/src/v2ray/set_routing b/src/v2ray/set_routing index ef4822f..6a8be78 100644 --- a/src/v2ray/set_routing +++ b/src/v2ray/set_routing @@ -54,8 +54,8 @@ V2raySetRouting() "network": $network }') Println "$tip 多个域名用空格分隔, 格式如 127.0.0.1, 10.0.0.0/8, geoip:cn, geoip:private, ext:file:tag" - inquirer text_input "输入匹配的域名: " routing_rule_domain "$i18n_not_set" - if [ "$routing_rule_domain" != "$i18n_not_set" ] + inquirer text_input "输入匹配的域名: " routing_rule_domain "$i18n_blank" + if [ "$routing_rule_domain" != "$i18n_blank" ] then IFS=" " read -r -a domains <<< "$routing_rule_domain" printf -v routing_rule_domain ',"%s"' "${domains[@]}" @@ -68,8 +68,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 多个 IP 范围用空格分隔" - inquirer text_input "输入匹配的 IP 范围: " routing_rule_ip "$i18n_not_set" - if [ "$routing_rule_ip" != "$i18n_not_set" ] + inquirer text_input "输入匹配的 IP 范围: " routing_rule_ip "$i18n_blank" + if [ "$routing_rule_ip" != "$i18n_blank" ] then IFS=" " read -r -a ips <<< "$routing_rule_ip" printf -v routing_rule_ip ',"%s"' "${ips[@]}" @@ -82,8 +82,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 多个端口用空格分隔, 格式如 53 443 1000-2000" - inquirer text_input "输入目标端口范围: " routing_rule_port "$i18n_not_set" - if [ "$routing_rule_port" != "$i18n_not_set" ] + inquirer text_input "输入目标端口范围: " routing_rule_port "$i18n_blank" + if [ "$routing_rule_port" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg port "${routing_rule_port// /,}" \ @@ -93,8 +93,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 多个端口用空格分隔, 格式如 53 443 1000-2000" - inquirer text_input "输入来源端口范围: " routing_rule_source_port "$i18n_not_set" - if [ "$routing_rule_source_port" != "$i18n_not_set" ] + inquirer text_input "输入来源端口范围: " routing_rule_source_port "$i18n_blank" + if [ "$routing_rule_source_port" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg sourcePort "${routing_rule_source_port// /,}" \ @@ -104,8 +104,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 多个 IP 用空格分隔, 格式如 127.0.0.1, 10.0.0.0/8" - inquirer text_input "输入匹配的来源 IP: " routing_rule_source "$i18n_not_set" - if [ "$routing_rule_source" != "$i18n_not_set" ] + inquirer text_input "输入匹配的来源 IP: " routing_rule_source "$i18n_blank" + if [ "$routing_rule_source" != "$i18n_blank" ] then IFS=" " read -r -a sources <<< "$routing_rule_source" printf -v routing_rule_source ',"%s"' "${sources[@]}" @@ -118,8 +118,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 多个邮箱地址用空格分隔, Shadowsocks 和 VMess 支持此规则" - inquirer text_input "输入匹配的邮箱地址: " routing_rule_user "$i18n_not_set" - if [ "$routing_rule_user" != "$i18n_not_set" ] + inquirer text_input "输入匹配的邮箱地址: " routing_rule_user "$i18n_blank" + if [ "$routing_rule_user" != "$i18n_blank" ] then IFS=" " read -r -a users <<< "$routing_rule_user" printf -v routing_rule_user ',"%s"' "${users[@]}" @@ -148,8 +148,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 用于检测流量的属性值, 目前只有 http 入站代理会设置这一属性" - inquirer text_input "输入 starlark 脚本: " routing_rule_attrs "$i18n_not_set" - if [ "$routing_rule_attrs" != "$i18n_not_set" ] + inquirer text_input "输入 starlark 脚本: " routing_rule_attrs "$i18n_blank" + if [ "$routing_rule_attrs" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg attrs "$routing_rule_attrs" \ @@ -159,8 +159,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi echo - inquirer text_input "输入匹配的入站标签: " routing_rule_inbound_tag "$i18n_not_set" - if [ "$routing_rule_inbound_tag" != "$i18n_not_set" ] + inquirer text_input "输入匹配的入站标签: " routing_rule_inbound_tag "$i18n_blank" + if [ "$routing_rule_inbound_tag" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg inboundTag "$routing_rule_inbound_tag" \ @@ -170,8 +170,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi Println "$tip 出站标签 和 负载均衡器标签 须二选一, 同时指定时, 出站标签 生效" - inquirer text_input "输入对应的出站标签: " routing_rule_outbound_tag "$i18n_not_set" - if [ "$routing_rule_outbound_tag" != "$i18n_not_set" ] + inquirer text_input "输入对应的出站标签: " routing_rule_outbound_tag "$i18n_blank" + if [ "$routing_rule_outbound_tag" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg outboundTag "$routing_rule_outbound_tag" \ @@ -181,8 +181,8 @@ V2raySetRouting() }' <<< "$new_routing_rule") fi echo - inquirer text_input "输入对应的负载均衡器标签: " routing_rule_balancer_tag "$i18n_not_set" - if [ "$routing_rule_balancer_tag" != "$i18n_not_set" ] + inquirer text_input "输入对应的负载均衡器标签: " routing_rule_balancer_tag "$i18n_blank" + if [ "$routing_rule_balancer_tag" != "$i18n_blank" ] then new_routing_rule=$( $JQ_FILE --arg balancerTag "$routing_rule_balancer_tag" \ @@ -207,8 +207,8 @@ V2raySetRouting() "tag": $tag }') Println "$tip 多个字符串用空格分隔" - inquirer text_input "输入匹配出站标签字符串: " routing_balancer_selector "$i18n_not_set" - if [ "$routing_balancer_selector" != "$i18n_not_set" ] + inquirer text_input "输入匹配出站标签字符串: " routing_balancer_selector "$i18n_blank" + if [ "$routing_balancer_selector" != "$i18n_blank" ] then IFS=" " read -r -a selectors <<< "$routing_balancer_selector" printf -v routing_balancer_selector ',"%s"' "${selectors[@]}" diff --git a/src/v2ray/stream b/src/v2ray/stream new file mode 100644 index 0000000..743f048 --- /dev/null +++ b/src/v2ray/stream @@ -0,0 +1,279 @@ +Include src/v2ray/set_bound "$@" + +V2raySecurity() +{ + echo + stream_security_options=( 'none' 'tls' 'utls' ) + inquirer list_input_index "选择传输层协议设置" stream_security_options stream_security_options_index + + case $stream_security_options_index in + 1) V2rayTlsSettings + ;; + 2) V2rayUtlsSettings + ;; + *) return + ;; + esac + + return +} + +V2raySocketMark() +{ + socket_mark=0 + + if [ "$dist" = "mac" ] || [ "$v2ray_inbound" = true ] + then + return + fi + + Println "$tip 当其值非零时,在出站连接上标记 SO_MARK" + inquirer text_input "设置标记" socket_mark 0 +} + +V2raySocketTcpFastOpen() +{ + echo + socket_tfo_options=( '系统默认' '强制开启' '强制关闭' ) + inquirer list_input_index "TCP Fast Open" socket_tfo_options socket_tfo_options_index + + unset socket_tfo_length + + if [ "$socket_tfo_options_index" -eq 2 ] + then + socket_tfo=false + return + fi + + if [ "$socket_tfo_options_index" -eq 0 ] + then + socket_tfo="" + else + socket_tfo=true + fi + + if [ "$dist" != "mac" ] && [ "$v2ray_inbound" = true ] + then + echo + inquirer text_input "入站连接的 TCP Fast Open 队列长度" socket_tfo_length 4096 + fi +} + +V2raySocketTproxy() +{ + unset socket_tproxy + + if [ "$dist" = "mac" ] + then + rerturn + fi + + echo + socket_tproxy_options=( 'off' 'redirect' 'tproxy' ) + inquirer list_input "设置透明代理模式" socket_tproxy_options socket_tproxy +} + +V2raySocketTcpKeepAliveInterval() +{ + unset socket_tcp_keep_alive_interval + + if [ "$dist" = "mac" ] + then + rerturn + fi + + Println "$tip 0 代表保持默认值" + inquirer text_input "TCP 保持活跃的数据包发送间隔(秒): " socket_tcp_keep_alive_interval 0 +} + +V2raySocketBindToDevice() +{ + echo + inquirer text_input "将连接绑定到指定的网络设备" socket_bind_to_device "$i18n_blank" + + if [ "$socket_bind_to_device" == "$i18n_blank" ] + then + socket_bind_to_device="" + fi +} + +V2raySocket() +{ + V2raySocketMark + V2raySocketTcpFastOpen + V2raySocketTproxy + V2raySocketTcpKeepAliveInterval + V2raySocketBindToDevice + + new_socket='{}' + + if [ "$socket_mark" -ne 0 ] + then + JQs merge_c new_socket --arg mark "$socket_mark" '. * { + "mark": $mark | tonumber + }' + fi + + if [ -n "${socket_tfo:-}" ] + then + new_socket=$( + $JQ_FILE --arg tcpFastOpen "$socket_tfo" \ + '. * + { + "tcpFastOpen": $tcpFastOpen | test("true") + }' <<< "$new_socket") + fi + + if [ -n "${socket_tfo_length:-}" ] + then + new_socket=$( + $JQ_FILE --arg tcpFastOpenQueueLength "$socket_tfo_length" \ + '. * + { + "tcpFastOpenQueueLength": $tcpFastOpenQueueLength | tonumber + }' <<< "$new_socket") + fi + + if [ -n "${socket_tproxy:-}" ] + then + new_socket=$( + $JQ_FILE --arg tproxy "$socket_tproxy" \ + '. * + { + "tproxy": $tproxy + }' <<< "$new_socket") + fi + + if [ -n "${socket_tcp_keep_alive_interval:-}" ] + then + new_socket=$( + $JQ_FILE --arg tcpKeepAliveInterval "$socket_tcp_keep_alive_interval" \ + '. * + { + "tcpKeepAliveInterval": $tcpKeepAliveInterval | tonumber + }' <<< "$new_socket") + fi + + if [ -n "${socket_bind_to_device:-}" ] + then + new_socket=$( + $JQ_FILE --arg bindToDevice "$socket_bind_to_device" \ + '. * + { + "bindToDevice": $bindToDevice + }' <<< "$new_socket") + fi +} + +V2rayStreamTransport() +{ + echo + stream_transport_options=( 'tcp' 'websocket' 'mkcp' 'grpc' 'quic' 'meek' 'httpupgrade' 'hysteria2' ) + inquirer list_input "选择传输层协议" stream_transport_options stream_transport +} + +V2rayTcpSettings() +{ + if [ "${1:-inbound}" != "inbound" ] + then + return + fi + + V2raySetTcpProxyProtocol + + JQs merge_c stream_transport_settings --arg acceptProxyProtocol "$tcp_accept_proxy_protocol" '. * { + "acceptProxyProtocol": $acceptProxyProtocol | test("true") + }' +} + +V2rayWebSocketSettings() +{ + V2raySetWebSocketPath + + if [ "${1:-inbound}" == "inbound" ] + then + V2raySetWebSocketAcceptProxyProtocol + V2raySetWebSocketInboundMaxEarlyData + V2raySetWebsocketUseBrowserForwarding + + if [ "$ws_max_early_data" -gt 0 ] + then + V2raySetWebSocketEarlyDataHeaderName + else + ws_early_data_header_name="" + fi + + JQs merge_c stream_transport_settings --arg acceptProxyProtocol "$ws_accept_proxy_protocol" \ + --arg path "$ws_path" --arg maxEarlyData "$ws_max_early_data" \ + --arg useBrowserForwarding "$ws_use_browser_forwarding" \ + --arg earlyDataHeaderName "$ws_early_data_header_name" '. * { + "acceptProxyProtocol": $acceptProxyProtocol | test("true"), + "path": $path, + "maxEarlyData": $maxEarlyData | tonumber, + "useBrowserForwarding": $useBrowserForwarding | test("true"), + "earlyDataHeaderName": $earlyDataHeaderName + }' + else + V2raySetWebSocketHeaders + V2raySetOutboundMaxEarlyData + V2raySetEarlyDataHeaderName + + JQs merge_c stream_transport_settings --arg acceptProxyProtocol "$ws_accept_proxy_protocol" \ + --arg path "$ws_path" --argjson headers "$ws_headers" \ + --arg maxEarlyData "$ws_max_early_data" \ + --arg earlyDataHeaderName "$ws_early_data_header_name" '. * { + "acceptProxyProtocol": $acceptProxyProtocol | test("true"), + "path": $path, + "headers": $headers, + "maxEarlyData": $maxEarlyData | tonumber, + "earlyDataHeaderName": $earlyDataHeaderName + }' + fi +} + +V2rayStream() +{ + V2rayStreamTransport + + stream_transport_settings='{}' + + case $stream_transport_options in + 0) V2rayTcpSettings "$@" + ;; + 1) V2rayWebSocketSettings "$@" + ;; + 2) V2rayMkcpSettings "$@" + ;; + 3) V2rayGrpcSettings "$@" + ;; + 4) V2rayQuicSettings "$@" + ;; + 5) V2rayMeekSettings "$@" + ;; + 6) V2rayHttpupgradeSettings "$@" + ;; + 7) V2rayHysteria2Settings "$@" + ;; + *) return + ;; + esac + + V2raySecurity + V2raySocket + + new_stream=$( + $JQ_FILE -n --arg transport "$stream_transport" \ + --argjson transportSettings "$stream_transport_settings" \ + --arg security "$stream_security" \ + --argjson securitySettings "$stream_security_settings" \ + --argjson socketSettings "$new_socket" \ + '{ + "transport": $transport, + "transportSettings": $transportSettings, + "security": $security, + "securitySettings": $securitySettings, + "socketSettings": $socketSettings + }') + + return +} diff --git a/src/vip/delete_channel b/src/vip/delete_channel index c7f4b97..314bc05 100644 --- a/src/vip/delete_channel +++ b/src/vip/delete_channel @@ -5,9 +5,9 @@ VipDelChannel() if [ -z "${vip_hosts_index:-}" ] then echo - inquirer list_input_index "清空所有频道" ny_options ny_options_index + inquirer list_input_index "清空所有频道" ny_options ny_index - if [ "$ny_options_index" -eq 1 ] + if [ "$ny_index" -eq 1 ] then for((vip_hosts_index=0;vip_hosts_index "$HOME"/ffmpeg.rb then diff --git a/utils/i18n b/utils/i18n index 57de24d..39539cb 100644 --- a/utils/i18n +++ b/utils/i18n @@ -40,13 +40,17 @@ i18nGetMsg() i18n_default_cancel=$(gettext "(默认: 取消): ") i18n_input_correct_no=$(gettext "请输入正确的序号") i18n_input_correct_number=$(gettext "请输入正确的数字") - i18n_not_set=${i18n_not_set:-$(gettext "不设置")} + i18n_blank=${i18n_blank:-$(gettext "不设置")} i18n_random=${i18n_random:-$(gettext "随机")} info="${green}`gettext \"[信息]\"`${normal}" error="${red}`gettext \"[错误]\"`${normal}" tip="${green}`gettext \"[注意]\"`${normal}" yn_options=( "$i18n_yes" "$i18n_no" ) ny_options=( "$i18n_no" "$i18n_yes" ) + tf_options=( true false ) + ft_options=( false true ) + zo_options=( 0 1 ) + oz_options=( 1 0 ) ;; get_default) i18n_proxy=${i18n_proxy:-$(gettext "代理")} diff --git a/utils/inquirer b/utils/inquirer index 982098d..3e3c92e 100644 --- a/utils/inquirer +++ b/utils/inquirer @@ -1591,6 +1591,34 @@ inquirer() trap - EXIT } + inquirer:list_input_yn() { + var_name=$3 + local hidden_var=("$2"[@]) + local hidden_options=("${!hidden_var}") + + inquirer:_list_input "$1" yn_options + + read -r ${var_name?} <<< "${hidden_options[current_index]}" + + inquirer:cleanup + + trap - EXIT + } + + inquirer:list_input_ny() { + var_name=$3 + local hidden_var=("$2"[@]) + local hidden_options=("${!hidden_var}") + + inquirer:_list_input "$1" ny_options + + read -r ${var_name?} <<< "${hidden_options[current_index]}" + + inquirer:cleanup + + trap - EXIT + } + inquirer:list_input_index() { var_name=$3 @@ -1783,11 +1811,18 @@ inquirer() trap inquirer:control_c EXIT + read -e text_input + + until validate_failed_msg=$($text_input_validator "$text_input") + do + inquirer:print "\n${bg_black}${red}${validate_failed_msg:-$text_input_validate_failed_msg}${normal}\n\n" + read -e text_input + done + #stty -echo #tput cnorm - - read -e text_input #inquirer:on_keypress inquirer:on_default inquirer:on_default inquirer:on_text_input_ascii inquirer:on_text_input_enter inquirer:on_text_input_left inquirer:on_text_input_right inquirer:on_text_input_ascii inquirer:on_text_input_backspace inquirer:on_text_input_not_ascii + read -r ${var_name?} <<< "${text_input:-$text_default}" inquirer:cleanup diff --git a/utils/iperf b/utils/iperf index 09f1ea1..6d95cd6 100644 --- a/utils/iperf +++ b/utils/iperf @@ -114,9 +114,9 @@ IperfAdd() inquirer list_input_index "请选择添加类型" iperf_type_options iperf_type_index echo - inquirer text_input "输入服务名称" iperf_name "$i18n_not_set" + inquirer text_input "输入服务名称" iperf_name "$i18n_blank" - if [ "$iperf_name" == "$i18n_not_set" ] + if [ "$iperf_name" == "$i18n_blank" ] then iperf_name="" fi @@ -148,9 +148,9 @@ IperfAdd() fi echo - inquirer text_input "输入 iperf3 参数" iperf_args "$i18n_not_set" + inquirer text_input "输入 iperf3 参数" iperf_args "$i18n_blank" - if [ "$iperf_args" == "$i18n_not_set" ] + if [ "$iperf_args" == "$i18n_blank" ] then iperf_args="" fi @@ -209,8 +209,8 @@ IperfEdit() case "${iperf_edit_options[iperf_edit_options_index]}" in '名称') echo - inquirer text_input "输入服务名称" iperf_name "${iperf_name[iperf_indices[iperf_options_index]]:-$i18n_not_set}" - if [ "$iperf_name" == "$i18n_not_set" ] + inquirer text_input "输入服务名称" iperf_name "${iperf_name[iperf_indices[iperf_options_index]]:-$i18n_blank}" + if [ "$iperf_name" == "$i18n_blank" ] then iperf_name="" fi @@ -231,8 +231,8 @@ IperfEdit() if [ "$iperf_target_index" -eq 0 ] then echo - inquirer text_input "输入目标地址" iperf_target "${iperf_target[iperf_indices[iperf_options_index]]:-$i18n_not_set}" - if [ "$iperf_target" == "$i18n_not_set" ] + inquirer text_input "输入目标地址" iperf_target "${iperf_target[iperf_indices[iperf_options_index]]:-$i18n_blank}" + if [ "$iperf_target" == "$i18n_blank" ] then iperf_target="" fi @@ -244,8 +244,8 @@ IperfEdit() ;; *) echo - inquirer text_input "输入 iperf3 参数" iperf_args "${iperf_args[iperf_indices[iperf_options_index]]:-$i18n_not_set}" - if [ "$iperf_args" == "$i18n_not_set" ] + inquirer text_input "输入 iperf3 参数" iperf_args "${iperf_args[iperf_indices[iperf_options_index]]:-$i18n_blank}" + if [ "$iperf_args" == "$i18n_blank" ] then iperf_args="" fi diff --git a/utils/jq b/utils/jq index 770b474..bec3e0d 100644 --- a/utils/jq +++ b/utils/jq @@ -434,6 +434,11 @@ JQs() ); merge({}; .)' <<< "${!2} $3") ;; + "merge_c") + local var=$2 + shift 2 + read -r $var < <($JQ_FILE "@" <<< "${!var}") + ;; "flat") if [[ $2 =~ ^/ ]] then diff --git a/utils/lua b/utils/lua index d72c28b..00fb476 100644 --- a/utils/lua +++ b/utils/lua @@ -55,7 +55,6 @@ LuaInstall() patch -p1 < "${patch##*/}" fi - make clean make linux-readline INSTALL_TOP="$DEPENDS_ROOT/$lua_name/$build_dir" make install INSTALL_TOP="$DEPENDS_ROOT/$lua_name/$build_dir" diff --git a/utils/mirror b/utils/mirror index 4d80fab..edec887 100644 --- a/utils/mirror +++ b/utils/mirror @@ -450,7 +450,7 @@ else fi Println "$info 下载 acme.sh ..." -if curl -s -L https://get.acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" +if curl -s -L https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh -o "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" then mv "$FFMPEG_MIRROR_ROOT/acme.sh_tmp" "$FFMPEG_MIRROR_ROOT/acme.sh" else diff --git a/utils/openssl b/utils/openssl index 3b66acd..15f6f2a 100644 --- a/utils/openssl +++ b/utils/openssl @@ -96,7 +96,6 @@ OpensslSourceInstall() cd "$openssl_name" perl ./Configure ${args[@]+"${args[@]}"} - make clean make make install diff --git a/utils/quictls b/utils/quictls index e5678e0..fea8f8b 100644 --- a/utils/quictls +++ b/utils/quictls @@ -78,7 +78,6 @@ QuictlsInstall() cd openssl-OpenSSL_1_1_1w-quic1 perl ./Configure "${args[@]}" - make clean make make install diff --git a/utils/zlib b/utils/zlib index 9900f82..35cc7ec 100644 --- a/utils/zlib +++ b/utils/zlib @@ -32,7 +32,6 @@ ZlibInstall() tar xzf "$zlib_name".tar.gz cd "$zlib_name" ./configure --prefix="$DEPENDS_ROOT/$zlib_name/$build_dir" ${args[@]+"${args[@]}"} - make clean make make install fi