Files
MIXBOX-ARCHIVE/apps/frpc/config/mixbox.conf
2020-03-05 00:08:40 +08:00

97 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#------------------【Frpc】--------------------
frpcAdd() {
read -p "请输入${appname}名称:" name
[ -z "$name" ] && return
read -p "请输入${appname}类型(1.http 2.tcp)" type
read -p "请输入${appname}本地ip(回车默认$lanip)" local_ip
read -p "请输入${appname}本地端口:" local_port
remote_port="" && domain=""
[ "$type" == '2' ] && read -p "请输入${appname}远程访问端口:" remote_port
[ "$type" == '1' ] && read -p "请输入${appname}域名(自动识别子域名或自定义域名)" domain
if [ ! -z $name ]; then
[ -z $local_ip ] && local_ip=$lanip
if [ "$type" == '1' ]; then
type=http
elif [ "$type" == '2' ]; then
type=tcp
else
type="输入有误"
fi
read -p "确定要添加配置:$name,$type,$local_ip,$local_port,$remote_port,$domain[1/0] " res
if [ "$res" == '1' ]; then
mbdb set $appname.info.$name="$type,$local_ip,$local_port,$remote_port,$domain"
fi
fi
read -p "添加完成,再添加一个?[1/0] " res
if checkread $res; then
[ "$res" == '1' ] && frpcAdd
fi
}
frpcDel() {
frpclist=$(mbdb keys $appname.info)
echo "${appname}穿透配置[`echo $frpclist`]"
read -p "请输入要删除的配置名:" res
[ ! -z "$res" ] && mbdb del $appname.info.$res
read -p "删除完成,继续删除?[1/0] " res
if checkread $res; then
[ "$res" == '1' ] && frpcDel
fi
}
frpc() {
eval `mbdb export frpc`
source /etc/mixbox/bin/base
echo "********* $service ***********"
echo "[${appinfo}]"
readsh "启动${appname}服务[1/0] " "enable" "1"
if [ "$enable" == '1' ]; then
echo "1.[0.9.3] 2.[0.17.0] 3.[0.20.0]"
read -p "请选择${appname}运行版本(回车不修改,默认最新)" res
case "$res" in
1) res="0.9.3" ;;
2) res="0.17.0" ;;
3) res="0.20.0" ;;
*) res="" ;;
esac
[ -z "$res" ] && [ -z "$runver" ] && res="0.20.0"
[ -n "$res" ] && mbdb set $appname.main.runver="$res"
[ -z "$server" ] && server="空"
[ -z "$server_port" ] && server_port="空"
[ -z "$token" ] && token="空"
read -p "修改${appname}服务器($server, $server_port, $token)[1/0] " res
if [ "$res" == '1' ]; then
read -p "请输入${appname}服务器:" res
[ ! -z "$res" ] && mbdb set $appname.main.server="$res"
read -p "请输入${appname}服务器端口:" res
[ ! -z "$res" ] && mbdb set $appname.main.server_port="$res"
read -p "请输入${appname}服务器秘钥:" res
[ ! -z "$res" ] && mbdb set $appname.main.token="$res"
if [ "$(mbdb get ${appname}.main.runver)" != "0.9.3" ]; then
read -p "请输入${appname}的tcp_mux配置(true/false)" res
[ -n "$res" ] && mbdb set $appname.main.tcp_mux="$res"
read -p "请输入${appname}的user配置" res
[ -n "$res" ] && mbdb set $appname.main.user="$res"
read -p "请输入${appname}的协议配置protocol" res
[ -n "$res" ] && mbdb set $appname.main.protocol="$res"
fi
fi
frpclist=$(mbdb keys $appname.info)
[ -z "$frpclist" ] && frpclist="空"
echo "${appname}穿透配置[`echo $frpclist`]"
read -p "添加${appname}穿透配置?[1/0] " res
[ "$res" == '1' ] && frpcAdd
read -p "删除${appname}穿透配置?[1/0] " res
[ "$res" == '1' ] && frpcDel
${mbroot}/apps/${appname}/scripts/${appname}.sh restart
else
${mbroot}/apps/${appname}/scripts/${appname}.sh stop
fi
}
#------------------【Frpc】--------------------