1
0

C-SSR.sh 82 KB

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