C-SSR.sh 82 KB

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