C-SSR.sh 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061
  1. #!/bin/bash
  2. #25/01/2021
  3. clear
  4. clear
  5. msg -bar
  6. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  7. export PATH
  8. SCPfrm="/etc/ger-frm" && [[ ! -d ${SCPfrm} ]] && mkdir ${SCPfrm}
  9. BARRA1="\e[0;31m--------------------------------------------------------------------\e[0m"
  10. SCPinst="/etc/ger-inst" && [[ ! -d ${SCPfrm} ]] && mkdir ${SCPfrm}
  11. sh_ver="1.0.26"
  12. filepath=$(
  13. cd "$(dirname "$0")"
  14. pwd
  15. )
  16. file=$(echo -e "${filepath}" | awk -F "$0" '{print $1}')
  17. ssr_folder="/usr/local/shadowsocksr"
  18. config_file="${ssr_folder}/config.json"
  19. config_user_file="${ssr_folder}/user-config.json"
  20. config_user_api_file="${ssr_folder}/userapiconfig.py"
  21. config_user_mudb_file="${ssr_folder}/mudb.json"
  22. ssr_log_file="${ssr_folder}/ssserver.log"
  23. Libsodiumr_file="/usr/local/lib/libsodium.so"
  24. Libsodiumr_ver_backup="1.0.16"
  25. Server_Speeder_file="/serverspeeder/bin/serverSpeeder.sh"
  26. LotServer_file="/appex/bin/serverSpeeder.sh"
  27. BBR_file="${file}/bbr.sh"
  28. jq_file="${ssr_folder}/jq"
  29. Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
  30. Info="${Green_font_prefix}[ INFORMACION ]${Font_color_suffix}"
  31. Error="${Red_font_prefix}[# ERROR #]${Font_color_suffix}"
  32. Tip="${Green_font_prefix}[ NOTA ]${Font_color_suffix}"
  33. Separator_1="——————————————————————————————"
  34. check_root() {
  35. [[ $EUID != 0 ]] && echo -e "${Error} La cuenta actual no es ROOT (no tiene permiso ROOT), no puede continuar la operacion, por favor ${Green_background_prefix} sudo su ${Font_color_suffix} Venga a ROOT (le pedire que ingrese la contraseña de la cuenta actual despues de la ejecucion)" && exit 1
  36. }
  37. check_sys() {
  38. if [[ -f /etc/redhat-release ]]; then
  39. release="centos"
  40. elif cat /etc/issue | grep -q -E -i "debian"; then
  41. release="debian"
  42. elif cat /etc/issue | grep -q -E -i "ubuntu"; then
  43. release="ubuntu"
  44. elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
  45. release="centos"
  46. elif cat /proc/version | grep -q -E -i "debian"; then
  47. release="debian"
  48. elif cat /proc/version | grep -q -E -i "ubuntu"; then
  49. release="ubuntu"
  50. elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
  51. release="centos"
  52. fi
  53. bit=$(uname -m)
  54. }
  55. check_pid() {
  56. PID=$(ps -ef | grep -v grep | grep server.py | awk '{print $2}')
  57. }
  58. check_crontab() {
  59. [[ ! -e "/usr/bin/crontab" ]] && echo -e "${Error}Falta de dependencia Crontab, Por favor, intente instalar manualmente CentOS: yum install crond -y , Debian/Ubuntu: apt-get install cron -y !" && exit 1
  60. }
  61. SSR_installation_status() {
  62. [[ ! -e ${ssr_folder} ]] && echo -e "${Error}\nShadowsocksR No se encontro la carpeta, por favor verifique\n$(msg -bar)" && exit 1
  63. }
  64. Server_Speeder_installation_status() {
  65. [[ ! -e ${Server_Speeder_file} ]] && echo -e "${Error}No instalado (Server Speeder), Por favor compruebe!" && exit 1
  66. }
  67. LotServer_installation_status() {
  68. [[ ! -e ${LotServer_file} ]] && echo -e "${Error}No instalado LotServer, Por favor revise!" && exit 1
  69. }
  70. BBR_installation_status() {
  71. if [[ ! -e ${BBR_file} ]]; then
  72. echo -e "${Error} No encontre el script de BBR, comience a descargar ..."
  73. cd "${file}"
  74. if ! wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/bbr.sh; then
  75. echo -e "${Error} BBR script descargar!" && exit 1
  76. else
  77. echo -e "${Info} BBR script descarga completa!"
  78. chmod +x bbr.sh
  79. fi
  80. fi
  81. }
  82. #Establecer reglas de firewall
  83. Add_iptables() {
  84. if [[ ! -z "${ssr_port}" ]]; then
  85. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${ssr_port} -j ACCEPT
  86. iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${ssr_port} -j ACCEPT
  87. ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${ssr_port} -j ACCEPT
  88. ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport ${ssr_port} -j ACCEPT
  89. fi
  90. }
  91. Del_iptables() {
  92. if [[ ! -z "${port}" ]]; then
  93. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT
  94. iptables -D INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT
  95. ip6tables -D INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT
  96. ip6tables -D INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT
  97. fi
  98. }
  99. Save_iptables() {
  100. if [[ ${release} == "centos" ]]; then
  101. service iptables save
  102. service ip6tables save
  103. else
  104. iptables-save >/etc/iptables.up.rules
  105. ip6tables-save >/etc/ip6tables.up.rules
  106. fi
  107. }
  108. Set_iptables() {
  109. if [[ ${release} == "centos" ]]; then
  110. service iptables save
  111. service ip6tables save
  112. chkconfig --level 2345 iptables on
  113. chkconfig --level 2345 ip6tables on
  114. else
  115. iptables-save >/etc/iptables.up.rules
  116. ip6tables-save >/etc/ip6tables.up.rules
  117. echo -e '#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules\n/sbin/ip6tables-restore < /etc/ip6tables.up.rules' >/etc/network/if-pre-up.d/iptables
  118. chmod +x /etc/network/if-pre-up.d/iptables
  119. fi
  120. }
  121. #Leer la informaci�n de configuraci�n
  122. Get_IP() {
  123. ip=$(wget -qO- -t1 -T2 ipinfo.io/ip)
  124. if [[ -z "${ip}" ]]; then
  125. ip=$(wget -qO- -t1 -T2 api.ip.sb/ip)
  126. if [[ -z "${ip}" ]]; then
  127. ip=$(wget -qO- -t1 -T2 members.3322.org/dyndns/getip)
  128. if [[ -z "${ip}" ]]; then
  129. ip="VPS_IP"
  130. fi
  131. fi
  132. fi
  133. }
  134. Get_User_info() {
  135. Get_user_port=$1
  136. user_info_get=$(python mujson_mgr.py -l -p "${Get_user_port}")
  137. match_info=$(echo "${user_info_get}" | grep -w "### user ")
  138. if [[ -z "${match_info}" ]]; then
  139. echo -e "${Error}La adquisicion de informacion del usuario fallo ${Green_font_prefix}[Puerto: ${ssr_port}]${Font_color_suffix} " && exit 1
  140. fi
  141. user_name=$(echo "${user_info_get}" | grep -w "user :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  142. msg -bar
  143. port=$(echo "${user_info_get}" | grep -w "port :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  144. msg -bar
  145. password=$(echo "${user_info_get}" | grep -w "passwd :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  146. msg -bar
  147. method=$(echo "${user_info_get}" | grep -w "method :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  148. msg -bar
  149. protocol=$(echo "${user_info_get}" | grep -w "protocol :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  150. msg -bar
  151. protocol_param=$(echo "${user_info_get}" | grep -w "protocol_param :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  152. msg -bar
  153. [[ -z ${protocol_param} ]] && protocol_param="0(Ilimitado)"
  154. msg -bar
  155. obfs=$(echo "${user_info_get}" | grep -w "obfs :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  156. msg -bar
  157. #transfer_enable=$(echo "${user_info_get}"|grep -w "transfer_enable :"|sed 's/[[:space:]]//g'|awk -F ":" '{print $NF}'|awk -F "ytes" '{print $1}'|sed 's/KB/ KB/;s/MB/ MB/;s/GB/ GB/;s/TB/ TB/;s/PB/ PB/')
  158. #u=$(echo "${user_info_get}"|grep -w "u :"|sed 's/[[:space:]]//g'|awk -F ":" '{print $NF}')
  159. #d=$(echo "${user_info_get}"|grep -w "d :"|sed 's/[[:space:]]//g'|awk -F ":" '{print $NF}')
  160. forbidden_port=$(echo "${user_info_get}" | grep -w "Puerto prohibido :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  161. [[ -z ${forbidden_port} ]] && forbidden_port="Permitir todo"
  162. msg -bar
  163. speed_limit_per_con=$(echo "${user_info_get}" | grep -w "speed_limit_per_con :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  164. msg -bar
  165. speed_limit_per_user=$(echo "${user_info_get}" | grep -w "speed_limit_per_user :" | sed 's/[[:space:]]//g' | awk -F ":" '{print $NF}')
  166. msg -bar
  167. Get_User_transfer "${port}"
  168. }
  169. Get_User_transfer() {
  170. transfer_port=$1
  171. #echo "transfer_port=${transfer_port}"
  172. all_port=$(${jq_file} '.[]|.port' ${config_user_mudb_file})
  173. #echo "all_port=${all_port}"
  174. port_num=$(echo "${all_port}" | grep -nw "${transfer_port}" | awk -F ":" '{print $1}')
  175. #echo "port_num=${port_num}"
  176. port_num_1=$(expr ${port_num} - 1)
  177. #echo "port_num_1=${port_num_1}"
  178. transfer_enable_1=$(${jq_file} ".[${port_num_1}].transfer_enable" ${config_user_mudb_file})
  179. #echo "transfer_enable_1=${transfer_enable_1}"
  180. u_1=$(${jq_file} ".[${port_num_1}].u" ${config_user_mudb_file})
  181. #echo "u_1=${u_1}"
  182. d_1=$(${jq_file} ".[${port_num_1}].d" ${config_user_mudb_file})
  183. #echo "d_1=${d_1}"
  184. transfer_enable_Used_2_1=$(expr ${u_1} + ${d_1})
  185. #echo "transfer_enable_Used_2_1=${transfer_enable_Used_2_1}"
  186. transfer_enable_Used_1=$(expr ${transfer_enable_1} - ${transfer_enable_Used_2_1})
  187. #echo "transfer_enable_Used_1=${transfer_enable_Used_1}"
  188. if [[ ${transfer_enable_1} -lt 1024 ]]; then
  189. transfer_enable="${transfer_enable_1} B"
  190. elif [[ ${transfer_enable_1} -lt 1048576 ]]; then
  191. transfer_enable=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_1}'/'1024'}')
  192. transfer_enable="${transfer_enable} KB"
  193. elif [[ ${transfer_enable_1} -lt 1073741824 ]]; then
  194. transfer_enable=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_1}'/'1048576'}')
  195. transfer_enable="${transfer_enable} MB"
  196. elif [[ ${transfer_enable_1} -lt 1099511627776 ]]; then
  197. transfer_enable=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_1}'/'1073741824'}')
  198. transfer_enable="${transfer_enable} GB"
  199. elif [[ ${transfer_enable_1} -lt 1125899906842624 ]]; then
  200. transfer_enable=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_1}'/'1099511627776'}')
  201. transfer_enable="${transfer_enable} TB"
  202. fi
  203. #echo "transfer_enable=${transfer_enable}"
  204. if [[ ${u_1} -lt 1024 ]]; then
  205. u="${u_1} B"
  206. elif [[ ${u_1} -lt 1048576 ]]; then
  207. u=$(awk 'BEGIN{printf "%.2f\n",'${u_1}'/'1024'}')
  208. u="${u} KB"
  209. elif [[ ${u_1} -lt 1073741824 ]]; then
  210. u=$(awk 'BEGIN{printf "%.2f\n",'${u_1}'/'1048576'}')
  211. u="${u} MB"
  212. elif [[ ${u_1} -lt 1099511627776 ]]; then
  213. u=$(awk 'BEGIN{printf "%.2f\n",'${u_1}'/'1073741824'}')
  214. u="${u} GB"
  215. elif [[ ${u_1} -lt 1125899906842624 ]]; then
  216. u=$(awk 'BEGIN{printf "%.2f\n",'${u_1}'/'1099511627776'}')
  217. u="${u} TB"
  218. fi
  219. #echo "u=${u}"
  220. if [[ ${d_1} -lt 1024 ]]; then
  221. d="${d_1} B"
  222. elif [[ ${d_1} -lt 1048576 ]]; then
  223. d=$(awk 'BEGIN{printf "%.2f\n",'${d_1}'/'1024'}')
  224. d="${d} KB"
  225. elif [[ ${d_1} -lt 1073741824 ]]; then
  226. d=$(awk 'BEGIN{printf "%.2f\n",'${d_1}'/'1048576'}')
  227. d="${d} MB"
  228. elif [[ ${d_1} -lt 1099511627776 ]]; then
  229. d=$(awk 'BEGIN{printf "%.2f\n",'${d_1}'/'1073741824'}')
  230. d="${d} GB"
  231. elif [[ ${d_1} -lt 1125899906842624 ]]; then
  232. d=$(awk 'BEGIN{printf "%.2f\n",'${d_1}'/'1099511627776'}')
  233. d="${d} TB"
  234. fi
  235. #echo "d=${d}"
  236. if [[ ${transfer_enable_Used_1} -lt 1024 ]]; then
  237. transfer_enable_Used="${transfer_enable_Used_1} B"
  238. elif [[ ${transfer_enable_Used_1} -lt 1048576 ]]; then
  239. transfer_enable_Used=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_1}'/'1024'}')
  240. transfer_enable_Used="${transfer_enable_Used} KB"
  241. elif [[ ${transfer_enable_Used_1} -lt 1073741824 ]]; then
  242. transfer_enable_Used=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_1}'/'1048576'}')
  243. transfer_enable_Used="${transfer_enable_Used} MB"
  244. elif [[ ${transfer_enable_Used_1} -lt 1099511627776 ]]; then
  245. transfer_enable_Used=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_1}'/'1073741824'}')
  246. transfer_enable_Used="${transfer_enable_Used} GB"
  247. elif [[ ${transfer_enable_Used_1} -lt 1125899906842624 ]]; then
  248. transfer_enable_Used=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_1}'/'1099511627776'}')
  249. transfer_enable_Used="${transfer_enable_Used} TB"
  250. fi
  251. #echo "transfer_enable_Used=${transfer_enable_Used}"
  252. if [[ ${transfer_enable_Used_2_1} -lt 1024 ]]; then
  253. transfer_enable_Used_2="${transfer_enable_Used_2_1} B"
  254. elif [[ ${transfer_enable_Used_2_1} -lt 1048576 ]]; then
  255. transfer_enable_Used_2=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_2_1}'/'1024'}')
  256. transfer_enable_Used_2="${transfer_enable_Used_2} KB"
  257. elif [[ ${transfer_enable_Used_2_1} -lt 1073741824 ]]; then
  258. transfer_enable_Used_2=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_2_1}'/'1048576'}')
  259. transfer_enable_Used_2="${transfer_enable_Used_2} MB"
  260. elif [[ ${transfer_enable_Used_2_1} -lt 1099511627776 ]]; then
  261. transfer_enable_Used_2=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_2_1}'/'1073741824'}')
  262. transfer_enable_Used_2="${transfer_enable_Used_2} GB"
  263. elif [[ ${transfer_enable_Used_2_1} -lt 1125899906842624 ]]; then
  264. transfer_enable_Used_2=$(awk 'BEGIN{printf "%.2f\n",'${transfer_enable_Used_2_1}'/'1099511627776'}')
  265. transfer_enable_Used_2="${transfer_enable_Used_2} TB"
  266. fi
  267. #echo "transfer_enable_Used_2=${transfer_enable_Used_2}"
  268. }
  269. urlsafe_base64() {
  270. date=$(echo -n "$1" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g;s/=//g;s/+/-/g;s/\//_/g')
  271. echo -e "${date}"
  272. }
  273. ss_link_qr() {
  274. SSbase64=$(urlsafe_base64 "${method}:${password}@${ip}:${port}")
  275. SSurl="ss://${SSbase64}"
  276. SSQRcode="http://www.codigos-qr.com/qr/php/qr_img.php?d=${SSurl}"
  277. ss_link=" SS Link :\n ${Green_font_prefix}${SSurl}${Font_color_suffix} \n Codigo QR SS:\n ${Green_font_prefix}${SSQRcode}${Font_color_suffix}"
  278. }
  279. ssr_link_qr() {
  280. SSRprotocol=$(echo ${protocol} | sed 's/_compatible//g')
  281. SSRobfs=$(echo ${obfs} | sed 's/_compatible//g')
  282. SSRPWDbase64=$(urlsafe_base64 "${password}")
  283. SSRbase64=$(urlsafe_base64 "${ip}:${port}:${SSRprotocol}:${method}:${SSRobfs}:${SSRPWDbase64}")
  284. SSRurl="ssr://${SSRbase64}"
  285. SSRQRcode="http://www.codigos-qr.com/qr/php/qr_img.php?d=${SSRurl}"
  286. ssr_link=" SSR Link :\n ${Red_font_prefix}${SSRurl}${Font_color_suffix} \n Codigo QR SSR:\n ${Red_font_prefix}${SSRQRcode}${Font_color_suffix}"
  287. }
  288. ss_ssr_determine() {
  289. protocol_suffix=$(echo ${protocol} | awk -F "_" '{print $NF}')
  290. obfs_suffix=$(echo ${obfs} | awk -F "_" '{print $NF}')
  291. if [[ ${protocol} = "origin" ]]; then
  292. if [[ ${obfs} = "plain" ]]; then
  293. ss_link_qr
  294. ssr_link=""
  295. else
  296. if [[ ${obfs_suffix} != "compatible" ]]; then
  297. ss_link=""
  298. else
  299. ss_link_qr
  300. fi
  301. fi
  302. else
  303. if [[ ${protocol_suffix} != "compatible" ]]; then
  304. ss_link=""
  305. else
  306. if [[ ${obfs_suffix} != "compatible" ]]; then
  307. if [[ ${obfs_suffix} = "plain" ]]; then
  308. ss_link_qr
  309. else
  310. ss_link=""
  311. fi
  312. else
  313. ss_link_qr
  314. fi
  315. fi
  316. fi
  317. ssr_link_qr
  318. }
  319. # Display configuration information
  320. View_User() {
  321. clear
  322. SSR_installation_status
  323. List_port_user
  324. while true; do
  325. echo -e "Ingrese el puerto de usuario para ver la informacion\nde la cuenta completa"
  326. msg -bar
  327. stty erase '^H' && read -p "(Predeterminado: cancelar):" View_user_port
  328. [[ -z "${View_user_port}" ]] && echo -e "Cancelado ...\n$(msg -bar)" && exit 1
  329. View_user=$(cat "${config_user_mudb_file}" | grep '"port": '"${View_user_port}"',')
  330. if [[ ! -z ${View_user} ]]; then
  331. Get_User_info "${View_user_port}"
  332. View_User_info
  333. break
  334. else
  335. echo -e "${Error} Por favor ingrese el puerto correcto !"
  336. fi
  337. done
  338. #read -p "Enter para continuar" enter
  339. }
  340. View_User_info() {
  341. ip=$(cat ${config_user_api_file} | grep "SERVER_PUB_ADDR = " | awk -F "[']" '{print $2}')
  342. [[ -z "${ip}" ]] && Get_IP
  343. ss_ssr_determine
  344. clear
  345. echo -e " Usuario [{user_name}] Informacion de Cuenta:"
  346. msg -bar
  347. echo -e " PANEL VPS-MX By @Kalix1"
  348. echo -e " IP : ${Green_font_prefix}${ip}${Font_color_suffix}"
  349. echo -e " Puerto : ${Green_font_prefix}${port}${Font_color_suffix}"
  350. echo -e " Contraseña : ${Green_font_prefix}${password}${Font_color_suffix}"
  351. echo -e " Encriptacion : ${Green_font_prefix}${method}${Font_color_suffix}"
  352. echo -e " Protocol : ${Red_font_prefix}${protocol}${Font_color_suffix}"
  353. echo -e " Obfs : ${Red_font_prefix}${obfs}${Font_color_suffix}"
  354. echo -e " Limite de dispositivos: ${Green_font_prefix}${protocol_param}${Font_color_suffix}"
  355. echo -e " Velocidad de subproceso Unico: ${Green_font_prefix}${speed_limit_per_con} KB/S${Font_color_suffix}"
  356. echo -e " Velocidad Maxima del Usuario: ${Green_font_prefix}${speed_limit_per_user} KB/S${Font_color_suffix}"
  357. echo -e " Puertos Prohibido: ${Green_font_prefix}${forbidden_port} ${Font_color_suffix}"
  358. echo -e " Consumo de sus Datos:\n Carga: ${Green_font_prefix}${u}${Font_color_suffix} + Descarga: ${Green_font_prefix}${d}${Font_color_suffix} = ${Green_font_prefix}${transfer_enable_Used_2}${Font_color_suffix}"
  359. echo -e " Trafico Restante: ${Green_font_prefix}${transfer_enable_Used} ${Font_color_suffix}"
  360. msg -bar
  361. echo -e " Trafico Total del Usuario: ${Green_font_prefix}${transfer_enable} ${Font_color_suffix}"
  362. msg -bar
  363. echo -e "${ss_link}"
  364. msg -bar
  365. echo -e "${ssr_link}"
  366. msg -bar
  367. echo -e " ${Green_font_prefix} Nota: ${Font_color_suffix}
  368. En el navegador, abra el enlace del codigo QR, puede\n ver la imagen del codigo QR."
  369. msg -bar
  370. }
  371. #Configuracion de la informacion de configuracion
  372. Set_config_user() {
  373. msg -bar
  374. echo -ne "\e[92m 1) Ingrese un nombre al usuario que desea Configurar\n (No repetir, o se marcara incorrectamente!)\n"
  375. msg -bar
  376. stty erase '^H' && read -p "(Predeterminado: VPS-MX):" ssr_user
  377. [[ -z "${ssr_user}" ]] && ssr_user="VPS-MX"
  378. echo && echo -e " Nombre de usuario : ${Green_font_prefix}${ssr_user}${Font_color_suffix}" && echo
  379. }
  380. Set_config_port() {
  381. msg -bar
  382. while true; do
  383. echo -e "\e[92m 2) Por favor ingrese un Puerto para el Usuario "
  384. msg -bar
  385. stty erase '^H' && read -p "(Predeterminado: 2525):" ssr_port
  386. [[ -z "$ssr_port" ]] && ssr_port="2525"
  387. expr ${ssr_port} + 0 &>/dev/null
  388. if [[ $? == 0 ]]; then
  389. if [[ ${ssr_port} -ge 1 ]] && [[ ${ssr_port} -le 65535 ]]; then
  390. echo && echo -e " Port : ${Green_font_prefix}${ssr_port}${Font_color_suffix}" && echo
  391. break
  392. else
  393. echo -e "${Error} Por favor ingrese el numero correcto (1-65535)"
  394. fi
  395. else
  396. echo -e "${Error} Por favor ingrese el numero correcto (1-65535)"
  397. fi
  398. done
  399. }
  400. Set_config_password() {
  401. msg -bar
  402. echo -e "\e[92m 3) Por favor ingrese una contrasena para el Usuario"
  403. msg -bar
  404. stty erase '^H' && read -p "(Predeterminado: VPS-MX):" ssr_password
  405. [[ -z "${ssr_password}" ]] && ssr_password="VPS-MX"
  406. echo && echo -e " contrasena : ${Green_font_prefix}${ssr_password}${Font_color_suffix}" && echo
  407. }
  408. Set_config_method() {
  409. msg -bar
  410. echo -e "\e[92m 4) Seleccione tipo de Encriptacion para el Usuario\e[0m
  411. $(msg -bar)
  412. ${Green_font_prefix} 1.${Font_color_suffix} Ninguno
  413. ${Green_font_prefix} 2.${Font_color_suffix} rc4
  414. ${Green_font_prefix} 3.${Font_color_suffix} rc4-md5
  415. ${Green_font_prefix} 4.${Font_color_suffix} rc4-md5-6
  416. ${Green_font_prefix} 5.${Font_color_suffix} aes-128-ctr
  417. ${Green_font_prefix} 6.${Font_color_suffix} aes-192-ctr
  418. ${Green_font_prefix} 7.${Font_color_suffix} aes-256-ctr
  419. ${Green_font_prefix} 8.${Font_color_suffix} aes-128-cfb
  420. ${Green_font_prefix} 9.${Font_color_suffix} aes-192-cfb
  421. ${Green_font_prefix}10.${Font_color_suffix} aes-256-cfb
  422. ${Green_font_prefix}11.${Font_color_suffix} aes-128-cfb8
  423. ${Green_font_prefix}12.${Font_color_suffix} aes-192-cfb8
  424. ${Green_font_prefix}13.${Font_color_suffix} aes-256-cfb8
  425. ${Green_font_prefix}14.${Font_color_suffix} salsa20
  426. ${Green_font_prefix}15.${Font_color_suffix} chacha20
  427. ${Green_font_prefix}16.${Font_color_suffix} chacha20-ietf
  428. ${Red_font_prefix}17.${Font_color_suffix} xsalsa20
  429. ${Red_font_prefix}18.${Font_color_suffix} xchacha20
  430. $(msg -bar)
  431. ${Tip} Para salsa20/chacha20-*:\n Porfavor instale libsodium:\n Opcion 4 en menu principal SSRR"
  432. msg -bar
  433. stty erase '^H' && read -p "(Predeterminado: 16. chacha20-ietf):" ssr_method
  434. msg -bar
  435. [[ -z "${ssr_method}" ]] && ssr_method="16"
  436. if [[ ${ssr_method} == "1" ]]; then
  437. ssr_method="Ninguno"
  438. elif [[ ${ssr_method} == "2" ]]; then
  439. ssr_method="rc4"
  440. elif [[ ${ssr_method} == "3" ]]; then
  441. ssr_method="rc4-md5"
  442. elif [[ ${ssr_method} == "4" ]]; then
  443. ssr_method="rc4-md5-6"
  444. elif [[ ${ssr_method} == "5" ]]; then
  445. ssr_method="aes-128-ctr"
  446. elif [[ ${ssr_method} == "6" ]]; then
  447. ssr_method="aes-192-ctr"
  448. elif [[ ${ssr_method} == "7" ]]; then
  449. ssr_method="aes-256-ctr"
  450. elif [[ ${ssr_method} == "8" ]]; then
  451. ssr_method="aes-128-cfb"
  452. elif [[ ${ssr_method} == "9" ]]; then
  453. ssr_method="aes-192-cfb"
  454. elif [[ ${ssr_method} == "10" ]]; then
  455. ssr_method="aes-256-cfb"
  456. elif [[ ${ssr_method} == "11" ]]; then
  457. ssr_method="aes-128-cfb8"
  458. elif [[ ${ssr_method} == "12" ]]; then
  459. ssr_method="aes-192-cfb8"
  460. elif [[ ${ssr_method} == "13" ]]; then
  461. ssr_method="aes-256-cfb8"
  462. elif [[ ${ssr_method} == "14" ]]; then
  463. ssr_method="salsa20"
  464. elif [[ ${ssr_method} == "15" ]]; then
  465. ssr_method="chacha20"
  466. elif [[ ${ssr_method} == "16" ]]; then
  467. ssr_method="chacha20-ietf"
  468. elif [[ ${ssr_method} == "17" ]]; then
  469. ssr_method="xsalsa20"
  470. elif [[ ${ssr_method} == "18" ]]; then
  471. ssr_method="xchacha20"
  472. else
  473. ssr_method="aes-256-cfb"
  474. fi
  475. echo && echo -e " Encriptacion: ${Green_font_prefix}${ssr_method}${Font_color_suffix}" && echo
  476. }
  477. Set_config_protocol() {
  478. msg -bar
  479. echo -e "\e[92m 5) Por favor, seleccione un Protocolo
  480. $(msg -bar)
  481. ${Green_font_prefix}1.${Font_color_suffix} origin
  482. ${Green_font_prefix}2.${Font_color_suffix} auth_sha1_v4
  483. ${Green_font_prefix}3.${Font_color_suffix} auth_aes128_md5
  484. ${Green_font_prefix}4.${Font_color_suffix} auth_aes128_sha1
  485. ${Green_font_prefix}5.${Font_color_suffix} auth_chain_a
  486. ${Green_font_prefix}6.${Font_color_suffix} auth_chain_b
  487. ${Red_font_prefix}7.${Font_color_suffix} auth_chain_c
  488. ${Red_font_prefix}8.${Font_color_suffix} auth_chain_d
  489. ${Red_font_prefix}9.${Font_color_suffix} auth_chain_e
  490. ${Red_font_prefix}10.${Font_color_suffix} auth_chain_f
  491. $(msg -bar)
  492. ${Tip}\n Si selecciona el protocolo de serie auth_chain_ *:\n Se recomienda establecer el metodo de cifrado en ninguno"
  493. msg -bar
  494. stty erase '^H' && read -p "(Predterminado: 1. origin):" ssr_protocol
  495. msg -bar
  496. [[ -z "${ssr_protocol}" ]] && ssr_protocol="1"
  497. if [[ ${ssr_protocol} == "1" ]]; then
  498. ssr_protocol="origin"
  499. elif [[ ${ssr_protocol} == "2" ]]; then
  500. ssr_protocol="auth_sha1_v4"
  501. elif [[ ${ssr_protocol} == "3" ]]; then
  502. ssr_protocol="auth_aes128_md5"
  503. elif [[ ${ssr_protocol} == "4" ]]; then
  504. ssr_protocol="auth_aes128_sha1"
  505. elif [[ ${ssr_protocol} == "5" ]]; then
  506. ssr_protocol="auth_chain_a"
  507. elif [[ ${ssr_protocol} == "6" ]]; then
  508. ssr_protocol="auth_chain_b"
  509. elif [[ ${ssr_protocol} == "7" ]]; then
  510. ssr_protocol="auth_chain_c"
  511. elif [[ ${ssr_protocol} == "8" ]]; then
  512. ssr_protocol="auth_chain_d"
  513. elif [[ ${ssr_protocol} == "9" ]]; then
  514. ssr_protocol="auth_chain_e"
  515. elif [[ ${ssr_protocol} == "10" ]]; then
  516. ssr_protocol="auth_chain_f"
  517. else
  518. ssr_protocol="origin"
  519. fi
  520. echo && echo -e " Protocolo : ${Green_font_prefix}${ssr_protocol}${Font_color_suffix}" && echo
  521. if [[ ${ssr_protocol} != "origin" ]]; then
  522. if [[ ${ssr_protocol} == "auth_sha1_v4" ]]; then
  523. stty erase '^H' && read -p "Set protocol plug-in to compatible mode(_compatible)?[Y/n]" ssr_protocol_yn
  524. [[ -z "${ssr_protocol_yn}" ]] && ssr_protocol_yn="y"
  525. [[ $ssr_protocol_yn == [Yy] ]] && ssr_protocol=${ssr_protocol}"_compatible"
  526. echo
  527. fi
  528. fi
  529. }
  530. Set_config_obfs() {
  531. msg -bar
  532. echo -e "\e[92m 6) Por favor, seleccione el metodo OBFS
  533. $(msg -bar)
  534. ${Green_font_prefix}1.${Font_color_suffix} plain
  535. ${Green_font_prefix}2.${Font_color_suffix} http_simple
  536. ${Green_font_prefix}3.${Font_color_suffix} http_post
  537. ${Green_font_prefix}4.${Font_color_suffix} random_head
  538. ${Green_font_prefix}5.${Font_color_suffix} tls1.2_ticket_auth
  539. $(msg -bar)
  540. Si elige tls1.2_ticket_auth, entonces el cliente puede\n elegir tls1.2_ticket_fastauth!"
  541. msg -bar
  542. stty erase '^H' && read -p "(Predeterminado: 5. tls1.2_ticket_auth):" ssr_obfs
  543. [[ -z "${ssr_obfs}" ]] && ssr_obfs="5"
  544. if [[ ${ssr_obfs} == "1" ]]; then
  545. ssr_obfs="plain"
  546. elif [[ ${ssr_obfs} == "2" ]]; then
  547. ssr_obfs="http_simple"
  548. elif [[ ${ssr_obfs} == "3" ]]; then
  549. ssr_obfs="http_post"
  550. elif [[ ${ssr_obfs} == "4" ]]; then
  551. ssr_obfs="random_head"
  552. elif [[ ${ssr_obfs} == "5" ]]; then
  553. ssr_obfs="tls1.2_ticket_auth"
  554. else
  555. ssr_obfs="tls1.2_ticket_auth"
  556. fi
  557. echo && echo -e " obfs : ${Green_font_prefix}${ssr_obfs}${Font_color_suffix}" && echo
  558. msg -bar
  559. if [[ ${ssr_obfs} != "plain" ]]; then
  560. stty erase '^H' && read -p "Configurar modo Compatible (Para usar SS)? [y/n]: " ssr_obfs_yn
  561. [[ -z "${ssr_obfs_yn}" ]] && ssr_obfs_yn="y"
  562. [[ $ssr_obfs_yn == [Yy] ]] && ssr_obfs=${ssr_obfs}"_compatible"
  563. fi
  564. }
  565. Set_config_protocol_param() {
  566. msg -bar
  567. while true; do
  568. echo -e "\e[92m 7) Limitar Cantidad de Dispositivos Simultaneos\n ${Green_font_prefix} auth_*La serie no es compatible con la version original. ${Font_color_suffix}"
  569. msg -bar
  570. echo -e "${Tip} Limite de numero de dispositivos:\n Es el numero de clientes que usaran la cuenta\n el minimo recomendado 2."
  571. msg -bar
  572. stty erase '^H' && read -p "(Predeterminado: Ilimitado):" ssr_protocol_param
  573. [[ -z "$ssr_protocol_param" ]] && ssr_protocol_param="" && echo && break
  574. expr ${ssr_protocol_param} + 0 &>/dev/null
  575. if [[ $? == 0 ]]; then
  576. if [[ ${ssr_protocol_param} -ge 1 ]] && [[ ${ssr_protocol_param} -le 9999 ]]; then
  577. echo && echo -e " Limite del dispositivo: ${Green_font_prefix}${ssr_protocol_param}${Font_color_suffix}" && echo
  578. break
  579. else
  580. echo -e "${Error} Por favor ingrese el numero correcto (1-9999)"
  581. fi
  582. else
  583. echo -e "${Error} Por favor ingrese el numero correcto (1-9999)"
  584. fi
  585. done
  586. }
  587. Set_config_speed_limit_per_con() {
  588. msg -bar
  589. while true; do
  590. echo -e "\e[92m 8) Introduzca un Limite de Velocidad x Hilo (en KB/S)"
  591. msg -bar
  592. stty erase '^H' && read -p "(Predterminado: Ilimitado):" ssr_speed_limit_per_con
  593. msg -bar
  594. [[ -z "$ssr_speed_limit_per_con" ]] && ssr_speed_limit_per_con=0 && echo && break
  595. expr ${ssr_speed_limit_per_con} + 0 &>/dev/null
  596. if [[ $? == 0 ]]; then
  597. if [[ ${ssr_speed_limit_per_con} -ge 1 ]] && [[ ${ssr_speed_limit_per_con} -le 131072 ]]; then
  598. echo && echo -e " Velocidad de Subproceso Unico: ${Green_font_prefix}${ssr_speed_limit_per_con} KB/S${Font_color_suffix}" && echo
  599. break
  600. else
  601. echo -e "${Error} Por favor ingrese el numero correcto (1-131072)"
  602. fi
  603. else
  604. echo -e "${Error} Por favor ingrese el numero correcto (1-131072)"
  605. fi
  606. done
  607. }
  608. Set_config_speed_limit_per_user() {
  609. msg -bar
  610. while true; do
  611. echo -e "\e[92m 9) Introduzca un Limite de Velocidad Maxima (en KB/S)"
  612. msg -bar
  613. echo -e "${Tip} Limite de Velocidad Maxima del Puerto :\n Es la velocidad maxima que ira el Usuario."
  614. msg -bar
  615. stty erase '^H' && read -p "(Predeterminado: Ilimitado):" ssr_speed_limit_per_user
  616. [[ -z "$ssr_speed_limit_per_user" ]] && ssr_speed_limit_per_user=0 && echo && break
  617. expr ${ssr_speed_limit_per_user} + 0 &>/dev/null
  618. if [[ $? == 0 ]]; then
  619. if [[ ${ssr_speed_limit_per_user} -ge 1 ]] && [[ ${ssr_speed_limit_per_user} -le 131072 ]]; then
  620. echo && echo -e " Velocidad Maxima del Usuario : ${Green_font_prefix}${ssr_speed_limit_per_user} KB/S${Font_color_suffix}" && echo
  621. break
  622. else
  623. echo -e "${Error} Por favor ingrese el numero correcto (1-131072)"
  624. fi
  625. else
  626. echo -e "${Error} Por favor ingrese el numero correcto (1-131072)"
  627. fi
  628. done
  629. }
  630. Set_config_transfer() {
  631. msg -bar
  632. while true; do
  633. echo -e "\e[92m 10) Ingrese Cantidad Total de Datos para el Usuario\n (en GB, 1-838868 GB)"
  634. msg -bar
  635. stty erase '^H' && read -p "(Predeterminado: Ilimitado):" ssr_transfer
  636. [[ -z "$ssr_transfer" ]] && ssr_transfer="838868" && echo && break
  637. expr ${ssr_transfer} + 0 &>/dev/null
  638. if [[ $? == 0 ]]; then
  639. if [[ ${ssr_transfer} -ge 1 ]] && [[ ${ssr_transfer} -le 838868 ]]; then
  640. echo && echo -e " Trafico Total Para El Usuario: ${Green_font_prefix}${ssr_transfer} GB${Font_color_suffix}" && echo
  641. break
  642. else
  643. echo -e "${Error} Por favor ingrese el numero correcto (1-838868)"
  644. fi
  645. else
  646. echo -e "${Error} Por favor ingrese el numero correcto (1-838868)"
  647. fi
  648. done
  649. }
  650. Set_config_forbid() {
  651. msg -bar
  652. echo "PROIBIR PUERTOS"
  653. msg -bar
  654. echo -e "${Tip} Puertos prohibidos:\n Por ejemplo, si no permite el acceso al puerto 25, los\n usuarios no podran acceder al puerto de correo 25 a\n traves del proxy de SSR. Si 80,443 esta desactivado,\n los usuarios no podran acceda a los sitios\n http/https normalmente."
  655. msg -bar
  656. stty erase '^H' && read -p "(Predeterminado: permitir todo):" ssr_forbid
  657. [[ -z "${ssr_forbid}" ]] && ssr_forbid=""
  658. echo && echo -e " Puerto prohibido: ${Green_font_prefix}${ssr_forbid}${Font_color_suffix}" && echo
  659. }
  660. Set_config_enable() {
  661. user_total=$(expr ${user_total} - 1)
  662. for ((integer = 0; integer <= ${user_total}; integer++)); do
  663. echo -e "integer=${integer}"
  664. port_jq=$(${jq_file} ".[${integer}].port" "${config_user_mudb_file}")
  665. echo -e "port_jq=${port_jq}"
  666. if [[ "${ssr_port}" == "${port_jq}" ]]; then
  667. enable=$(${jq_file} ".[${integer}].enable" "${config_user_mudb_file}")
  668. echo -e "enable=${enable}"
  669. [[ "${enable}" == "null" ]] && echo -e "${Error} Obtenga el puerto actual [${ssr_port}] Estado deshabilitado fallido!" && exit 1
  670. ssr_port_num=$(cat "${config_user_mudb_file}" | grep -n '"puerto": '${ssr_port}',' | awk -F ":" '{print $1}')
  671. echo -e "ssr_port_num=${ssr_port_num}"
  672. [[ "${ssr_port_num}" == "null" ]] && echo -e "${Error}Obtener actual Puerto [${ssr_port}] Numero de filas fallidas!" && exit 1
  673. ssr_enable_num=$(expr ${ssr_port_num} - 5)
  674. echo -e "ssr_enable_num=${ssr_enable_num}"
  675. break
  676. fi
  677. done
  678. if [[ "${enable}" == "1" ]]; then
  679. echo -e "Puerto [${ssr_port}] El estado de la cuenta es: ${Green_font_prefix}Enabled ${Font_color_suffix} , Cambiar a ${Red_font_prefix}Disabled${Font_color_suffix} ?[Y/n]"
  680. stty erase '^H' && read -p "(Predeterminado: Y):" ssr_enable_yn
  681. [[ -z "${ssr_enable_yn}" ]] && ssr_enable_yn="y"
  682. if [[ "${ssr_enable_yn}" == [Yy] ]]; then
  683. ssr_enable="0"
  684. else
  685. echo -e "Cancelado...\n$(msg -bar)" && exit 0
  686. fi
  687. elif [[ "${enable}" == "0" ]]; then
  688. echo -e "Port [${ssr_port}] El estado de la cuenta:${Green_font_prefix}Habilitado ${Font_color_suffix} , Cambie a ${Red_font_prefix}Deshabilitado${Font_color_suffix} ?[Y/n]"
  689. stty erase '^H' && read -p "(Predeterminado: Y):" ssr_enable_yn
  690. [[ -z "${ssr_enable_yn}" ]] && ssr_enable_yn = "y"
  691. if [[ "${ssr_enable_yn}" == [Yy] ]]; then
  692. ssr_enable="1"
  693. else
  694. echo "Cancelar ..." && exit 0
  695. fi
  696. else
  697. echo -e "${Error} El actual estado de discapacidad de Puerto es anormal.[${enable}] !" && exit 1
  698. fi
  699. }
  700. Set_user_api_server_pub_addr() {
  701. addr=$1
  702. if [[ "${addr}" == "Modify" ]]; then
  703. server_pub_addr=$(cat ${config_user_api_file} | grep "SERVER_PUB_ADDR = " | awk -F "[']" '{print $2}')
  704. if [[ -z ${server_pub_addr} ]]; then
  705. echo -e "${Error} La IP del servidor o el nombre de dominio obtenidos fallaron!" && exit 1
  706. else
  707. echo -e "${Info} La IP del servidor o el nombre de dominio actualmente configurados es ${Green_font_prefix}${server_pub_addr}${Font_color_suffix}"
  708. fi
  709. fi
  710. echo "Introduzca la IP del servidor o el nombre de dominio que se mostrara en la configuracion del usuario (cuando el servidor tiene varias IP, puede especificar la IP o el nombre de dominio que se muestra en la configuracion del usuario)"
  711. msg -bar
  712. stty erase '^H' && read -p "(Predeterminado:Deteccion automatica de la red externa IP):" ssr_server_pub_addr
  713. if [[ -z "${ssr_server_pub_addr}" ]]; then
  714. Get_IP
  715. if [[ ${ip} == "VPS_IP" ]]; then
  716. while true; do
  717. stty erase '^H' && read -p "${Error} La deteccion automatica de la IP de la red externa fallo, ingrese manualmente la IP del servidor o el nombre de dominio" ssr_server_pub_addr
  718. if [[ -z "$ssr_server_pub_addr" ]]; then
  719. echo -e "${Error}No puede estar vacio!"
  720. else
  721. break
  722. fi
  723. done
  724. else
  725. ssr_server_pub_addr="${ip}"
  726. fi
  727. fi
  728. echo && msg -bar && echo -e " IP o nombre de dominio: ${Green_font_prefix}${ssr_server_pub_addr}${Font_color_suffix}" && msg -bar && echo
  729. }
  730. Set_config_all() {
  731. lal=$1
  732. if [[ "${lal}" == "Modify" ]]; then
  733. Set_config_password
  734. Set_config_method
  735. Set_config_protocol
  736. Set_config_obfs
  737. Set_config_protocol_param
  738. Set_config_speed_limit_per_con
  739. Set_config_speed_limit_per_user
  740. Set_config_transfer
  741. Set_config_forbid
  742. else
  743. Set_config_user
  744. Set_config_port
  745. Set_config_password
  746. Set_config_method
  747. Set_config_protocol
  748. Set_config_obfs
  749. Set_config_protocol_param
  750. Set_config_speed_limit_per_con
  751. Set_config_speed_limit_per_user
  752. Set_config_transfer
  753. Set_config_forbid
  754. fi
  755. }
  756. #Modificar la informaci�n de configuraci�n
  757. Modify_config_password() {
  758. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -k "${ssr_password}" | grep -w "edit user ")
  759. if [[ -z "${match_edit}" ]]; then
  760. echo -e "${Error} Fallo la modificacion de la contrasena del usuario ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  761. else
  762. echo -e "${Info} La contrasena del usuario se modifico correctamente ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Puede tardar unos 10 segundos aplicar la ultima configuracion)"
  763. fi
  764. }
  765. Modify_config_method() {
  766. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -m "${ssr_method}" | grep -w "edit user ")
  767. if [[ -z "${match_edit}" ]]; then
  768. echo -e "${Error} La modificacion del metodo de cifrado del usuario fallo ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  769. else
  770. echo -e "${Info} Modo de cifrado de usuario ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Note: Nota: la configuracion mas reciente puede demorar unos 10 segundos)"
  771. fi
  772. }
  773. Modify_config_protocol() {
  774. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -O "${ssr_protocol}" | grep -w "edit user ")
  775. if [[ -z "${match_edit}" ]]; then
  776. echo -e "${Error} Fallo la modificacion del protocolo de usuario ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  777. else
  778. echo -e "${Info} Acuerdo de usuario modificacion exito ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: la configuracion m�s reciente puede demorar unos 10 segundos)"
  779. fi
  780. }
  781. Modify_config_obfs() {
  782. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -o "${ssr_obfs}" | grep -w "edit user ")
  783. if [[ -z "${match_edit}" ]]; then
  784. echo -e "${Error} La modificacion de la confusion del usuario fallo ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  785. else
  786. echo -e "${Info} Confusion del usuario exito de modificacion ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: La aplicacion de la ultima configuracion puede demorar unos 10 segundos)"
  787. fi
  788. }
  789. Modify_config_protocol_param() {
  790. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -G "${ssr_protocol_param}" | grep -w "edit user ")
  791. if [[ -z "${match_edit}" ]]; then
  792. echo -e "${Error} Fallo la modificacion del parametro del protocolo del usuario (numero de dispositivos limite) ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  793. else
  794. echo -e "${Info} Parametros de negociaci�n del usuario (numero de dispositivos limite) modificados correctamente ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: puede tomar aproximadamente 10 segundos aplicar la ultima configuracion)"
  795. fi
  796. }
  797. Modify_config_speed_limit_per_con() {
  798. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -s "${ssr_speed_limit_per_con}" | grep -w "edit user ")
  799. if [[ -z "${match_edit}" ]]; then
  800. echo -e "${Error} Fallo la modificacion de la velocidad de un solo hilo ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  801. else
  802. echo -e "${Info} Modificacion de la velocidad de un solo hilo exitosa ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: puede tomar aproximadamente 10 segundos aplicar la ultima configuracion)"
  803. fi
  804. }
  805. Modify_config_speed_limit_per_user() {
  806. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -S "${ssr_speed_limit_per_user}" | grep -w "edit user ")
  807. if [[ -z "${match_edit}" ]]; then
  808. echo -e "${Error} Usuario Puerto la modificaci�n del limite de velocidad total fallo ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  809. else
  810. echo -e "${Info} Usuario Puerto limite de velocidad total modificado con exito ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: la configuracion mas reciente puede demorar unos 10 segundos)"
  811. fi
  812. }
  813. Modify_config_connect_verbose_info() {
  814. sed -i 's/"connect_verbose_info": '"$(echo ${connect_verbose_info})"',/"connect_verbose_info": '"$(echo ${ssr_connect_verbose_info})"',/g' ${config_user_file}
  815. }
  816. Modify_config_transfer() {
  817. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -t "${ssr_transfer}" | grep -w "edit user ")
  818. if [[ -z "${match_edit}" ]]; then
  819. echo -e "${Error} La modificacion de trafico total del usuario fallo ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  820. else
  821. echo -e "${Info} Trafico total del usuario ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: la configuracion mas reciente puede demorar unos 10 segundos)"
  822. fi
  823. }
  824. Modify_config_forbid() {
  825. match_edit=$(python mujson_mgr.py -e -p "${ssr_port}" -f "${ssr_forbid}" | grep -w "edit user ")
  826. if [[ -z "${match_edit}" ]]; then
  827. echo -e "${Error} La modificacion del puerto prohibido por el usuario ha fallado ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} " && exit 1
  828. else
  829. echo -e "${Info} Los puertos prohibidos por el usuario se modificaron correctamente ${Green_font_prefix}[Port: ${ssr_port}]${Font_color_suffix} (Nota: puede tomar aproximadamente 10 segundos aplicar la ultima configuracion)"
  830. fi
  831. }
  832. Modify_config_enable() {
  833. sed -i "${ssr_enable_num}"'s/"enable": '"$(echo ${enable})"',/"enable": '"$(echo ${ssr_enable})"',/' ${config_user_mudb_file}
  834. }
  835. Modify_user_api_server_pub_addr() {
  836. sed -i "s/SERVER_PUB_ADDR = '${server_pub_addr}'/SERVER_PUB_ADDR = '${ssr_server_pub_addr}'/" ${config_user_api_file}
  837. }
  838. Modify_config_all() {
  839. Modify_config_password
  840. Modify_config_method
  841. Modify_config_protocol
  842. Modify_config_obfs
  843. Modify_config_protocol_param
  844. Modify_config_speed_limit_per_con
  845. Modify_config_speed_limit_per_user
  846. Modify_config_transfer
  847. Modify_config_forbid
  848. }
  849. Check_python() {
  850. python_ver=$(python -h)
  851. if [[ -z ${python_ver} ]]; then
  852. echo -e "${Info} No instalo Python, comience a instalar ..."
  853. if [[ ${release} == "centos" ]]; then
  854. yum install -y python
  855. else
  856. apt-get install -y python
  857. fi
  858. fi
  859. }
  860. Centos_yum() {
  861. yum update
  862. cat /etc/redhat-release | grep 7\..* | grep -i centos >/dev/null
  863. if [[ $? = 0 ]]; then
  864. yum install -y vim unzip crond net-tools git
  865. else
  866. yum install -y vim unzip crond git
  867. fi
  868. }
  869. Debian_apt() {
  870. apt-get update
  871. apt-get install -y vim unzip cron git net-tools
  872. }
  873. #Descargar ShadowsocksR
  874. Download_SSR() {
  875. cd "/usr/local"
  876. # wget -N --no-check-certificate "https://github.com/ToyoDAdoubi/shadowsocksr/archive/manyuser.zip"
  877. #git config --global http.sslVerify false
  878. git clone -b akkariiin/master https://github.com/shadowsocksrr/shadowsocksr.git
  879. [[ ! -e ${ssr_folder} ]] && echo -e "${Error} Fallo la descarga del servidor ShadowsocksR!" && exit 1
  880. # [[ ! -e "manyuser.zip" ]] && echo -e "${Error} Fallo la descarga del paquete de compresion lateral ShadowsocksR !" && rm -rf manyuser.zip && exit 1
  881. # unzip "manyuser.zip"
  882. # [[ ! -e "/usr/local/shadowsocksr-manyuser/" ]] && echo -e "${Error} Fallo la descompresi�n del servidor ShadowsocksR !" && rm -rf manyuser.zip && exit 1
  883. # mv "/usr/local/shadowsocksr-manyuser/" "/usr/local/shadowsocksr/"
  884. # [[ ! -e "/usr/local/shadowsocksr/" ]] && echo -e "${Error} Fallo el cambio de nombre del servidor ShadowsocksR!" && rm -rf manyuser.zip && rm -rf "/usr/local/shadowsocksr-manyuser/" && exit 1
  885. # rm -rf manyuser.zip
  886. cd "shadowsocksr"
  887. cp "${ssr_folder}/config.json" "${config_user_file}"
  888. cp "${ssr_folder}/mysql.json" "${ssr_folder}/usermysql.json"
  889. cp "${ssr_folder}/apiconfig.py" "${config_user_api_file}"
  890. [[ ! -e ${config_user_api_file} ]] && echo -e "${Error} Fallo la replicacion apiconfig.py del servidor ShadowsocksR!" && exit 1
  891. sed -i "s/API_INTERFACE = 'sspanelv2'/API_INTERFACE = 'mudbjson'/" ${config_user_api_file}
  892. server_pub_addr="127.0.0.1"
  893. Modify_user_api_server_pub_addr
  894. #sed -i "s/SERVER_PUB_ADDR = '127.0.0.1'/SERVER_PUB_ADDR = '${ip}'/" ${config_user_api_file}
  895. sed -i 's/ \/\/ only works under multi-user mode//g' "${config_user_file}"
  896. echo -e "${Info} Descarga del servidor ShadowsocksR completa!"
  897. }
  898. Service_SSR() {
  899. if [[ ${release} = "centos" ]]; then
  900. if ! wget --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/service/ssrmu_centos -O /etc/init.d/ssrmu; then
  901. echo -e "${Error} Fallo la descarga de la secuencia de comandos de administracion de servicios de ShadowsocksR!" && exit 1
  902. fi
  903. chmod +x /etc/init.d/ssrmu
  904. chkconfig --add ssrmu
  905. chkconfig ssrmu on
  906. else
  907. if ! wget --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/service/ssrmu_debian -O /etc/init.d/ssrmu; then
  908. echo -e "${Error} Fallo la descarga de la secuencia de comandos de administracion de servicio de ShadowsocksR!" && exit 1
  909. fi
  910. chmod +x /etc/init.d/ssrmu
  911. update-rc.d -f ssrmu defaults
  912. fi
  913. echo -e "${Info} ShadowsocksR Service Management Script Descargar Descargar!"
  914. }
  915. #Instalar el analizador JQ
  916. JQ_install() {
  917. if [[ ! -e ${jq_file} ]]; then
  918. cd "${ssr_folder}"
  919. if [[ ${bit} = "x86_64" ]]; then
  920. # mv "jq-linux64" "jq"
  921. wget --no-check-certificate "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -O ${jq_file}
  922. else
  923. # mv "jq-linux32" "jq"
  924. wget --no-check-certificate "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32" -O ${jq_file}
  925. fi
  926. [[ ! -e ${jq_file} ]] && echo -e "${Error} JQ parser, por favor!" && exit 1
  927. chmod +x ${jq_file}
  928. echo -e "${Info} La instalacion del analizador JQ se ha completado, continuar ..."
  929. else
  930. echo -e "${Info} JQ parser esta instalado, continuar ..."
  931. fi
  932. }
  933. #Instalacion
  934. Installation_dependency() {
  935. if [[ ${release} == "centos" ]]; then
  936. Centos_yum
  937. else
  938. Debian_apt
  939. fi
  940. [[ ! -e "/usr/bin/unzip" ]] && echo -e "${Error} Dependiente de la instalacion de descomprimir (paquete comprimido) fallo, en su mayoria problema, por favor verifique!" && exit 1
  941. Check_python
  942. #echo "nameserver 8.8.8.8" > /etc/resolv.conf
  943. #echo "nameserver 8.8.4.4" >> /etc/resolv.conf
  944. cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  945. if [[ ${release} == "centos" ]]; then
  946. /etc/init.d/crond restart
  947. else
  948. /etc/init.d/cron restart
  949. fi
  950. }
  951. Install_SSR() {
  952. clear
  953. check_root
  954. msg -bar
  955. [[ -e ${ssr_folder} ]] && echo -e "${Error}\nLa carpeta ShadowsocksR ha sido creada, por favor verifique\n(si la instalacion falla, desinstalela primero) !\n$(msg -bar)" && exit 1
  956. echo -e "${Info}\nComience la configuracion de la cuenta de ShadowsocksR..."
  957. msg -bar
  958. Set_user_api_server_pub_addr
  959. Set_config_all
  960. echo -e "${Info} Comience a instalar / configurar las dependencias de ShadowsocksR ..."
  961. Installation_dependency
  962. echo -e "${Info} Iniciar descarga / Instalar ShadowsocksR File ..."
  963. Download_SSR
  964. echo -e "${Info} Iniciar descarga / Instalar ShadowsocksR Service Script(init)..."
  965. Service_SSR
  966. echo -e "${Info} Iniciar descarga / instalar JSNO Parser JQ ..."
  967. JQ_install
  968. echo -e "${Info} Comience a agregar usuario inicial ..."
  969. Add_port_user "install"
  970. echo -e "${Info} Empezar a configurar el firewall de iptables ..."
  971. Set_iptables
  972. echo -e "${Info} Comience a agregar reglas de firewall de iptables ..."
  973. Add_iptables
  974. echo -e "${Info} Comience a guardar las reglas del servidor de seguridad de iptables ..."
  975. Save_iptables
  976. echo -e "${Info} Todos los pasos para iniciar el servicio ShadowsocksR ..."
  977. Start_SSR
  978. Get_User_info "${ssr_port}"
  979. View_User_info
  980. }
  981. Update_SSR() {
  982. SSR_installation_status
  983. # echo -e "Debido a que el beb� roto actualiza el servidor ShadowsocksR, entonces."
  984. cd ${ssr_folder}
  985. git pull
  986. Restart_SSR
  987. }
  988. Uninstall_SSR() {
  989. [[ ! -e ${ssr_folder} ]] && echo -e "${Error} ShadowsocksR no esta instalado, por favor, compruebe!\n$(msg -bar)" && exit 1
  990. echo "Desinstalar ShadowsocksR [y/n]"
  991. msg -bar
  992. stty erase '^H' && read -p "(Predeterminado: n):" unyn
  993. msg -bar
  994. [[ -z ${unyn} ]] && unyn="n"
  995. if [[ ${unyn} == [Yy] ]]; then
  996. check_pid
  997. [[ ! -z "${PID}" ]] && kill -9 ${PID}
  998. user_info=$(python mujson_mgr.py -l)
  999. user_total=$(echo "${user_info}" | wc -l)
  1000. if [[ ! -z ${user_info} ]]; then
  1001. for ((integer = 1; integer <= ${user_total}; integer++)); do
  1002. port=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $4}')
  1003. Del_iptables
  1004. done
  1005. fi
  1006. if [[ ${release} = "centos" ]]; then
  1007. chkconfig --del ssrmu
  1008. else
  1009. update-rc.d -f ssrmu remove
  1010. fi
  1011. rm -rf ${ssr_folder} && rm -rf /etc/init.d/ssrmu
  1012. echo && echo " Desinstalacion de ShadowsocksR completada!" && echo
  1013. else
  1014. echo && echo "Desinstalar cancelado ..." && echo
  1015. fi
  1016. }
  1017. Check_Libsodium_ver() {
  1018. echo -e "${Info} Descargando la ultima version de libsodium"
  1019. #Libsodiumr_ver=$(wget -qO- "https://github.com/jedisct1/libsodium/tags"|grep "/jedisct1/libsodium/releases/tag/"|head -1|sed -r 's/.*tag\/(.+)\">.*/\1/')
  1020. Libsodiumr_ver=1.0.17
  1021. [[ -z ${Libsodiumr_ver} ]] && Libsodiumr_ver=${Libsodiumr_ver_backup}
  1022. echo -e "${Info} La ultima version de libsodium es ${Green_font_prefix}${Libsodiumr_ver}${Font_color_suffix} !"
  1023. }
  1024. Install_Libsodium() {
  1025. if [[ -e ${Libsodiumr_file} ]]; then
  1026. echo -e "${Error} libsodium ya instalado, quieres actualizar?[y/N]"
  1027. stty erase '^H' && read -p "(Default: n):" yn
  1028. [[ -z ${yn} ]] && yn="n"
  1029. if [[ ${yn} == [Nn] ]]; then
  1030. echo -e "Cancelado...\n$(msg -bar)" && exit 1
  1031. fi
  1032. else
  1033. echo -e "${Info} libsodium no instalado, instalacion iniciada ..."
  1034. fi
  1035. Check_Libsodium_ver
  1036. if [[ ${release} == "centos" ]]; then
  1037. yum -y actualizacion
  1038. echo -e "${Info} La instalacion depende de ..."
  1039. yum -y groupinstall "Herramientas de desarrollo"
  1040. echo -e "${Info} Descargar ..."
  1041. wget --no-check-certificate -N "https://github.com/jedisct1/libsodium/releases/download/${Libsodiumr_ver}/libsodium-${Libsodiumr_ver}.tar.gz"
  1042. echo -e "${Info} Descomprimir ..."
  1043. tar -xzf libsodium-${Libsodiumr_ver}.tar.gz && cd libsodium-${Libsodiumr_ver}
  1044. echo -e "${Info} Compilar e instalar ..."
  1045. ./configure --disable-maintainer-mode && make -j2 && make install
  1046. echo /usr/local/lib >/etc/ld.so.conf.d/usr_local_lib.conf
  1047. else
  1048. apt-get update
  1049. echo -e "${Info} La instalacion depende de ..."
  1050. apt-get install -y build-essential
  1051. echo -e "${Info} Descargar ..."
  1052. wget --no-check-certificate -N "https://github.com/jedisct1/libsodium/releases/download/${Libsodiumr_ver}/libsodium-${Libsodiumr_ver}.tar.gz"
  1053. echo -e "${Info} Descomprimir ..."
  1054. tar -xzf libsodium-${Libsodiumr_ver}.tar.gz && cd libsodium-${Libsodiumr_ver}
  1055. echo -e "${Info} Compilar e instalar ..."
  1056. ./configure --disable-maintainer-mode && make -j2 && make install
  1057. fi
  1058. ldconfig
  1059. cd .. && rm -rf libsodium-${Libsodiumr_ver}.tar.gz && rm -rf libsodium-${Libsodiumr_ver}
  1060. [[ ! -e ${Libsodiumr_file} ]] && echo -e "${Error} libsodium Instalacion fallida!" && exit 1
  1061. echo && echo -e "${Info} libsodium exito de instalacion!" && echo
  1062. msg -bar
  1063. }
  1064. #Mostrar informaci�n de conexi�n
  1065. debian_View_user_connection_info() {
  1066. format_1=$1
  1067. user_info=$(python mujson_mgr.py -l)
  1068. user_total=$(echo "${user_info}" | wc -l)
  1069. [[ -z ${user_info} ]] && echo -e "${Error} No encontro, por favor compruebe!" && exit 1
  1070. IP_total=$(netstat -anp | grep 'ESTABLISHED' | grep 'python' | grep 'tcp6' | awk '{print $5}' | awk -F ":" '{print $1}' | sort -u | wc -l)
  1071. user_list_all=""
  1072. for ((integer = 1; integer <= ${user_total}; integer++)); do
  1073. user_port=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $4}')
  1074. user_IP_1=$(netstat -anp | grep 'ESTABLISHED' | grep 'python' | grep 'tcp6' | grep ":${user_port} " | awk '{print $5}' | awk -F ":" '{print $1}' | sort -u)
  1075. if [[ -z ${user_IP_1} ]]; then
  1076. user_IP_total="0"
  1077. else
  1078. user_IP_total=$(echo -e "${user_IP_1}" | wc -l)
  1079. if [[ ${format_1} == "IP_address" ]]; then
  1080. get_IP_address
  1081. else
  1082. user_IP=$(echo -e "\n${user_IP_1}")
  1083. fi
  1084. fi
  1085. user_list_all=${user_list_all}"Puerto: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, El numero total de IPs vinculadas: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, Current linked IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
  1086. user_IP=""
  1087. done
  1088. echo -e "Numero total de usuarios: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} Numero total de IPs vinculadas: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix}\n"
  1089. echo -e "${user_list_all}"
  1090. msg -bar
  1091. }
  1092. centos_View_user_connection_info() {
  1093. format_1=$1
  1094. user_info=$(python mujson_mgr.py -l)
  1095. user_total=$(echo "${user_info}" | wc -l)
  1096. [[ -z ${user_info} ]] && echo -e "${Error} No encontrado, por favor revise!" && exit 1
  1097. IP_total=$(netstat -anp | grep 'ESTABLISHED' | grep 'python' | grep 'tcp' | grep '::ffff:' | awk '{print $5}' | awk -F ":" '{print $4}' | sort -u | wc -l)
  1098. user_list_all=""
  1099. for ((integer = 1; integer <= ${user_total}; integer++)); do
  1100. user_port=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $4}')
  1101. user_IP_1=$(netstat -anp | grep 'ESTABLISHED' | grep 'python' | grep 'tcp' | grep ":${user_port} " | grep '::ffff:' | awk '{print $5}' | awk -F ":" '{print $4}' | sort -u)
  1102. if [[ -z ${user_IP_1} ]]; then
  1103. user_IP_total="0"
  1104. else
  1105. user_IP_total=$(echo -e "${user_IP_1}" | wc -l)
  1106. if [[ ${format_1} == "IP_address" ]]; then
  1107. get_IP_address
  1108. else
  1109. user_IP=$(echo -e "\n${user_IP_1}")
  1110. fi
  1111. fi
  1112. user_list_all=${user_list_all}"Puerto: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, El numero total de IPs vinculadas: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, Current linked IP: ${Green_font_prefix}${user_IP}${Font_color_suffix}\n"
  1113. user_IP=""
  1114. done
  1115. echo -e "El numero total de usuarios: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} El numero total de IPs vinculadas: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix} "
  1116. echo -e "${user_list_all}"
  1117. }
  1118. View_user_connection_info() {
  1119. clear
  1120. SSR_installation_status
  1121. msg -bar
  1122. echo -e "Seleccione el formato para mostrar :
  1123. $(msg -bar)
  1124. ${Green_font_prefix}1.${Font_color_suffix} Mostrar IP
  1125. ${Green_font_prefix}2.${Font_color_suffix} Mostrar IP + Resolver el nombre DNS"
  1126. msg -bar
  1127. stty erase '^H' && read -p "(Predeterminado: 1):" ssr_connection_info
  1128. msg -bar
  1129. [[ -z "${ssr_connection_info}" ]] && ssr_connection_info="1"
  1130. if [[ ${ssr_connection_info} == "1" ]]; then
  1131. View_user_connection_info_1 ""
  1132. elif [[ ${ssr_connection_info} == "2" ]]; then
  1133. echo -e "${Tip} Detectar IP (ipip.net)puede llevar mas tiempo si hay muchas IPs"
  1134. msg -bar
  1135. View_user_connection_info_1 "IP_address"
  1136. else
  1137. echo -e "${Error} Ingrese el numero correcto(1-2)" && exit 1
  1138. fi
  1139. }
  1140. View_user_connection_info_1() {
  1141. format=$1
  1142. if [[ ${release} = "centos" ]]; then
  1143. cat /etc/redhat-release | grep 7\..* | grep -i centos >/dev/null
  1144. if [[ $? = 0 ]]; then
  1145. debian_View_user_connection_info "$format"
  1146. else
  1147. centos_View_user_connection_info "$format"
  1148. fi
  1149. else
  1150. debian_View_user_connection_info "$format"
  1151. fi
  1152. }
  1153. get_IP_address() {
  1154. #echo "user_IP_1=${user_IP_1}"
  1155. if [[ ! -z ${user_IP_1} ]]; then
  1156. #echo "user_IP_total=${user_IP_total}"
  1157. for ((integer_1 = ${user_IP_total}; integer_1 >= 1; integer_1--)); do
  1158. IP=$(echo "${user_IP_1}" | sed -n "$integer_1"p)
  1159. #echo "IP=${IP}"
  1160. IP_address=$(wget -qO- -t1 -T2 http://freeapi.ipip.net/${IP} | sed 's/\"//g;s/,//g;s/\[//g;s/\]//g')
  1161. #echo "IP_address=${IP_address}"
  1162. user_IP="${user_IP}\n${IP}(${IP_address})"
  1163. #echo "user_IP=${user_IP}"
  1164. sleep 1s
  1165. done
  1166. fi
  1167. }
  1168. #Modificar la configuraci�n del usuario
  1169. Modify_port() {
  1170. msg -bar
  1171. List_port_user
  1172. while true; do
  1173. echo -e "Por favor ingrese el usuario (Puerto) que tiene que ser modificado"
  1174. msg -bar
  1175. stty erase '^H' && read -p "(Predeterminado: cancelar):" ssr_port
  1176. [[ -z "${ssr_port}" ]] && echo -e "Cancelado ...\n$(msg -bar)" && exit 1
  1177. Modify_user=$(cat "${config_user_mudb_file}" | grep '"port": '"${ssr_port}"',')
  1178. if [[ ! -z ${Modify_user} ]]; then
  1179. break
  1180. else
  1181. echo -e "${Error} Puerto Introduzca el Puerto correcto!"
  1182. fi
  1183. done
  1184. }
  1185. Modify_Config() {
  1186. clear
  1187. SSR_installation_status
  1188. echo && echo -e " ###¿Que desea realizar?###Mod By @Kalix1
  1189. $(msg -bar)
  1190. ${Green_font_prefix}1.${Font_color_suffix} Agregar y Configurar Usuario
  1191. ${Green_font_prefix}2.${Font_color_suffix} Eliminar la Configuracion del Usuario
  1192. ————————— Modificar la Configuracion del Usuario ————
  1193. ${Green_font_prefix}3.${Font_color_suffix} Modificar contrasena de Usuario
  1194. ${Green_font_prefix}4.${Font_color_suffix} Modificar el metodo de Cifrado
  1195. ${Green_font_prefix}5.${Font_color_suffix} Modificar el Protocolo
  1196. ${Green_font_prefix}6.${Font_color_suffix} Modificar Ofuscacion
  1197. ${Green_font_prefix}7.${Font_color_suffix} Modificar el Limite de Dispositivos
  1198. ${Green_font_prefix}8.${Font_color_suffix} Modificar el Limite de Velocidad de un solo Hilo
  1199. ${Green_font_prefix}9.${Font_color_suffix} Modificar limite de Velocidad Total del Usuario
  1200. ${Green_font_prefix}10.${Font_color_suffix} Modificar el Trafico Total del Usuario
  1201. ${Green_font_prefix}11.${Font_color_suffix} Modificar los Puertos Prohibidos Del usuario
  1202. ${Green_font_prefix}12.${Font_color_suffix} Modificar la Configuracion Completa
  1203. ————————— Otras Configuraciones —————————
  1204. ${Green_font_prefix}13.${Font_color_suffix} Modificar la IP o el nombre de dominio que\n se muestra en el perfil del usuario
  1205. $(msg -bar)
  1206. ${Tip} El nombre de usuario y el puerto del usuario\n no se pueden modificar. Si necesita modificarlos, use\n el script para modificar manualmente la funcion !"
  1207. msg -bar
  1208. stty erase '^H' && read -p "(Predeterminado: cancelar):" ssr_modify
  1209. [[ -z "${ssr_modify}" ]] && echo -e "Cancelado ...\n$(msg -bar)" && exit 1
  1210. if [[ ${ssr_modify} == "1" ]]; then
  1211. Add_port_user
  1212. elif [[ ${ssr_modify} == "2" ]]; then
  1213. Del_port_user
  1214. elif [[ ${ssr_modify} == "3" ]]; then
  1215. Modify_port
  1216. Set_config_password
  1217. Modify_config_password
  1218. elif [[ ${ssr_modify} == "4" ]]; then
  1219. Modify_port
  1220. Set_config_method
  1221. Modify_config_method
  1222. elif [[ ${ssr_modify} == "5" ]]; then
  1223. Modify_port
  1224. Set_config_protocol
  1225. Modify_config_protocol
  1226. elif [[ ${ssr_modify} == "6" ]]; then
  1227. Modify_port
  1228. Set_config_obfs
  1229. Modify_config_obfs
  1230. elif [[ ${ssr_modify} == "7" ]]; then
  1231. Modify_port
  1232. Set_config_protocol_param
  1233. Modify_config_protocol_param
  1234. elif [[ ${ssr_modify} == "8" ]]; then
  1235. Modify_port
  1236. Set_config_speed_limit_per_con
  1237. Modify_config_speed_limit_per_con
  1238. elif [[ ${ssr_modify} == "9" ]]; then
  1239. Modify_port
  1240. Set_config_speed_limit_per_user
  1241. Modify_config_speed_limit_per_user
  1242. elif [[ ${ssr_modify} == "10" ]]; then
  1243. Modify_port
  1244. Set_config_transfer
  1245. Modify_config_transfer
  1246. elif [[ ${ssr_modify} == "11" ]]; then
  1247. Modify_port
  1248. Set_config_forbid
  1249. Modify_config_forbid
  1250. elif [[ ${ssr_modify} == "12" ]]; then
  1251. Modify_port
  1252. Set_config_all "Modify"
  1253. Modify_config_all
  1254. elif [[ ${ssr_modify} == "13" ]]; then
  1255. Set_user_api_server_pub_addr "Modify"
  1256. Modify_user_api_server_pub_addr
  1257. else
  1258. echo -e "${Error} Ingrese el numero correcto(1-13)" && exit 1
  1259. fi
  1260. }
  1261. List_port_user() {
  1262. user_info=$(python mujson_mgr.py -l)
  1263. user_total=$(echo "${user_info}" | wc -l)
  1264. [[ -z ${user_info} ]] && echo -e "${Error} No encontre al usuario, por favor verifica otra vez!" && exit 1
  1265. user_list_all=""
  1266. for ((integer = 1; integer <= ${user_total}; integer++)); do
  1267. user_port=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $4}')
  1268. user_username=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $2}' | sed 's/\[//g;s/\]//g')
  1269. Get_User_transfer "${user_port}"
  1270. user_list_all=${user_list_all}"Nombre de usuario: ${Green_font_prefix} "${user_username}"${Font_color_suffix}\nPort: ${Green_font_prefix}"${user_port}"${Font_color_suffix}\nUso del trafico (Usado + Restante = Total):\n ${Green_font_prefix}${transfer_enable_Used_2}${Font_color_suffix} + ${Green_font_prefix}${transfer_enable_Used}${Font_color_suffix} = ${Green_font_prefix}${transfer_enable}${Font_color_suffix}\n--------------------------------------------\n "
  1271. done
  1272. echo && echo -e "===== El numero total de usuarios ===== ${Green_background_prefix} "${user_total}" ${Font_color_suffix}\n--------------------------------------------"
  1273. echo -e ${user_list_all}
  1274. }
  1275. Add_port_user() {
  1276. clear
  1277. lalal=$1
  1278. if [[ "$lalal" == "install" ]]; then
  1279. match_add=$(python mujson_mgr.py -a -u "${ssr_user}" -p "${ssr_port}" -k "${ssr_password}" -m "${ssr_method}" -O "${ssr_protocol}" -G "${ssr_protocol_param}" -o "${ssr_obfs}" -s "${ssr_speed_limit_per_con}" -S "${ssr_speed_limit_per_user}" -t "${ssr_transfer}" -f "${ssr_forbid}" | grep -w "add user info")
  1280. else
  1281. while true; do
  1282. Set_config_all
  1283. match_port=$(python mujson_mgr.py -l | grep -w "port ${ssr_port}$")
  1284. [[ ! -z "${match_port}" ]] && echo -e "${Error} El puerto [${ssr_port}] Ya existe, no lo agregue de nuevo !" && exit 1
  1285. match_username=$(python mujson_mgr.py -l | grep -w "Usuario \[${ssr_user}]")
  1286. [[ ! -z "${match_username}" ]] && echo -e "${Error} Nombre de usuario [${ssr_user}] Ya existe, no lo agregues de nuevo !" && exit 1
  1287. match_add=$(python mujson_mgr.py -a -u "${ssr_user}" -p "${ssr_port}" -k "${ssr_password}" -m "${ssr_method}" -O "${ssr_protocol}" -G "${ssr_protocol_param}" -o "${ssr_obfs}" -s "${ssr_speed_limit_per_con}" -S "${ssr_speed_limit_per_user}" -t "${ssr_transfer}" -f "${ssr_forbid}" | grep -w "add user info")
  1288. if [[ -z "${match_add}" ]]; then
  1289. echo -e "${Error} Usuario no se pudo agregar ${Green_font_prefix}[Nombre de usuario: ${ssr_user} , port: ${ssr_port}]${Font_color_suffix} "
  1290. break
  1291. else
  1292. Add_iptables
  1293. Save_iptables
  1294. msg -bar
  1295. echo -e "${Info} Usuario agregado exitosamente\n ${Green_font_prefix}[Nombre de usuario: ${ssr_user} , Puerto: ${ssr_port}]${Font_color_suffix} "
  1296. echo
  1297. stty erase '^H' && read -p "Continuar para agregar otro Usuario?[y/n]:" addyn
  1298. [[ -z ${addyn} ]] && addyn="y"
  1299. if [[ ${addyn} == [Nn] ]]; then
  1300. Get_User_info "${ssr_port}"
  1301. View_User_info
  1302. break
  1303. else
  1304. echo -e "${Info} Continuar agregando configuracion de usuario ..."
  1305. fi
  1306. fi
  1307. done
  1308. fi
  1309. }
  1310. Del_port_user() {
  1311. List_port_user
  1312. while true; do
  1313. msg -bar
  1314. echo -e "Por favor ingrese el puerto de usuario para ser eliminado"
  1315. stty erase '^H' && read -p "(Predeterminado: Cancelar):" del_user_port
  1316. msg -bar
  1317. [[ -z "${del_user_port}" ]] && echo -e "Cancelado...\n$(msg -bar)" && exit 1
  1318. del_user=$(cat "${config_user_mudb_file}" | grep '"port": '"${del_user_port}"',')
  1319. if [[ ! -z ${del_user} ]]; then
  1320. port=${del_user_port}
  1321. match_del=$(python mujson_mgr.py -d -p "${del_user_port}" | grep -w "delete user ")
  1322. if [[ -z "${match_del}" ]]; then
  1323. echo -e "${Error} La eliminación del usuario falló ${Green_font_prefix}[Puerto: ${del_user_port}]${Font_color_suffix} "
  1324. else
  1325. Del_iptables
  1326. Save_iptables
  1327. echo -e "${Info} Usuario eliminado exitosamente ${Green_font_prefix}[Puerto: ${del_user_port}]${Font_color_suffix} "
  1328. fi
  1329. break
  1330. else
  1331. echo -e "${Error} Por favor ingrese el puerto correcto !"
  1332. fi
  1333. done
  1334. msg -bar
  1335. }
  1336. Manually_Modify_Config() {
  1337. clear
  1338. msg -bar
  1339. SSR_installation_status
  1340. nano ${config_user_mudb_file}
  1341. echo "Si reiniciar ShadowsocksR ahora?[Y/n]" && echo
  1342. msg -bar
  1343. stty erase '^H' && read -p "(Predeterminado: y):" yn
  1344. [[ -z ${yn} ]] && yn="y"
  1345. if [[ ${yn} == [Yy] ]]; then
  1346. Restart_SSR
  1347. fi
  1348. }
  1349. Clear_transfer() {
  1350. clear
  1351. msg -bar
  1352. SSR_installation_status
  1353. echo -e "Que quieres realizar?
  1354. $(msg -bar)
  1355. ${Green_font_prefix}1.${Font_color_suffix} Borrar el trafico de un solo usuario
  1356. ${Green_font_prefix}2.${Font_color_suffix} Borrar todo el trafico de usuarios (irreparable)
  1357. ${Green_font_prefix}3.${Font_color_suffix} Todo el trafico de usuarios se borra en el inicio
  1358. ${Green_font_prefix}4.${Font_color_suffix} Deja de cronometrar todo el trafico de usuarios
  1359. ${Green_font_prefix}5.${Font_color_suffix} Modificar la sincronizacion de todo el trafico de usuarios"
  1360. msg -bar
  1361. stty erase '^H' && read -p "(Predeterminado:Cancelar):" ssr_modify
  1362. [[ -z "${ssr_modify}" ]] && echo "Cancelado ..." && exit 1
  1363. if [[ ${ssr_modify} == "1" ]]; then
  1364. Clear_transfer_one
  1365. elif [[ ${ssr_modify} == "2" ]]; then
  1366. msg -bar
  1367. echo "Esta seguro de que desea borrar todo el trafico de usuario[y/n]" && echo
  1368. msg -bar
  1369. stty erase '^H' && read -p "(Predeterminado: n):" yn
  1370. [[ -z ${yn} ]] && yn="n"
  1371. if [[ ${yn} == [Yy] ]]; then
  1372. Clear_transfer_all
  1373. else
  1374. echo "Cancelar ..."
  1375. fi
  1376. elif [[ ${ssr_modify} == "3" ]]; then
  1377. check_crontab
  1378. Set_crontab
  1379. Clear_transfer_all_cron_start
  1380. elif [[ ${ssr_modify} == "4" ]]; then
  1381. check_crontab
  1382. Clear_transfer_all_cron_stop
  1383. elif [[ ${ssr_modify} == "5" ]]; then
  1384. check_crontab
  1385. Clear_transfer_all_cron_modify
  1386. else
  1387. echo -e "${Error} Por favor numero de (1-5)" && exit 1
  1388. fi
  1389. }
  1390. Clear_transfer_one() {
  1391. List_port_user
  1392. while true; do
  1393. msg -bar
  1394. echo -e "Por favor ingrese el puerto de usuario para borrar el tráfico usado"
  1395. stty erase '^H' && read -p "(Predeterminado: Cancelar):" Clear_transfer_user_port
  1396. [[ -z "${Clear_transfer_user_port}" ]] && echo -e "Cancelado...\n$(msg -bar)" && exit 1
  1397. Clear_transfer_user=$(cat "${config_user_mudb_file}" | grep '"port": '"${Clear_transfer_user_port}"',')
  1398. if [[ ! -z ${Clear_transfer_user} ]]; then
  1399. match_clear=$(python mujson_mgr.py -c -p "${Clear_transfer_user_port}" | grep -w "clear user ")
  1400. if [[ -z "${match_clear}" ]]; then
  1401. echo -e "${Error} El usuario no ha podido utilizar la compensación de tráfico ${Green_font_prefix}[Puerto: ${Clear_transfer_user_port}]${Font_color_suffix} "
  1402. else
  1403. echo -e "${Info} El usuario ha eliminado con éxito el tráfico utilizando cero. ${Green_font_prefix}[Puerto: ${Clear_transfer_user_port}]${Font_color_suffix} "
  1404. fi
  1405. break
  1406. else
  1407. echo -e "${Error} Por favor ingrese el puerto correcto !"
  1408. fi
  1409. done
  1410. }
  1411. Clear_transfer_all() {
  1412. clear
  1413. cd "${ssr_folder}"
  1414. user_info=$(python mujson_mgr.py -l)
  1415. user_total=$(echo "${user_info}" | wc -l)
  1416. [[ -z ${user_info} ]] && echo -e "${Error} No encontro, por favor compruebe!" && exit 1
  1417. for ((integer = 1; integer <= ${user_total}; integer++)); do
  1418. user_port=$(echo "${user_info}" | sed -n "${integer}p" | awk '{print $4}')
  1419. match_clear=$(python mujson_mgr.py -c -p "${user_port}" | grep -w "clear user ")
  1420. if [[ -z "${match_clear}" ]]; then
  1421. echo -e "${Error} El usuario ha utilizado el trafico borrado fallido ${Green_font_prefix}[Port: ${user_port}]${Font_color_suffix} "
  1422. else
  1423. echo -e "${Info} El usuario ha utilizado el trafico para borrar con exito ${Green_font_prefix}[Port: ${user_port}]${Font_color_suffix} "
  1424. fi
  1425. done
  1426. echo -e "${Info} Se borra todo el trafico de usuarios!"
  1427. }
  1428. Clear_transfer_all_cron_start() {
  1429. crontab -l >"$file/crontab.bak"
  1430. sed -i "/ssrmu.sh/d" "$file/crontab.bak"
  1431. echo -e "\n${Crontab_time} /bin/bash $file/ssrmu.sh clearall" >>"$file/crontab.bak"
  1432. crontab "$file/crontab.bak"
  1433. rm -r "$file/crontab.bak"
  1434. cron_config=$(crontab -l | grep "ssrmu.sh")
  1435. if [[ -z ${cron_config} ]]; then
  1436. echo -e "${Error} Temporizacion de todo el trafico de usuarios borrado. !" && exit 1
  1437. else
  1438. echo -e "${Info} Programacion de todos los tiempos de inicio claro exitosos!"
  1439. fi
  1440. }
  1441. Clear_transfer_all_cron_stop() {
  1442. crontab -l >"$file/crontab.bak"
  1443. sed -i "/ssrmu.sh/d" "$file/crontab.bak"
  1444. crontab "$file/crontab.bak"
  1445. rm -r "$file/crontab.bak"
  1446. cron_config=$(crontab -l | grep "ssrmu.sh")
  1447. if [[ ! -z ${cron_config} ]]; then
  1448. echo -e "${Error} Temporizado Todo el trafico de usuarios se ha borrado Parado fallido!" && exit 1
  1449. else
  1450. echo -e "${Info} Timing All Clear Stop Stop Successful!!"
  1451. fi
  1452. }
  1453. Clear_transfer_all_cron_modify() {
  1454. Set_crontab
  1455. Clear_transfer_all_cron_stop
  1456. Clear_transfer_all_cron_start
  1457. }
  1458. Set_crontab() {
  1459. clear
  1460. echo -e "Por favor ingrese el intervalo de tiempo de flujo
  1461. === Formato ===
  1462. * * * * * Mes * * * * *
  1463. ${Green_font_prefix} 0 2 1 * * ${Font_color_suffix} Representante 1er, 2:00, claro, trafico usado.
  1464. $(msg -bar)
  1465. ${Green_font_prefix} 0 2 15 * * ${Font_color_suffix} Representativo El 1 2} representa el 15 2:00 minutos Punto de flujo usado despejado 0 minutos Borrar flujo usado�
  1466. $(msg -bar)
  1467. ${Green_font_prefix} 0 2 */7 * * ${Font_color_suffix} Representante 7 dias 2: 0 minutos despeja el trafico usado.
  1468. $(msg -bar)
  1469. ${Green_font_prefix} 0 2 * * 0 ${Font_color_suffix} Representa todos los domingos (7) para despejar el trafico utilizado.
  1470. $(msg -bar)
  1471. ${Green_font_prefix} 0 2 * * 3 ${Font_color_suffix} Representante (3) Flujo de trafico usado despejado"
  1472. msg -bar
  1473. stty erase '^H' && read -p "(Default: 0 2 1 * * 1 de cada mes 2:00):" Crontab_time
  1474. [[ -z "${Crontab_time}" ]] && Crontab_time="0 2 1 * *"
  1475. }
  1476. Start_SSR() {
  1477. clear
  1478. SSR_installation_status
  1479. check_pid
  1480. [[ ! -z ${PID} ]] && echo -e "${Error} ShadowsocksR se esta ejecutando!" && exit 1
  1481. /etc/init.d/ssrmu start
  1482. }
  1483. Stop_SSR() {
  1484. clear
  1485. SSR_installation_status
  1486. check_pid
  1487. [[ -z ${PID} ]] && echo -e "${Error} ShadowsocksR no esta funcionando!" && exit 1
  1488. /etc/init.d/ssrmu stop
  1489. }
  1490. Restart_SSR() {
  1491. clear
  1492. SSR_installation_status
  1493. check_pid
  1494. [[ ! -z ${PID} ]] && /etc/init.d/ssrmu stop
  1495. /etc/init.d/ssrmu start
  1496. }
  1497. View_Log() {
  1498. SSR_installation_status
  1499. [[ ! -e ${ssr_log_file} ]] && echo -e "${Error} El registro de ShadowsocksR no existe!" && exit 1
  1500. echo && echo -e "${Tip} Presione ${Red_font_prefix}Ctrl+C ${Font_color_suffix} Registro de registro de terminacion" && echo
  1501. tail -f ${ssr_log_file}
  1502. }
  1503. #Afilado
  1504. Configure_Server_Speeder() {
  1505. clear
  1506. msg -bar
  1507. echo && echo -e "Que vas a hacer
  1508. ${BARRA1}
  1509. ${Green_font_prefix}1.${Font_color_suffix} Velocidad aguda
  1510. $(msg -bar)
  1511. ${Green_font_prefix}2.${Font_color_suffix} Velocidad aguda
  1512. ————————
  1513. ${Green_font_prefix}3.${Font_color_suffix} Velocidad aguda
  1514. $(msg -bar)
  1515. ${Green_font_prefix}4.${Font_color_suffix} Velocidad aguda
  1516. $(msg -bar)
  1517. ${Green_font_prefix}5.${Font_color_suffix} Reinicie la velocidad aguda
  1518. $(msg -bar)
  1519. ${Green_font_prefix}6.${Font_color_suffix} Estado agudo
  1520. $(msg -bar)
  1521. Nota: Sharp y LotServer no se pueden instalar / iniciar al mismo tiempo"
  1522. msg -bar
  1523. stty erase '^H' && read -p "(Predeterminado: Cancelar):" server_speeder_num
  1524. [[ -z "${server_speeder_num}" ]] && echo "Cancelado ..." && exit 1
  1525. if [[ ${server_speeder_num} == "1" ]]; then
  1526. Install_ServerSpeeder
  1527. elif [[ ${server_speeder_num} == "2" ]]; then
  1528. Server_Speeder_installation_status
  1529. Uninstall_ServerSpeeder
  1530. elif [[ ${server_speeder_num} == "3" ]]; then
  1531. Server_Speeder_installation_status
  1532. ${Server_Speeder_file} start
  1533. ${Server_Speeder_file} status
  1534. elif [[ ${server_speeder_num} == "4" ]]; then
  1535. Server_Speeder_installation_status
  1536. ${Server_Speeder_file} stop
  1537. elif [[ ${server_speeder_num} == "5" ]]; then
  1538. Server_Speeder_installation_status
  1539. ${Server_Speeder_file} restart
  1540. ${Server_Speeder_file} status
  1541. elif [[ ${server_speeder_num} == "6" ]]; then
  1542. Server_Speeder_installation_status
  1543. ${Server_Speeder_file} status
  1544. else
  1545. echo -e "${Error} Por favor numero(1-6)" && exit 1
  1546. fi
  1547. }
  1548. Install_ServerSpeeder() {
  1549. [[ -e ${Server_Speeder_file} ]] && echo -e "${Error} Server Speeder esta instalado!" && exit 1
  1550. #Prestamo de la version feliz de 91yun.rog
  1551. wget --no-check-certificate -qO /tmp/serverspeeder.sh https://raw.githubusercontent.com/91yun/serverspeeder/master/serverspeeder.sh
  1552. [[ ! -e "/tmp/serverspeeder.sh" ]] && echo -e "${Error} Prestamo de la version feliz de 91yun.rog!" && exit 1
  1553. bash /tmp/serverspeeder.sh
  1554. sleep 2s
  1555. PID=$(ps -ef | grep -v grep | grep "serverspeeder" | awk '{print $2}')
  1556. if [[ ! -z ${PID} ]]; then
  1557. rm -rf /tmp/serverspeeder.sh
  1558. rm -rf /tmp/91yunserverspeeder
  1559. rm -rf /tmp/91yunserverspeeder.tar.gz
  1560. echo -e "${Info} La instalacion del servidor Speeder esta completa!" && exit 1
  1561. else
  1562. echo -e "${Error} Fallo la instalacion de Server Speeder!" && exit 1
  1563. fi
  1564. }
  1565. Uninstall_ServerSpeeder() {
  1566. clear
  1567. msg -bar
  1568. echo "yes para desinstalar Speed ??Speed ??(Server Speeder)[y/N]" && echo
  1569. msg -bar
  1570. stty erase '^H' && read -p "(Predeterminado: n):" unyn
  1571. [[ -z ${unyn} ]] && echo && echo "Cancelado ..." && exit 1
  1572. if [[ ${unyn} == [Yy] ]]; then
  1573. chattr -i /serverspeeder/etc/apx*
  1574. /serverspeeder/bin/serverSpeeder.sh uninstall -f
  1575. echo && echo "Server Speeder Desinstalacion completa!" && echo
  1576. fi
  1577. }
  1578. # LotServer
  1579. Configure_LotServer() {
  1580. clear
  1581. msg -bar
  1582. echo && echo -e "Que vas a hacer?
  1583. $(msg -bar)
  1584. ${Green_font_prefix}1.${Font_color_suffix} Instalar LotServer
  1585. $(msg -bar)
  1586. ${Green_font_prefix}2.${Font_color_suffix} Desinstalar LotServer
  1587. ————————
  1588. ${Green_font_prefix}3.${Font_color_suffix} Iniciar LotServer
  1589. $(msg -bar)
  1590. ${Green_font_prefix}4.${Font_color_suffix} Detener LotServer
  1591. $(msg -bar)
  1592. ${Green_font_prefix}5.${Font_color_suffix} Reiniciar LotServer
  1593. $(msg -bar)
  1594. ${Green_font_prefix}6.${Font_color_suffix} Ver el estado de LotServer
  1595. ${BARRA1}
  1596. Nota: Sharp y LotServer no se pueden instalar / iniciar al mismo tiempo"
  1597. msg -bar
  1598. stty erase '^H' && read -p "(Predeterminado: Cancelar):" lotserver_num
  1599. [[ -z "${lotserver_num}" ]] && echo "Cancelado ..." && exit 1
  1600. if [[ ${lotserver_num} == "1" ]]; then
  1601. Install_LotServer
  1602. elif [[ ${lotserver_num} == "2" ]]; then
  1603. LotServer_installation_status
  1604. Uninstall_LotServer
  1605. elif [[ ${lotserver_num} == "3" ]]; then
  1606. LotServer_installation_status
  1607. ${LotServer_file} start
  1608. ${LotServer_file} status
  1609. elif [[ ${lotserver_num} == "4" ]]; then
  1610. LotServer_installation_status
  1611. ${LotServer_file} stop
  1612. elif [[ ${lotserver_num} == "5" ]]; then
  1613. LotServer_installation_status
  1614. ${LotServer_file} restart
  1615. ${LotServer_file} status
  1616. elif [[ ${lotserver_num} == "6" ]]; then
  1617. LotServer_installation_status
  1618. ${LotServer_file} status
  1619. else
  1620. echo -e "${Error} Por favor numero(1-6)" && exit 1
  1621. fi
  1622. }
  1623. Install_LotServer() {
  1624. [[ -e ${LotServer_file} ]] && echo -e "${Error} LotServer esta instalado!" && exit 1
  1625. #Github: https://github.com/0oVicero0/serverSpeeder_Install
  1626. wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh"
  1627. [[ ! -e "/tmp/appex.sh" ]] && echo -e "${Error} Fallo la descarga del script de instalacion de LotServer!" && exit 1
  1628. bash /tmp/appex.sh 'install'
  1629. sleep 2s
  1630. PID=$(ps -ef | grep -v grep | grep "appex" | awk '{print $2}')
  1631. if [[ ! -z ${PID} ]]; then
  1632. echo -e "${Info} La instalacion de LotServer esta completa!" && exit 1
  1633. else
  1634. echo -e "${Error} Fallo la instalacion de LotServer!" && exit 1
  1635. fi
  1636. }
  1637. Uninstall_LotServer() {
  1638. clear
  1639. msg -bar
  1640. echo "Desinstalar Para desinstalar LotServer[y/N]" && echo
  1641. msg -bar
  1642. stty erase '^H' && read -p "(Predeterminado: n):" unyn
  1643. msg -bar
  1644. [[ -z ${unyn} ]] && echo && echo "Cancelado ..." && exit 1
  1645. if [[ ${unyn} == [Yy] ]]; then
  1646. wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh" && bash /tmp/appex.sh 'uninstall'
  1647. echo && echo "La desinstalacion de LotServer esta completa!" && echo
  1648. fi
  1649. }
  1650. # BBR
  1651. Configure_BBR() {
  1652. clear
  1653. msg -bar
  1654. echo -e " Que vas a hacer?
  1655. $(msg -bar)
  1656. ${Green_font_prefix}1.${Font_color_suffix} Instalar BBR
  1657. ————————
  1658. ${Green_font_prefix}2.${Font_color_suffix} Iniciar BBR
  1659. ${Green_font_prefix}3.${Font_color_suffix} Dejar de BBR
  1660. ${Green_font_prefix}4.${Font_color_suffix} Ver el estado de BBR"
  1661. msg -bar
  1662. echo -e "${Green_font_prefix} [Por favor, preste atencion antes de la instalacion] ${Font_color_suffix}
  1663. $(msg -bar)
  1664. 1. Abra BBR, reemplace, hay un error de reemplazo (despues de reiniciar)
  1665. 2. Este script solo es compatible con los nucleos de reemplazo de Debian / Ubuntu. OpenVZ y Docker no admiten el reemplazo de los nucleos.
  1666. 3. Debian reemplaza el proceso del kernel [Desea finalizar el kernel de desinstalacion], seleccione ${Green_font_prefix} NO ${Font_color_suffix}"
  1667. stty erase '^H' && read -p "(Predeterminado: Cancelar):" bbr_num
  1668. msg -bar
  1669. [[ -z "${bbr_num}" ]] && echo -e "Cancelado...\n$(msg -bar)" && exit 1
  1670. if [[ ${bbr_num} == "1" ]]; then
  1671. Install_BBR
  1672. elif [[ ${bbr_num} == "2" ]]; then
  1673. Start_BBR
  1674. elif [[ ${bbr_num} == "3" ]]; then
  1675. Stop_BBR
  1676. elif [[ ${bbr_num} == "4" ]]; then
  1677. Status_BBR
  1678. else
  1679. echo -e "${Error} Por favor numero(1-4)" && exit 1
  1680. fi
  1681. }
  1682. Install_BBR() {
  1683. [[ ${release} = "centos" ]] && echo -e "${Error} Este script de instalacion del sistema CentOS. BBR !" && exit 1
  1684. BBR_installation_status
  1685. bash "${BBR_file}"
  1686. }
  1687. Start_BBR() {
  1688. BBR_installation_status
  1689. bash "${BBR_file}" start
  1690. }
  1691. Stop_BBR() {
  1692. BBR_installation_status
  1693. bash "${BBR_file}" stop
  1694. }
  1695. Status_BBR() {
  1696. BBR_installation_status
  1697. bash "${BBR_file}" status
  1698. }
  1699. BackUP_ssrr() {
  1700. clear
  1701. msg -bar
  1702. msg -ama "$(fun_trans "HERRAMIENTA DE BACKUP SS-SSRR -BETA")"
  1703. msg -bar
  1704. msg -azu "CREANDO BACKUP" "RESTAURAR BACKUP"
  1705. msg -bar
  1706. rm -rf /root/mudb.json >/dev/null 2>&1
  1707. cp /usr/local/shadowsocksr/mudb.json /root/mudb.json >/dev/null 2>&1
  1708. msg -azu "$(fun_trans "Procedimiento Hecho con Exito, Guardado en:")"
  1709. echo -e "\033[1;31mBACKUP > [\033[1;32m/root/mudb.json\033[1;31m]"
  1710. msg -bar
  1711. }
  1712. RestaurarBackUp_ssrr() {
  1713. clear
  1714. msg -bar
  1715. msg -ama "$(fun_trans "HERRAMIENTA DE RESTAURACION SS-SSRR -BETA")"
  1716. msg -bar
  1717. msg -azu "Recuerde tener minimo una cuenta ya creada"
  1718. msg -azu "Copie el archivo mudb.json en la carpeta /root"
  1719. read -p " ►► Presione enter para continuar ◄◄"
  1720. msg -bar
  1721. msg -azu "$(fun_trans "Procedimiento Hecho con Exito")"
  1722. read -p " ►► Presione enter para Reiniciar Panel SSRR ◄◄"
  1723. msg -bar
  1724. mv /root/mudb.json /usr/local/shadowsocksr/mudb.json
  1725. Restart_SSR
  1726. msg -bar
  1727. }
  1728. # Otros
  1729. Other_functions() {
  1730. clear
  1731. msg -bar
  1732. echo && echo -e " Que vas a realizar?
  1733. $(msg -bar)
  1734. ${Green_font_prefix}1.${Font_color_suffix} Configurar BBR
  1735. ${Green_font_prefix}2.${Font_color_suffix} Velocidad de configuracion (ServerSpeeder)
  1736. ${Green_font_prefix}3.${Font_color_suffix} Configurar LotServer (Rising Parent)
  1737. ${Tip} Sharp / LotServer / BBR no es compatible con OpenVZ!
  1738. ${Tip} Speed y LotServer no pueden coexistir!
  1739. ————————————
  1740. ${Green_font_prefix}4.${Font_color_suffix} Llave de bloqueo BT/PT/SPAM (iptables)
  1741. ${Green_font_prefix}5.${Font_color_suffix} Llave de desbloqueo BT/PT/SPAM (iptables)
  1742. ————————————
  1743. ${Green_font_prefix}6.${Font_color_suffix} Cambiar modo de salida de registro ShadowsocksR
  1744. —— Modo bajo o verboso..
  1745. ${Green_font_prefix}7.${Font_color_suffix} Supervisar el estado de ejecucion del servidor ShadowsocksR
  1746. —— NOTA: Esta funcion es adecuada para que el servidor SSR finalice los procesos regulares. Una vez que esta funcion esta habilitada, sera detectada cada minuto. Cuando el proceso no existe, el servidor SSR se inicia automaticamente.
  1747. ————————————
  1748. ${Green_font_prefix}8.${Font_color_suffix} Backup SSRR
  1749. ${Green_font_prefix}9.${Font_color_suffix} Restaurar Backup" && echo
  1750. msg -bar
  1751. stty erase '^H' && read -p "(Predeterminado: cancelar):" other_num
  1752. [[ -z "${other_num}" ]] && echo -e "Cancelado...\n$(msg -bar)" && exit 1
  1753. if [[ ${other_num} == "1" ]]; then
  1754. Configure_BBR
  1755. elif [[ ${other_num} == "2" ]]; then
  1756. Configure_Server_Speeder
  1757. elif [[ ${other_num} == "3" ]]; then
  1758. Configure_LotServer
  1759. elif [[ ${other_num} == "4" ]]; then
  1760. BanBTPTSPAM
  1761. elif [[ ${other_num} == "5" ]]; then
  1762. UnBanBTPTSPAM
  1763. elif [[ ${other_num} == "6" ]]; then
  1764. Set_config_connect_verbose_info
  1765. elif [[ ${other_num} == "7" ]]; then
  1766. Set_crontab_monitor_ssr
  1767. elif [[ ${other_num} == "8" ]]; then
  1768. BackUP_ssrr
  1769. elif [[ ${other_num} == "9" ]]; then
  1770. RestaurarBackUp_ssrr
  1771. else
  1772. echo -e "${Error} Por favor numero [1-9]" && exit 1
  1773. fi
  1774. }
  1775. #Prohibido�BT PT SPAM
  1776. BanBTPTSPAM() {
  1777. wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ban_iptables.sh && chmod +x ban_iptables.sh && bash ban_iptables.sh banall
  1778. rm -rf ban_iptables.sh
  1779. }
  1780. #Desbloquear BT PT SPAM
  1781. UnBanBTPTSPAM() {
  1782. wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ban_iptables.sh && chmod +x ban_iptables.sh && bash ban_iptables.sh unbanall
  1783. rm -rf ban_iptables.sh
  1784. }
  1785. Set_config_connect_verbose_info() {
  1786. clear
  1787. msg -bar
  1788. SSR_installation_status
  1789. [[ ! -e ${jq_file} ]] && echo -e "${Error} JQ parser No, por favor, compruebe!" && exit 1
  1790. connect_verbose_info=$(${jq_file} '.connect_verbose_info' ${config_user_file})
  1791. if [[ ${connect_verbose_info} = "0" ]]; then
  1792. echo && echo -e "Modo de registro actual: ${Green_font_prefix}Registro de errores en modo simple${Font_color_suffix}"
  1793. msg -bar
  1794. echo -e "yes para cambiar a ${Green_font_prefix}Modo detallado (registro de conexi�n + registro de errores)${Font_color_suffix}?[y/N]"
  1795. msg -bar
  1796. stty erase '^H' && read -p "(Predeterminado: n):" connect_verbose_info_ny
  1797. [[ -z "${connect_verbose_info_ny}" ]] && connect_verbose_info_ny="n"
  1798. if [[ ${connect_verbose_info_ny} == [Yy] ]]; then
  1799. ssr_connect_verbose_info="1"
  1800. Modify_config_connect_verbose_info
  1801. Restart_SSR
  1802. else
  1803. echo && echo " Cancelado ..." && echo
  1804. fi
  1805. else
  1806. echo && echo -e "Modo de registro actual: ${Green_font_prefix}Modo detallado (conexion de conexion + registro de errores)${Font_color_suffix}"
  1807. msg -bar
  1808. echo -e "yes para cambiar a ${Green_font_prefix}Modo simple ${Font_color_suffix}?[y/N]"
  1809. stty erase '^H' && read -p "(Predeterminado: n):" connect_verbose_info_ny
  1810. [[ -z "${connect_verbose_info_ny}" ]] && connect_verbose_info_ny="n"
  1811. if [[ ${connect_verbose_info_ny} == [Yy] ]]; then
  1812. ssr_connect_verbose_info="0"
  1813. Modify_config_connect_verbose_info
  1814. Restart_SSR
  1815. else
  1816. echo && echo " Cancelado ..." && echo
  1817. fi
  1818. fi
  1819. }
  1820. Set_crontab_monitor_ssr() {
  1821. clear
  1822. msg -bar
  1823. SSR_installation_status
  1824. crontab_monitor_ssr_status=$(crontab -l | grep "ssrmu.sh monitor")
  1825. if [[ -z "${crontab_monitor_ssr_status}" ]]; then
  1826. echo && echo -e "Modo de monitoreo actual: ${Green_font_prefix}No monitoreado${Font_color_suffix}"
  1827. msg -bar
  1828. echo -e "Ok para abrir ${Green_font_prefix}Servidor ShadowsocksR ejecutando monitoreo de estado${Font_color_suffix} Funcion? (Cuando el proceso R lado SSR R)[Y/n]"
  1829. msg -bar
  1830. stty erase '^H' && read -p "(Predeterminado: y):" crontab_monitor_ssr_status_ny
  1831. [[ -z "${crontab_monitor_ssr_status_ny}" ]] && crontab_monitor_ssr_status_ny="y"
  1832. if [[ ${crontab_monitor_ssr_status_ny} == [Yy] ]]; then
  1833. crontab_monitor_ssr_cron_start
  1834. else
  1835. echo && echo " Cancelado ..." && echo
  1836. fi
  1837. else
  1838. echo && echo -e "Modo de monitoreo actual: ${Green_font_prefix}Abierto${Font_color_suffix}"
  1839. msg -bar
  1840. echo -e "Ok para apagar ${Green_font_prefix}Servidor ShadowsocksR ejecutando monitoreo de estado${Font_color_suffix} Funcion? (procesar servidor SSR)[y/N]"
  1841. msg -bar
  1842. stty erase '^H' && read -p "(Predeterminado: n):" crontab_monitor_ssr_status_ny
  1843. [[ -z "${crontab_monitor_ssr_status_ny}" ]] && crontab_monitor_ssr_status_ny="n"
  1844. if [[ ${crontab_monitor_ssr_status_ny} == [Yy] ]]; then
  1845. crontab_monitor_ssr_cron_stop
  1846. else
  1847. echo && echo " Cancelado ..." && echo
  1848. fi
  1849. fi
  1850. }
  1851. crontab_monitor_ssr() {
  1852. SSR_installation_status
  1853. check_pid
  1854. if [[ -z ${PID} ]]; then
  1855. echo -e "${Error} [$(date "+%Y-%m-%d %H:%M:%S %u %Z")] Detectado que el servidor ShadowsocksR no esta iniciado, inicie..." | tee -a ${ssr_log_file}
  1856. /etc/init.d/ssrmu start
  1857. sleep 1s
  1858. check_pid
  1859. if [[ -z ${PID} ]]; then
  1860. echo -e "${Error} [$(date "+%Y-%m-%d %H:%M:%S %u %Z")] Fallo el inicio del servidor ShadowsocksR..." | tee -a ${ssr_log_file} && exit 1
  1861. else
  1862. echo -e "${Info} [$(date "+%Y-%m-%d %H:%M:%S %u %Z")] Inicio de inicio del servidor ShadowsocksR..." | tee -a ${ssr_log_file} && exit 1
  1863. fi
  1864. else
  1865. echo -e "${Info} [$(date "+%Y-%m-%d %H:%M:%S %u %Z")] El proceso del servidor ShadowsocksR se ejecuta normalmente..." exit 0
  1866. fi
  1867. }
  1868. crontab_monitor_ssr_cron_start() {
  1869. crontab -l >"$file/crontab.bak"
  1870. sed -i "/ssrmu.sh monitor/d" "$file/crontab.bak"
  1871. echo -e "\n* * * * * /bin/bash $file/ssrmu.sh monitor" >>"$file/crontab.bak"
  1872. crontab "$file/crontab.bak"
  1873. rm -r "$file/crontab.bak"
  1874. cron_config=$(crontab -l | grep "ssrmu.sh monitor")
  1875. if [[ -z ${cron_config} ]]; then
  1876. echo -e "${Error} Fallo el arranque del servidor ShadowsocksR!" && exit 1
  1877. else
  1878. echo -e "${Info} El servidor ShadowsocksR esta ejecutando la monitorizacion del estado con exito!"
  1879. fi
  1880. }
  1881. crontab_monitor_ssr_cron_stop() {
  1882. crontab -l >"$file/crontab.bak"
  1883. sed -i "/ssrmu.sh monitor/d" "$file/crontab.bak"
  1884. crontab "$file/crontab.bak"
  1885. rm -r "$file/crontab.bak"
  1886. cron_config=$(crontab -l | grep "ssrmu.sh monitor")
  1887. if [[ ! -z ${cron_config} ]]; then
  1888. echo -e "${Error} Fallo la detencion del servidor ShadowsocksR!" && exit 1
  1889. else
  1890. echo -e "${Info} La supervision del estado de ejecucion del servidor de ShadowsocksR se detiene correctamente!"
  1891. fi
  1892. }
  1893. Update_Shell() {
  1894. clear
  1895. msg -bar
  1896. echo -e "La version actual es [ ${sh_ver} ], Comienza a detectar la ultima version ..."
  1897. sh_new_ver=$(wget --no-check-certificate -qO- "https://raw.githubusercontent.com/hybtoy/ssrrmu/master/ssrrmu.sh" | grep 'sh_ver="' | awk -F "=" '{print $NF}' | sed 's/\"//g' | head -1) && sh_new_type="github"
  1898. [[ -z ${sh_new_ver} ]] && sh_new_ver=$(wget --no-check-certificate -qO- "https://raw.githubusercontent.com/hybtoy/ssrrmu/master/ssrrmu.sh" | grep 'sh_ver="' | awk -F "=" '{print $NF}' | sed 's/\"//g' | head -1) && sh_new_type="github"
  1899. [[ -z ${sh_new_ver} ]] && echo -e "${Error} Ultima version de deteccion !" && exit 0
  1900. if [[ ${sh_new_ver} != ${sh_ver} ]]; then
  1901. echo -e "Descubrir nueva version[ ${sh_new_ver} ], Esta actualizado?[Y/n]"
  1902. msg -bar
  1903. stty erase '^H' && read -p "(Predeterminado: y):" yn
  1904. [[ -z "${yn}" ]] && yn="y"
  1905. if [[ ${yn} == [Yy] ]]; then
  1906. cd "${file}"
  1907. if [[ $sh_new_type == "github" ]]; then
  1908. wget -N --no-check-certificate https://raw.githubusercontent.com/hybtoy/ssrrmu/master/ssrrmu.sh && chmod +x ssrrmu.sh
  1909. fi
  1910. echo -e "El script ha sido actualizado a la ultima version.[ ${sh_new_ver} ] !"
  1911. else
  1912. echo && echo " Cancelado ..." && echo
  1913. fi
  1914. else
  1915. echo -e "Actualmente es la ultima version.[ ${sh_new_ver} ] !"
  1916. fi
  1917. exit 0
  1918. }
  1919. # Mostrar el estado del menu
  1920. menu_status() {
  1921. msg -bar
  1922. if [[ -e ${ssr_folder} ]]; then
  1923. check_pid
  1924. if [[ ! -z "${PID}" ]]; then
  1925. echo -e " VPS-MX By @Kalix1\n Estado actual: ${Green_font_prefix}Instalado${Font_color_suffix} y ${Green_font_prefix}Iniciado${Font_color_suffix}"
  1926. else
  1927. echo -e " Estado actual: ${Green_font_prefix}Instalado${Font_color_suffix} pero ${Red_font_prefix}no comenzo${Font_color_suffix}"
  1928. fi
  1929. cd "${ssr_folder}"
  1930. else
  1931. echo -e " Estado actual: ${Red_font_prefix}No Instalado${Font_color_suffix}"
  1932. fi
  1933. }
  1934. check_sys
  1935. [[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} el script no es compatible con el sistema actual ${release} !" && exit 1
  1936. action=$1
  1937. if [[ "${action}" == "clearall" ]]; then
  1938. Clear_transfer_all
  1939. elif [[ "${action}" == "monitor" ]]; then
  1940. crontab_monitor_ssr
  1941. else
  1942. echo -e "$(msg -tit) "
  1943. echo -e " Controlador de ShadowSock-R ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
  1944. $(msg -bar)
  1945. ${Green_font_prefix}1.${Font_color_suffix} Instalar ShadowsocksR
  1946. ${Green_font_prefix}2.${Font_color_suffix} Actualizar ShadowsocksR
  1947. ${Green_font_prefix}3.${Font_color_suffix} Desinstalar ShadowsocksR
  1948. ${Green_font_prefix}4.${Font_color_suffix} Instalar libsodium (chacha20)
  1949. —————————————
  1950. ${Green_font_prefix}5.${Font_color_suffix} Verifique la informacion de la cuenta
  1951. ${Green_font_prefix}6.${Font_color_suffix} Mostrar la informacion de conexion
  1952. ${Green_font_prefix}7.${Font_color_suffix} Agregar/Modificar/Eliminar la configuracion del usuario
  1953. ${Green_font_prefix}8.${Font_color_suffix} Modificar manualmente la configuracion del usuario
  1954. ${Green_font_prefix}9.${Font_color_suffix} Borrar el trafico usado
  1955. ——————————————
  1956. ${Green_font_prefix}10.${Font_color_suffix} Iniciar ShadowsocksR
  1957. ${Green_font_prefix}11.${Font_color_suffix} Detener ShadowsocksR
  1958. ${Green_font_prefix}12.${Font_color_suffix} Reiniciar ShadowsocksR
  1959. ${Green_font_prefix}13.${Font_color_suffix} Verificar Registro de ShadowsocksR
  1960. —————————————
  1961. ${Green_font_prefix}14.${Font_color_suffix} Otras Funciones
  1962. ${Green_font_prefix}15.${Font_color_suffix} Actualizar Script
  1963. $(msg -bar)
  1964. ${Green_font_prefix}16.${Font_color_suffix}${Red_font_prefix} SALIR"
  1965. menu_status
  1966. msg -bar
  1967. stty erase '^H' && read -p "Porfavor seleccione una opcion [1-16]:" num
  1968. msg -bar
  1969. case "$num" in
  1970. 1)
  1971. Install_SSR
  1972. ;;
  1973. 2)
  1974. Update_SSR
  1975. ;;
  1976. 3)
  1977. Uninstall_SSR
  1978. ;;
  1979. 4)
  1980. Install_Libsodium
  1981. ;;
  1982. 5)
  1983. View_User
  1984. ;;
  1985. 6)
  1986. View_user_connection_info
  1987. ;;
  1988. 7)
  1989. Modify_Config
  1990. ;;
  1991. 8)
  1992. Manually_Modify_Config
  1993. ;;
  1994. 9)
  1995. Clear_transfer
  1996. ;;
  1997. 10)
  1998. Start_SSR
  1999. ;;
  2000. 11)
  2001. Stop_SSR
  2002. ;;
  2003. 12)
  2004. Restart_SSR
  2005. ;;
  2006. 13)
  2007. View_Log
  2008. ;;
  2009. 14)
  2010. Other_functions
  2011. ;;
  2012. 15)
  2013. Update_Shell
  2014. ;;
  2015. 16)
  2016. exit 1
  2017. ;;
  2018. *)
  2019. echo -e "${Error} Porfavor use numeros del [1-16]"
  2020. msg -bar
  2021. ;;
  2022. esac
  2023. fi