#---------------【ShadowSocks】----------------- shadowsocksAdd() { ciphers="aes-256-gcm aes-192-gcm aes-128-gcm aes-256-ctr aes-192-ctr aes-128-ctr aes-256-cfb aes-192-cfb aes-128-cfb camellia-128-cfb camellia-192-cfb camellia-256-cfb xchacha20-ietf-poly1305 chacha20-ietf-poly1305 chacha20-ietf chacha20 salsa20 rc4-md5" v2ray_ciphers="auto aes-128-cfb aes-128-gcm chacha20-poly1305 none" protocols="origin verify_deflate auth_sha1_v4 auth_aes128_md5 auth_aes128_sha1 auth_chain_a auth_chain_b auth_chain_c auth_chain_d auth_chain_e auth_chain_f" obfs="plain http_simple http_post tls1.2_ticket_auth tls1.2_ticket_fastauth" read -p "选择${appname}节点类型[1.ss 2.ssr 3.v2ray] " proxy_type case "$proxy_type" in 1) proxy_type="ss" ;; 2) proxy_type="ssr" ;; 3) proxy_type="v2ray" ;; *) echo "服务器类型输入错误!" && return ;; esac if [ "$proxy_type" = "v2ray" ]; then read -p "输入v2ray节点名:" ss_id read -p "输入v2ray服务器地址:" ss_server read -p "输入v2ray服务器端口:" ss_port echo "选择v2ray加密方式(不一定都支持):" echo $v2ray_ciphers | tr " " "\n" | grep -n . | sed -e "s/:/) /g" read -p "输入v2ray加密方式(选择或输入):" ss_method if [ -n "$(echo $ss_method | grep "[0-9][0-9]*")" ]; then ss_method="$(echo $v2ray_ciphers | tr " " "\n" | sed -n "$ss_method"p)" [ -z "$ss_method" ] && echo "输入错误!" && return fi read -p "输入v2ray用户ID:" ss_uuid read -p "输入v2ray额外ID:" ss_alterid read -p "输入v2ray传输协议[1.tcp 2.kcp 3.ws 4.h2]:" ss_network case "$ss_network" in 1) ss_network="tcp" read -p "输入v2ray伪装类型tcp[1.不伪装 2.伪装http]:" ss_headtype_tcp if [ "$ss_headtype_tcp" = "http" ]; then ss_headtype_tcp="http" read -p "输入v2ray伪装域名(回车不添加):" ss_network_host else ss_headtype_tcp="none" fi ;; 2) ss_network="kcp" echo -e "1.不伪装\n2.伪装视频通话(srtp)\n3.伪装BT下载(uTP)\n4.伪装微信视频通话" read -p "选择v2ray伪装类型kcp:" ss_headtype_kcp case "$ss_headtype_kcp" in 1) ss_headtype_kcp="none" ;; 2) ss_headtype_kcp="srtp" ;; 3) ss_headtype_kcp="utp" ;; 4) ss_headtype_kcp="wechat-video" ;; *) ss_headtype_kcp="none" ;; esac ;; 3) ss_network="ws" read -p "输入v2ray路径(回车不添加):" ss_network_path read -p "输入v2ray伪装域名(回车不添加):" ss_network_host ;; 4) ss_network="h2" read -p "输入v2ray路径(回车不添加):" ss_network_path read -p "输入v2ray伪装域名(回车不添加):" ss_network_host ;; *) echo "输入错误!" && return esac read -p "输入v2ray底层安全传输[1.tls 2.none]:" ss_network_security case $ss_network_security in 1) ss_network_security="tls" ;; 2) ss_network_security="none" ;; *) ss_network_security="none" ;; esac read -p "启用v2ray多路复用?[1/0] " ss_mux_enable [ -n "$ss_mux_enable" ] && ss_mux_enable="$ss_mux_enable" case "$ss_mux_enable" in 1) ss_mux_enable="true" ;; 0) ss_mux_enable="false" ;; esac read -p "输入v2ray并发连接数(默认8):" ss_mux_concurrency [ -z "$ss_mux_concurrency" ] && ss_mux_concurrency=8 else read -p "输入${appname}节点名:" ss_id read -p "输入${appname}服务器地址:" ss_server read -p "输入${appname}服务器端口:" ss_port read -p "输入${appname}服务器密码:" ss_passwd echo "选择${appname}加密方式(不一定都支持):" echo $ciphers | tr " " "\n" | grep -n . | sed -e "s/:/) /g" read -p "输入${appname}加密方式(选择或输入):" ss_method if [ -n "$(echo $ss_method | grep "[0-9][0-9]*")" ]; then ss_method="$(echo $ciphers | tr " " "\n" | sed -n "$ss_method"p)" [ -z "$ss_method" ] && echo "输入错误!" && return fi if [ "$proxy_type" = 'ssr' ]; then echo "选择ssr协议(不一定都支持):" echo $protocols | tr " " "\n" | grep -n . | sed -e "s/:/) /g" read -p "输入${appname}协议protocols(ss请回车):" ss_protocol if [ -n "$(echo $ss_protocol | grep "[0-9][0-9]*")" -a -n "$ss_protocol" ]; then ss_protocol="$(echo $protocols | tr " " "\n" | sed -n "$ss_protocol"p)" [ -z "$ss_protocol" ] && echo "输入错误!" && return fi echo "选择ssr混淆(不一定都支持):" echo $obfs | tr " " "\n" | grep -n . | sed -e "s/:/) /g" read -p "输入${appname}混淆obfs:" ss_obfs if [ -n "$(echo $ss_obfs | grep "[0-9][0-9]*")" -a -n "$ss_obfs" ]; then ss_obfs="$(echo $obfs | tr " " "\n" | sed -n "$ss_obfs"p)" [ -z "$ss_obfs" ] && echo "输入错误!" && return fi read -p "输入${appname}协议参数protocol_param(没有请回车):" ss_protocol_param read -p "输入${appname}混淆参数obfs_param(没有请回车):" ss_obfs_param fi fi echo "你要添加的节点信息为:" if [ "$proxy_type" = "v2ray" ]; then cat << EOF 服务器v2ray类型:$proxy_type 服务器v2ray名称:$ss_id 服务器v2ray地址:$ss_server 服务器v2ray端口号:$ss_port 服务器v2ray加密方式:$ss_method 服务器v2ray用户ID:$ss_uuid 服务器v2ray额外ID:$ss_alterid 服务器v2ray传输协议:$ss_network 服务器v2ray的tcp伪装类型:$ss_headtype_tcp 服务器v2ray伪装域名:$ss_network_host 服务器v2ray的kcp伪装类型:$ss_headtype_kcp 服务器v2ray路径:$ss_network_path 服务器v2ray伪装域名:$ss_network_host 服务器v2ray底层安全传输:$ss_network_security 服务器v2ray多路复用:$ss_mux_enable 服务器v2ray并发连接数:$ss_mux_concurrency EOF else cat << EOF 服务器ss类型:$proxy_type 服务器ss名称:$ss_id 服务器ss地址:$ss_server 服务器ss端口号:$ss_port 服务器ss密码:$ss_passwd 服务器ss加密方式:$ss_method 服务器ssr协议:$ss_protocol 服务器ssr混淆:$ss_obfs 服务器ssr协议参数:$ss_protocol_param 服务器ssr混淆参数:$ss_obfs_param EOF fi read -p "确定要添加此服务器?[1/0] " res if [ "$res" == '1' ]; then sed -i "/,$ss_id,/d" $SSID.conf if [ "$proxy_type" = "ss" -o "$proxy_type" = "ssr" ]; then echo "$proxy_type,$ss_id,$ss_server,$ss_port,$ss_passwd,$ss_method,$ss_protocol,$ss_obfs,$ss_protocol_param,$ss_obfs_param" >> $SSID.conf else echo "$proxy_type,$ss_id,$ss_server,$ss_port,$ss_method,$ss_uuid,$ss_alterid,$ss_network,$ss_headtype_tcp,$ss_headtype_kcp,$ss_network_host,$ss_network_path,$ss_network_security,$ss_mux_enable,$ss_mux_concurrency" >> $SSID.conf fi fi read -p "添加完成,再添加一个?[1/0] " res if checkread $res; then [ "$res" == '1' ] && shadowsocksAdd fi } shadowsocksDel() { echo "${appname}节点:" cat $SSID.conf | sed -e 's/.*/[&]/g' | grep -n . | sed -e 's/:/\./g' | while read line do [ "${#line}" -gt 70 ] && line="$(echo ${line} | cut -b 1-70)"... echo ${line} done read -p "请选择要删除的节点:" res [ -n "$res" ] && sed -i "$res"d $SSID.conf read -p "删除完成,继续删除?[1/0] " res if checkread $res; then [ "$res" == '1' ] && shadowsocksDel fi } shadowsocks() { eval `mbdb export shadowsocks` source /etc/mixbox/bin/base SSID=${mbroot}/apps/${appname}/config/ssserver black_list=${mbroot}/apps/${appname}/config/customize_black.conf white_list=${mbroot}/apps/${appname}/config/customize_white.conf [ ! -f $SSID.conf ] && touch $SSID.conf [ ! -f "$black_list" ] && touch $black_list [ ! -f "$white_list" ] && touch $white_list # sslist=$(cat $SSID* | cut -d, -f2 | grep -n . | sed -e 's/:/./g') control=${mbroot}/apps/${appname}/config/sscontrol.conf [ ! -f "$control" ] && touch $control echo "********* $service ***********" echo "[最好的翻墙工具,没有之一,还可以加速国内外游戏]" readsh "启动${appname}服务[1/0] " "enable" "1" if [ "$enable" == '1' ]; then # [ -z "$sslist" ] && sslist="空" # echo "${appname}节点:[`echo $sslist`]" read -p "添加${appname}节点?[1/0] " res if [ "$res" == '1' ]; then read -p "选择添加方式[1.手动添加 2.订阅地址 3.uri地址] " res if [ "$res" == '1' ]; then shadowsocksAdd elif [ "$res" == '2' ]; then cat ${mbroot}/apps/${appname}/config/subscribe_link.txt 2> /dev/null | grep -v "^$" read -p "清空订阅地址列表后再添加?[1/0] " res [ "$res" = '1' ] && cat /dev/null > ${mbroot}/apps/${appname}/config/subscribe_link.txt while(true) do read -p "请输入ssr节点订阅地址(回车停止添加):" res [ -z "$res" ] && break || echo "$res" >> ${mbroot}/apps/${appname}/config/subscribe_link.txt done if [ -n "$(cat ${mbroot}/apps/${appname}/config/subscribe_link.txt)" ]; then ${mbroot}/apps/${appname}/scripts/ss_online_update.sh [ "$?" -ne 0 ] && echo "订阅失败,退出插件配置!" && return 1 fi read -p "是否需要删除所有的订阅节点?[1/0] " res [ "$res" = '1' ] && rm -rf ${mbroot}/apps/${appname}/config/ssserver_online.conf elif [ "$res" == '3' ]; then read -p "请输入ssr节点uri地址:" res if [ ! -z "$res" ]; then ${mbroot}/apps/${appname}/scripts/ss_online_update.sh add "$res" fi fi fi # sslist=$(cat $SSID* | cut -d, -f2 | grep -n . | sed -e 's/:/./g') id=$(mbdb get ${appname}.main.id) ss_mode=$(mbdb get ${appname}.main.ss_mode) [ -z "$id" ] && id="空" [ -z $ss_mode ] && ss_mode="空" read -p "修改${appname}配置($id, $ss_mode)?[1/0] " res if [ "$res" == '1' ]; then # [ -z "$sslist" ] && sslist="空" echo "${appname}节点:" cat $SSID* | sed -e 's/.*/[&]/g' | grep -n . | sed -e 's/:/\./g' | while read line do [ "${#line}" -gt 70 ] && line="$(echo ${line} | cut -b 1-70)"... echo ${line} done read -p "请选择${appname}节点:" res if [ -n "$res" ]; then id=$(cat $SSID* | cut -d, -f2 | sed -n "$res"p) [ ! -z "$id" ] && mbdb set $appname.main.id="$id" fi echo "[1.黑名单模式 2.白名单模式 3.全局模式 4.回国模式]" read -p "请选择${appname}模式:" res if [ ! -z "$res" ]; then case "$res" in 1) res="gfwlist" ;; 2) res="whitelist" ;; 3) res="wholemode" ;; 4) res="homemode" ;; *) res="gfwlist" ;; esac mbdb set $appname.main.ss_mode="$res" fi fi read -p "进入${appname}高级设置?[1/0] " res if [ "$res" == '1' ]; then read -p "删除${appname}节点?[1/0] " res [ "$res" == '1' ] && shadowsocksDel if [ -n "$(lsmod | grep TPROXY)" ]; then read -p "启动${appname}游戏模式?[1/0] " res checkread $res && mbdb set $appname.main.ssgena="$res" if [ "$res" == '1' ]; then ssgid=$(mbdb get ${appname}.main.ssgid) ssg_mode=$(mbdb get ${appname}.main.ssg_mode) [ -z "$ssgid" ] && ssgid="空" [ -z "$ssg_mode" ] && ssg_mode="空" read -p "修改${appname}游戏配置($ssgid, $ssg_mode)?[1/0] " res if [ "$res" == '1' ]; then echo "${appname}节点:" cat $SSID* | sed -e 's/.*/[&]/g' | grep -n . | sed -e 's/:/\./g' | while read line do [ "${#line}" -gt 70 ] && line="$(echo ${line} | cut -b 1-70)"... echo ${line} done read -p "请选择${appname}游戏节点:" res ssgid=$(cat $SSID* | cut -d, -f2 | sed -n "$res"p) [ ! -z "$ssgid" ] && mbdb set $appname.main.ssgid="$ssgid" echo "[1.国内游戏 2.国外游戏]" read -p "请选择${appname}游戏模式:" res if [ ! -z "$res" ]; then case "$res" in 1) res="cngame" ;; 2) res="frgame" ;; *) res="frgame" ;; esac mbdb set $appname.main.ssg_mode="$res" fi fi fi fi # smartdns # if [ "$(mbdb get smartdns.main.enable)" = '1' ]; then # readsh "是否使用SmartDNS作为ss的DNS解析" "smartdns" "1" # fi # kcptun readsh "是否启动${appname}的kcptun加速(需要服务端支持)[1/0] " "kcp_enable" "0" if [ "$kcp_enable" = '1' ]; then echo "以下除了服务端配置,不清楚默认即可!" readsh "请输入加速kcp服务器地址" "ss_kcp_node" readsh "请输入加速kcp服务器端口" "ss_kcp_port" readsh "请输入加速kcp服务器密码(--key)" "ss_kcp_password" readsh "请输入加速kcp模式(--mode)" "ss_kcp_mode" "fast" readsh "请输入加速kcp加密方式(--crypt)" "ss_kcp_crypt" "aes" read -p "剩余一些不必要的配置,是否继续?[1/0] " res if [ "$res" = '1' ]; then readsh "请输入加速kcp的MTU(--mtu)" "ss_kcp_mtu" "1350" readsh "请输入加速kcp发送窗口(--sndwnd)" "ss_kcp_sndwnd" "128" readsh "请输入加速kcp接收窗口(--rcvwnd)" "ss_kcp_rcvwnd" "1024" readsh "请输入加速kcp链接数(--conn)" "ss_kcp_conn" "1" readsh "请输入加速kcp关闭数据压缩(--nocomp)" "ss_kcp_compon" "1" readsh "请输入加速kcp的其他配置项" "ss_kcp_config" fi fi # 显示局域网控制 cat $control | while read line do name=$(cutsh ${line} 1) mode=$(cutsh ${line} 3) case "$mode" in 0) mode="不走代理" ;; 1) mode="科学上网" ;; *) mode="空" ;; esac echo "设备[$name]运行模式为: $mode" done mode=$(mbdb get ${appname}.main.ss_proxy_default_mode) case "$mode" in 0) mode="不走代理" ;; 1) mode="科学上网" ;; *) mode="科学上网" ;; esac echo "其余设备运行模式为: $mode" read -p "设置局域网代理控制?[1/0] " res if [ "$res" == '1' ]; then read -p "清空之前的配置再添加?[1/0] " res [ "$res" == '1' ] && echo -n > $control i=0 cat /tmp/dhcp.leases | while read line do name=$(echo ${line} | cut -d' ' -f4) mac=$(echo ${line} | cut -d' ' -f2) ip=$(echo ${line} | cut -d' ' -f3) let i=$i+1 echo "$i. $name [$ip] [$mac]" done while(true) do read -p "请选择一个设备:" res if [ ! -z "$res" ]; then line=$(cat /tmp/dhcp.leases | grep -n . | grep -w "^$res") name=$(echo ${line} | cut -d' ' -f4) mac=$(echo ${line} | cut -d' ' -f2) read -p "请选择代理模式(0.不走代理 1.科学上网):" ssproxy if [ -n "$(lsmod | grep TPROXY)" ]; then read -p "请选择游戏模式(0.不走游戏 1.游戏加速):" ssgame fi if checkread $ssproxy; then if [ ! -z "$mac" ]; then [ -z "$ssgame" ] && ssgame=0 sed -i "/^$name,$mac/d" $control echo "$name,$mac,$ssproxy,$ssgame" >> $control else echo "mac不能为空, 添加失败!" fi else echo "输入有误, 添加失败" fi read -p "继续增加设备?[1/0] " res [ "$res" == '0' -o -z "$res" ] && break else echo "输入为空,跳过..." break fi done readsh "请选择其余设备代理模式(0.不走代理 1.科学上网):" "ss_proxy_default_mode" "1" if [ -n "$(lsmod | grep TPROXY)" ]; then readsh "请选择其余设备游戏模式(0.不走游戏 1.游戏加速):" "ss_game_default_mode" "1" fi fi read -p "添加自定义规则(支持ip和域名)?[1/0] " res if [ "$res" == '1' ]; then read -p "添加黑名单规则?[1/0] " res if [ "$res" == '1' ]; then echo "黑名单规则列表:" cat $black_list read -p "请选择添加方式(1.覆盖添加 2.追加规则):" res [ "$res" == '1' ] && echo -n > $black_list while(true) do read -p "输入域名网址(exit结束输入):" res [ "$res" == "exit" -o -z "$res" ] && break echo "$res" >> $black_list done fi read -p "添加白名单规则?[1/0] " res if [ "$res" == '1' ]; then echo "白名单规则列表:" cat $white_list read -p "请选择添加方式(1.覆盖添加 2.追加规则):" res [ "$res" == '1' ] && echo -n > $white_list while(true) do read -p "输入域名网址(exit结束输入):" res [ "$res" == "exit" -o -z "$res" ] && break echo "$res" >> $white_list done fi fi [ "$dns_red_enable" != '1' ] && dns_red_text="不重定向" || dns_red_text="重定向" [ -z "$DNS_SERVER" ] && DNS_SERVER=8.8.8.8 [ -z "$DNS_SERVER_PORT" ] && DNS_SERVER_PORT=53 read -p "修改DNS配置($dns_red_text, $DNS_SERVER, $DNS_SERVER_PORT)?[1/0] " res if [ "$res" == '1' ]; then read -p "启用DNS重定向?[1/0] " res [ -n "$res" ] && mbdb set $appname.main.dns_red_enable="$res" if [ "$res" == '1' ]; then [ -z "$dns_red_ip" ] && dns_red_ip="$lanip" read -p "修改DNS重定向IP地址($dns_red_ip):" res [ -n "$res" ] && mbdb set $appname.main.dns_red_ip="$res" fi read -p "输入代理使用DNS服务器($DNS_SERVER):" res [ -n "$res" ] && mbdb set $appname.main.DNS_SERVER="$res" read -p "输入代理使用DNS端口号($DNS_SERVER_PORT):" res [ -n "$res" ] && mbdb set $appname.main.DNS_SERVER_PORT="$res" fi fi ${mbroot}/apps/${appname}/scripts/${appname}.sh restart else ${mbroot}/apps/${appname}/scripts/${appname}.sh stop fi } #---------------【ShadowSocks】-----------------