Skip to content

Commit

Permalink
# 使用 $[] 来替代 expr 计算
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyo authored Sep 23, 2018
1 parent cc7c751 commit fb9ba84
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 66 deletions.
6 changes: 3 additions & 3 deletions brook-pf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Set_port_Modify(){
echo -e "请选择并输入要修改的 Brook 端口转发本地监听端口 [1-65535]"
stty erase '^H' && read -p "(默认取消):" bk_port_Modify
[[ -z "${bk_port_Modify}" ]] && echo "取消..." && exit 1
expr ${bk_port_Modify} + 0 &>/dev/null
echo $[${bk_port_Modify}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${bk_port_Modify} -ge 1 ]] && [[ ${bk_port_Modify} -le 65535 ]]; then
check_port "${bk_port_Modify}"
Expand All @@ -175,7 +175,7 @@ Set_port(){
echo -e "请输入 Brook 本地监听端口 [1-65535](端口不能重复,避免冲突)"
stty erase '^H' && read -p "(默认取消):" bk_port
[[ -z "${bk_port}" ]] && echo "已取消..." && exit 1
expr ${bk_port} + 0 &>/dev/null
echo $[${bk_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${bk_port} -ge 1 ]] && [[ ${bk_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down Expand Up @@ -204,7 +204,7 @@ Set_port_pf(){
echo -e "请输入 Brook 被转发的端口 [1-65535]"
stty erase '^H' && read -p "(默认取消):" bk_port_pf
[[ -z "${bk_port_pf}" ]] && echo "已取消..." && exit 1
expr ${bk_port_pf} + 0 &>/dev/null
echo $[${bk_port_pf}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${bk_port_pf} -ge 1 ]] && [[ ${bk_port_pf} -le 65535 ]]; then
echo && echo "========================"
Expand Down
4 changes: 2 additions & 2 deletions brook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Set_port_Modify(){
echo -e "请选择并输入要修改的 Brook 账号端口 [1-65535]"
stty erase '^H' && read -p "(默认取消):" bk_port_Modify
[[ -z "${bk_port_Modify}" ]] && echo "取消..." && exit 1
expr ${bk_port_Modify} + 0 &>/dev/null
echo $[${bk_port_Modify}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${bk_port_Modify} -ge 1 ]] && [[ ${bk_port_Modify} -le 65535 ]]; then
check_port "${bk_port_Modify}"
Expand All @@ -191,7 +191,7 @@ Set_port(){
echo -e "请输入 Brook 端口 [1-65535](端口不能重复,避免冲突)"
stty erase '^H' && read -p "(默认: 2333):" bk_port
[[ -z "${bk_port}" ]] && bk_port="2333"
expr ${bk_port} + 0 &>/dev/null
echo $[${bk_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${bk_port} -ge 1 ]] && [[ ${bk_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down
2 changes: 1 addition & 1 deletion cloudt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Set_port(){
echo -e "请输入 Cloud Torrent 监听端口 [1-65535](如果是绑定的域名,那么建议80端口)"
stty erase '^H' && read -p "(默认端口: 80):" ct_port
[[ -z "${ct_port}" ]] && ct_port="80"
expr ${ct_port} + 0 &>/dev/null
echo $[${ct_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ct_port} -ge 1 ]] && [[ ${ct_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down
12 changes: 6 additions & 6 deletions dowsdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Read_wrcd(){
[[ ! -e ${dowsdns_wrcd} ]] && echo -e "${Error} DowsDNS 泛域名解析 配置文件不存在 !" && exit 1
wrcd_json=$(cat -n ${dowsdns_wrcd}|sed '$d;1d;s/\"//g;s/,//g')
wrcd_json_num=$(echo -e "${wrcd_json}"|wc -l)
wrcd_json_num=$(expr $wrcd_json_num + 1)
wrcd_json_num=$(echo $[${wrcd_json_num}+1])
echo -e "当前DowsDNS 泛域名解析配置(不要问我为什么是从 2 开始):\n"
echo -e "${wrcd_json}\n"
}
Expand All @@ -138,7 +138,7 @@ Set_remote_dns_port(){
echo -e "请输入 DowsDNS 远程(上游)DNS解析服务器端口 [1-65535]"
stty erase '^H' && read -p "(默认: 53):" dd_remote_dns_port
[[ -z "$dd_remote_dns_port" ]] && dd_remote_dns_port="53"
expr ${dd_remote_dns_port} + 0 &>/dev/null
echo $[${dd_remote_dns_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${dd_remote_dns_port} -ge 1 ]] && [[ ${dd_remote_dns_port} -le 65535 ]]; then
echo
Expand Down Expand Up @@ -214,7 +214,7 @@ Set_local_dns_port(){
注意:大部分设备是不支持设置 非53端口的DNS服务器的,所以非必须请直接回车默认使用 53端口。" && echo
stty erase '^H' && read -p "(默认: 53):" dd_local_dns_port
[[ -z "$dd_local_dns_port" ]] && dd_local_dns_port="53"
expr ${dd_local_dns_port} + 0 &>/dev/null
echo $[${dd_local_dns_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${dd_local_dns_port} -ge 1 ]] && [[ ${dd_local_dns_port} -le 65535 ]]; then
echo && echo " ================================================"
Expand Down Expand Up @@ -359,15 +359,15 @@ Del_wrcd(){
echo "请根据上面的列表选择你要删除的 泛域名解析 序号数字 [ 2-${wrcd_json_num} ]"
stty erase '^H' && read -p "(默认回车取消):" del_wrcd_num
[[ -z "$del_wrcd_num" ]] && echo "已取消..." && exit 0
expr ${del_wrcd_num} + 0 &>/dev/null
echo $[${del_wrcd_num}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${del_wrcd_num} -ge 2 ]] && [[ ${del_wrcd_num} -le ${wrcd_json_num} ]]; then
wrcd_text=$(cat ${dowsdns_wrcd}|sed -n "${del_wrcd_num}p")
wrcd_name=$(echo -e "${wrcd_text}"|sed 's/\"//g;s/,//g'|awk -F ":" '{print $1}')
wrcd_ip=$(echo -e "${wrcd_text}"|sed 's/\"//g;s/,//g'|awk -F ":" '{print $2}')
del_wrcd_determine=$(echo ${wrcd_text:((${#wrcd_text} - 1))})
if [[ ${del_wrcd_num} == ${wrcd_json_num} ]]; then
del_wrcd_determine_num=$(expr $del_wrcd_num - 1)
del_wrcd_determine_num=$(echo $[${del_wrcd_num}-1])
sed -i "${del_wrcd_determine_num}s/,//g" ${dowsdns_wrcd}
fi
sed -i "${del_wrcd_num}d" ${dowsdns_wrcd}
Expand Down Expand Up @@ -401,7 +401,7 @@ Modify_wrcd(){
echo "请根据上面的列表选择你要修改的 泛域名解析 序号数字 [ 2-${wrcd_json_num} ]"
stty erase '^H' && read -p "(默认回车取消):" modify_wrcd_num
[[ -z "$modify_wrcd_num" ]] && echo "已取消..." && exit 0
expr ${modify_wrcd_num} + 0 &>/dev/null
echo $[${modify_wrcd_num}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${modify_wrcd_num} -ge 2 ]] && [[ ${modify_wrcd_num} -le ${wrcd_json_num} ]]; then
wrcd_name_now=$(cat ${dowsdns_wrcd}|sed -n "${modify_wrcd_num}p"|sed 's/\"//g;s/,//g'|awk -F ":" '{print $1}')
Expand Down
2 changes: 1 addition & 1 deletion goflyway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Set_port(){
echo -e "请输入 GoFlyway 监听端口 [1-65535](如果要伪装或者套CDN,那么只能使用端口:80 8080 8880 2052 2082 2086 2095)"
stty erase '^H' && read -p "(默认: 2333):" new_port
[[ -z "${new_port}" ]] && new_port="2333"
expr ${new_port} + 0 &>/dev/null
echo $[${new_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${new_port} -ge 1 ]] && [[ ${new_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down
2 changes: 1 addition & 1 deletion iptables-pf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Del_forwarding(){
View_forwarding
stty erase '^H' && read -p "请输入数字 来选择要删除的 iptables 端口转发规则(默认回车取消):" Del_forwarding_num
[[ -z "${Del_forwarding_num}" ]] && Del_forwarding_num="0"
expr ${Del_forwarding_num} + 0 &>/dev/null
echo $[${Del_forwarding_num}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${Del_forwarding_num} -ge 1 ]] && [[ ${Del_forwarding_num} -le ${forwarding_total} ]]; then
forwarding_type=$(echo -e "${forwarding_text}"| awk '{print $4}' | sed -n "${Del_forwarding_num}p")
Expand Down
4 changes: 2 additions & 2 deletions lightsocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Set_port(){
echo -e "请输入 Lightsocks 端口 [1-65535](端口不能重复,避免冲突)"
stty erase '^H' && read -p "(默认: 随机端口):" ls_port
[[ -z "${ls_port}" ]] && ls_port=$(Generate_the_port 443 65500)
expr ${ls_port} + 0 &>/dev/null
echo $[${ls_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ls_port} -ge 1 ]] && [[ ${ls_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down Expand Up @@ -228,7 +228,7 @@ Modify_config_password(){
password_num=$(cat "${lightsocks_conf}"|grep -n '"password":'|awk -F ':' '{print $1}')
if [[ ${password_num} -gt 0 ]];then
sed -i "${password_num}d" ${lightsocks_conf}
password_num_1=$(expr $password_num - 1)
password_num_1=$(echo $[${password_num}-1])
sed -i "${password_num_1}s/,//g" ${lightsocks_conf}
else
echo -e "${Error} 配置文件修改错误!"
Expand Down
2 changes: 1 addition & 1 deletion mtproxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Set_port(){
echo -e "请输入 MTProxy 端口 [1-65535]"
stty erase '^H' && read -p "(默认: 7000):" mtp_port
[[ -z "${mtp_port}" ]] && mtp_port="7000"
expr ${mtp_port} + 0 &>/dev/null
echo $[${mtp_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${mtp_port} -ge 1 ]] && [[ ${mtp_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down
4 changes: 2 additions & 2 deletions ocserv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Set_tcp_port(){
echo -e "请输入VPN服务端的TCP端口"
stty erase '^H' && read -p "(默认: 443):" set_tcp_port
[[ -z "$set_tcp_port" ]] && set_tcp_port="443"
expr ${set_tcp_port} + 0 &>/dev/null
echo $[${set_tcp_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${set_tcp_port} -ge 1 ]] && [[ ${set_tcp_port} -le 65535 ]]; then
echo && echo -e " TCP端口 : ${Red_font_prefix}${set_tcp_port}${Font_color_suffix}" && echo
Expand All @@ -267,7 +267,7 @@ Set_udp_port(){
echo -e "请输入VPN服务端的UDP端口"
stty erase '^H' && read -p "(默认: ${set_tcp_port}):" set_udp_port
[[ -z "$set_udp_port" ]] && set_udp_port="${set_tcp_port}"
expr ${set_udp_port} + 0 &>/dev/null
echo $[${set_udp_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${set_udp_port} -ge 1 ]] && [[ ${set_udp_port} -le 65535 ]]; then
echo && echo -e " TCP端口 : ${Red_font_prefix}${set_udp_port}${Font_color_suffix}" && echo
Expand Down
2 changes: 1 addition & 1 deletion pipes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Set_user_pipes(){
echo -e "请输入 PipeSocks 本地监听端口 [1-65535]"
stty erase '^H' && read -p "(默认: 2333):" pipes_port
[[ -z "$pipes_port" ]] && pipes_port="2333"
expr ${pipes_port} + 0 &>/dev/null
echo $[${pipes_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${pipes_port} -ge 1 ]] && [[ ${pipes_port} -le 65535 ]]; then
echo && echo "————————————————————"
Expand Down
2 changes: 1 addition & 1 deletion pserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Set_port(){
echo -e "请输入 Peerflix Server 监听端口 [1-65535](如果是绑定的域名,那么建议80端口)"
stty erase '^H' && read -p "(默认端口: 9000):" ps_port
[[ -z "${ps_port}" ]] && ps_port="9000"
expr ${ps_port} + 0 &>/dev/null
echo $[${ps_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ps_port} -ge 1 ]] && [[ ${ps_port} -le 65535 ]]; then
echo && echo "========================"
Expand Down
6 changes: 3 additions & 3 deletions socat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ addSocat(){
echo -e "请输入 Socat 的 本地监听端口 [1-65535]"
stty erase '^H' && read -p "(默认端口: 23333):" Socatport
[[ -z "$Socatport" ]] && Socatport="23333"
expr ${Socatport} + 0 &>/dev/null
echo $[${Socatport}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${Socatport} -ge 1 ]] && [[ ${Socatport} -le 65535 ]]; then
echo
Expand All @@ -92,7 +92,7 @@ addSocat(){
echo -e "请输入 Socat 远程被转发 端口 [1-65535]"
stty erase '^H' && read -p "(默认端口: ${Socatport}):" Socatport1
[[ -z "$Socatport1" ]] && Socatport1=${Socatport}
expr ${Socatport1} + 0 &>/dev/null
echo $[${Socatport1}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${Socatport1} -ge 1 ]] && [[ ${Socatport1} -le 65535 ]]; then
echo
Expand Down Expand Up @@ -241,7 +241,7 @@ delSocat(){
listSocat
stty erase '^H' && read -p "请输入数字 来选择要终止的 Socat 进程:" stopsocat
[[ -z "${stopsocat}" ]] && stopsocat="0"
expr ${stopsocat} + 0 &>/dev/null
echo $[${stopsocat}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${stopsocat} -ge 1 ]] && [[ ${stopsocat} -le ${socat_total} ]]; then
# 删除开机启动
Expand Down
2 changes: 1 addition & 1 deletion ssh_port.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Set_port(){
echo -e "请输入新的SSH端口 [1-65535]"
stty erase '^H' && read -p "(输入为空则取消):" new_port
[[ -z "${new_port}" ]] && echo "取消..." && exit 1
expr ${new_port} + 0 &>/dev/null
echo $[${new_port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${new_port} -ge 1 ]] && [[ ${new_port} -le 65535 ]]; then
if [[ ${new_port} == ${port} ]]; then
Expand Down
11 changes: 6 additions & 5 deletions ssr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Set_config_port(){
echo -e "请输入要设置的ShadowsocksR账号 端口"
stty erase '^H' && read -p "(默认: 2333):" ssr_port
[[ -z "$ssr_port" ]] && ssr_port="2333"
expr ${ssr_port} + 0 &>/dev/null
echo $[${ssr_port}+0] &>/dev/null
if [[ $? == 0 ]]; then
if [[ ${ssr_port} -ge 1 ]] && [[ ${ssr_port} -le 65535 ]]; then
echo && echo ${Separator_1} && echo -e " 端口 : ${Green_font_prefix}${ssr_port}${Font_color_suffix}" && echo ${Separator_1} && echo
Expand Down Expand Up @@ -409,7 +409,7 @@ Set_config_protocol_param(){
echo -e "${Tip} 设备数限制:每个端口同一时间能链接的客户端数量(多端口模式,每个端口都是独立计算),建议最少 2个。"
stty erase '^H' && read -p "(默认: 无限):" ssr_protocol_param
[[ -z "$ssr_protocol_param" ]] && ssr_protocol_param="" && echo && break
expr ${ssr_protocol_param} + 0 &>/dev/null
echo $[${ssr_protocol_param}+0] &>/dev/null
if [[ $? == 0 ]]; then
if [[ ${ssr_protocol_param} -ge 1 ]] && [[ ${ssr_protocol_param} -le 9999 ]]; then
echo && echo ${Separator_1} && echo -e " 设备数限制 : ${Green_font_prefix}${ssr_protocol_param}${Font_color_suffix}" && echo ${Separator_1} && echo
Expand All @@ -429,7 +429,7 @@ Set_config_speed_limit_per_con(){
echo -e "${Tip} 单线程限速:每个端口 单线程的限速上限,多线程即无效。"
stty erase '^H' && read -p "(默认: 无限):" ssr_speed_limit_per_con
[[ -z "$ssr_speed_limit_per_con" ]] && ssr_speed_limit_per_con=0 && echo && break
expr ${ssr_speed_limit_per_con} + 0 &>/dev/null
echo $[${ssr_speed_limit_per_con}+0] &>/dev/null
if [[ $? == 0 ]]; then
if [[ ${ssr_speed_limit_per_con} -ge 1 ]] && [[ ${ssr_speed_limit_per_con} -le 131072 ]]; then
echo && echo ${Separator_1} && echo -e " 单线程限速 : ${Green_font_prefix}${ssr_speed_limit_per_con} KB/S${Font_color_suffix}" && echo ${Separator_1} && echo
Expand All @@ -450,7 +450,7 @@ Set_config_speed_limit_per_user(){
echo -e "${Tip} 端口总限速:每个端口 总速度 限速上限,单个端口整体限速。"
stty erase '^H' && read -p "(默认: 无限):" ssr_speed_limit_per_user
[[ -z "$ssr_speed_limit_per_user" ]] && ssr_speed_limit_per_user=0 && echo && break
expr ${ssr_speed_limit_per_user} + 0 &>/dev/null
echo $[${ssr_speed_limit_per_user}+0] &>/dev/null
if [[ $? == 0 ]]; then
if [[ ${ssr_speed_limit_per_user} -ge 1 ]] && [[ ${ssr_speed_limit_per_user} -le 131072 ]]; then
echo && echo ${Separator_1} && echo -e " 端口总限速 : ${Green_font_prefix}${ssr_speed_limit_per_user} KB/S${Font_color_suffix}" && echo ${Separator_1} && echo
Expand Down Expand Up @@ -1085,7 +1085,8 @@ Del_multi_port_user(){
del_user_determine=`echo ${del_user:((${#del_user} - 1))}`
if [[ ${del_user_determine} != "," ]]; then
del_user_num=$(sed -n -e "/${port}/=" ${config_user_file})
del_user_num=$(expr $del_user_num - 1)
echo $[${ssr_protocol_param}+0] &>/dev/null
del_user_num=$(echo $[${del_user_num}-1])
sed -i "${del_user_num}s/,//g" ${config_user_file}
fi
sed -i "/${port}/d" ${config_user_file}
Expand Down
4 changes: 3 additions & 1 deletion ssr_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set_config_port(){
echo -e "请输入 ShadowsocksR 账号端口"
stty erase '^H' && read -p "(默认: 2333):" port
[[ -z "$port" ]] && port="2333"
expr ${port} + 0 &>/dev/null
echo $[${port}+0] &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${port} -ge 1 ]] && [[ ${port} -le 65535 ]]; then
echo && echo -e " 端口 : ${Red_font_prefix}${port}${Font_color_suffix}" && echo
Expand Down Expand Up @@ -279,6 +279,7 @@ ssr_config(){
fi
fi
passwd=$(echo -e "${passwd_base64}"|base64 -d)
[[ ${debug} == [Yy] ]] && echo -e "${ip}\n${port}\n${method}\n${passwd}\n${protocol}\n${obfs}\n"
if [[ -z ${ip} ]] || [[ -z ${port} ]] || [[ -z ${method} ]] || [[ -z ${passwd} ]] || [[ -z ${protocol} ]] || [[ -z ${obfs} ]]; then
echo -e "${Error} 错误,有部分 账号参数为空![ ${ip} ,${port} ,${method} ,${passwd} ,${protocol} ,${obfs} ]" | tee -a ${log_file}
if [[ ${analysis_type} == "add" ]]; then
Expand Down Expand Up @@ -356,6 +357,7 @@ View_log(){
cat "${log_file}"
}
action=$1
debug=$2
if [[ ${1} == "t" ]]; then
Test
elif [[ ${1} == "a" ]]; then
Expand Down
Loading

0 comments on commit fb9ba84

Please sign in to comment.