v2ray.sh 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. #!/bin/bash
  2. restart(){
  3. title "REINICIANDO V2RAY"
  4. if [[ "$(v2ray restart|awk '{printf $3}')" = "success" ]]; then
  5. print_center -verd "v2ray restart success !"
  6. else
  7. print_center -verm2 "v2ray restart fail !"
  8. fi
  9. msg -bar
  10. sleep 3
  11. }
  12. ins_v2r(){
  13. title "ESTA POR INSTALAR V2RAY!"
  14. print_center -ama "La instalacion puede tener alguna fallas!\npor favor observe atentamente el log de intalacion.\npodria contener informacion sobre algunos errores!\ny deveran corregirse de forma manual antes de\ncontinuar usando el script."
  15. enter
  16. source <(curl -sL https://multi.netlify.app/v2ray.sh)
  17. }
  18. v2ray_tls(){
  19. db="$(ls ${ADM_crt})"
  20. if [[ ! "$(echo "$db"|grep '.crt')" = "" ]]; then
  21. cert=$(echo "$db"|grep '.crt')
  22. key=$(echo "$db"|grep '.key')
  23. DOMI=$(cat "${ADM_src}/dominio.txt")
  24. title "CERTIFICADO SSL ENCONTRADO"
  25. echo -e "$(msg -azu "DOMI:") $(msg -ama "$DOMI")"
  26. echo -e "$(msg -azu "CERT:") $(msg -ama "$cert")"
  27. echo -e "$(msg -azu "KEY:") $(msg -ama "$key")"
  28. msg -bar
  29. msg -ne " Continuar, usando este certificado [S/N]: " && read opcion_tls
  30. if [[ $opcion_tls = @(S|s) ]]; then
  31. cert=$(jq --arg a "${ADM_crt}/$cert" --arg b "${ADM_crt}/$key" '.inbounds[].streamSettings.tlsSettings += {"certificates":[{"certificateFile":$a,"keyFile":$b}]}' < $config)
  32. domi=$(echo "$cert"|jq --arg a "$DOMI" '.inbounds[] += {"domain":$a}')
  33. echo "$domi"|jq --arg a 'tls' '.inbounds[].streamSettings += {"security":$a}' > $temp
  34. chmod 777 $temp
  35. mv -f $temp $config
  36. restart
  37. return
  38. fi
  39. fi
  40. title "CERTIFICADO TLS V2RAY"
  41. echo -e "\033[1;37m"
  42. v2ray tls
  43. enter
  44. }
  45. removeV2Ray(){
  46. #V2ray
  47. bash <(curl -L -s https://multi.netlify.app/go.sh) --remove >/dev/null 2>&1
  48. rm -rf /etc/v2ray >/dev/null 2>&1
  49. rm -rf /var/log/v2ray >/dev/null 2>&1
  50. #Xray
  51. bash <(curl -L -s https://multi.netlify.app/go.sh) --remove -x >/dev/null 2>&1
  52. rm -rf /etc/xray >/dev/null 2>&1
  53. rm -rf /var/log/xray >/dev/null 2>&1
  54. #v2ray iptable
  55. bash <(curl -L -s https://multi.netlify.app/v2ray_util/global_setting/clean_iptables.sh)
  56. #multi-v2ray
  57. pip uninstall v2ray_util -y
  58. rm -rf /usr/share/bash-completion/completions/v2ray.bash >/dev/null 2>&1
  59. rm -rf /usr/share/bash-completion/completions/v2ray >/dev/null 2>&1
  60. rm -rf /usr/share/bash-completion/completions/xray >/dev/null 2>&1
  61. rm -rf /etc/bash_completion.d/v2ray.bash >/dev/null 2>&1
  62. rm -rf /usr/local/bin/v2ray >/dev/null 2>&1
  63. rm -rf /etc/v2ray_util >/dev/null 2>&1
  64. #v2ray
  65. crontab -l|sed '/SHELL=/d;/v2ray/d'|sed '/SHELL=/d;/xray/d' > crontab.txt
  66. crontab crontab.txt >/dev/null 2>&1
  67. rm -f crontab.txt >/dev/null 2>&1
  68. systemctl restart cron >/dev/null 2>&1
  69. #multi-v2ray
  70. sed -i '/v2ray/d' ~/.bashrc
  71. sed -i '/xray/d' ~/.bashrc
  72. source ~/.bashrc
  73. clear
  74. msg -bar
  75. print_center "V2RAY REMOVIDO!"
  76. enter
  77. return 1
  78. }
  79. v2ray_stream(){
  80. title "PROTOCOLOS V2RAY"
  81. echo -e "\033[1;37m"
  82. v2ray stream
  83. msg -bar
  84. read foo
  85. }
  86. port(){
  87. port=$(jq -r '.inbounds[].port' $config)
  88. title "CONFING PERTO V2RAY"
  89. print_center -azu "puerto actual: $(msg -ama "$port")"
  90. back
  91. in_opcion "Nuevo puerto"
  92. opcion=$(echo "$opcion" | tr -d '[[:space:]]')
  93. tput cuu1 && tput dl1
  94. if [[ -z "$opcion" ]]; then
  95. msg -ne " deves ingresar una opcion"
  96. sleep 2
  97. return
  98. elif [[ ! $opcion =~ $numero ]]; then
  99. msg -ne " solo deves ingresar numeros"
  100. sleep 2
  101. return
  102. elif [[ "$opcion" = "0" ]]; then
  103. return
  104. fi
  105. mv $config $temp
  106. jq --argjson a "$opcion" '.inbounds[] += {"port":$a}' < $temp >> $config
  107. chmod 777 $config
  108. rm $temp
  109. restart
  110. }
  111. alterid(){
  112. aid=$(jq -r '.inbounds[].settings.clients[0].alterId' $config)
  113. title "CONFING alterId V2RAY"
  114. print_center -azu "alterid actual: $(msg -ama "$aid")"
  115. back
  116. in_opcion "Nuevo alterid"
  117. opcion=$(echo "$opcion" | tr -d '[[:space:]]')
  118. tput cuu1 && tput dl1
  119. if [[ -z "$opcion" ]]; then
  120. msg -ne " deves ingresar una opcion"
  121. sleep 2
  122. return
  123. elif [[ ! $opcion =~ $numero ]]; then
  124. msg -ne " solo deves ingresar numeros"
  125. sleep 2
  126. return
  127. elif [[ "$opcion" = "0" ]]; then
  128. return
  129. fi
  130. mv $config $temp
  131. jq --argjson a "$opcion" '.inbounds[].settings.clients[] += {"alterId":$a}' < $temp >> $config
  132. chmod 777 $config
  133. rm $temp
  134. restart
  135. }
  136. n_v2ray(){
  137. title "CONFIGRACION NATIVA V2RAY"
  138. echo -ne "\033[1;37m"
  139. v2ray
  140. }
  141. address(){
  142. add=$(jq -r '.inbounds[].domain' $config) && [[ $add = null ]] && add=$(wget -qO- ipv4.icanhazip.com)
  143. title "CONFING address V2RAY"
  144. print_center -azu "actual: $(msg -ama "$add")"
  145. back
  146. in_opcion "Nuevo address"
  147. opcion=$(echo "$opcion" | tr -d '[[:space:]]')
  148. tput cuu1 && tput dl1
  149. if [[ -z "$opcion" ]]; then
  150. msg -ne " deves ingresar una opcion"
  151. sleep 2
  152. return
  153. elif [[ "$opcion" = "0" ]]; then
  154. return
  155. fi
  156. mv $config $temp
  157. jq --arg a "$opcion" '.inbounds[] += {"domain":$a}' < $temp >> $config
  158. chmod 777 $config
  159. rm $temp
  160. restart
  161. }
  162. host(){
  163. host=$(jq -r '.inbounds[].streamSettings.wsSettings.headers.Host' $config) && [[ $host = null ]] && host='sin host'
  164. title "CONFING host V2RAY"
  165. print_center -azu "Actual: $(msg -ama "$host")"
  166. back
  167. in_opcion "Nuevo host"
  168. opcion=$(echo "$opcion" | tr -d '[[:space:]]')
  169. tput cuu1 && tput dl1
  170. if [[ -z "$opcion" ]]; then
  171. msg -ne " deves ingresar una opcion"
  172. sleep 2
  173. return
  174. elif [[ "$opcion" = "0" ]]; then
  175. return
  176. fi
  177. mv $config $temp
  178. jq --arg a "$opcion" '.inbounds[].streamSettings.wsSettings.headers += {"Host":$a}' < $temp >> $config
  179. chmod 777 $config
  180. rm $temp
  181. restart
  182. }
  183. path(){
  184. path=$(jq -r '.inbounds[].streamSettings.wsSettings.path' $config) && [[ $path = null ]] && path=''
  185. title "CONFING path V2RAY"
  186. print_center -azu "Actual: $(msg -ama "$path")"
  187. back
  188. in_opcion "Nuevo path"
  189. opcion=$(echo "$opcion" | tr -d '[[:space:]]')
  190. tput cuu1 && tput dl1
  191. if [[ -z "$opcion" ]]; then
  192. msg -ne " deves ingresar una opcion"
  193. sleep 2
  194. return
  195. elif [[ "$opcion" = "0" ]]; then
  196. return
  197. fi
  198. mv $config $temp
  199. jq --arg a "$opcion" '.inbounds[].streamSettings.wsSettings += {"path":$a}' < $temp >> $config
  200. chmod 777 $config
  201. rm $temp
  202. restart
  203. }
  204. reset(){
  205. title "RESTAURANDO AJUSTES V2RAY"
  206. #resolver imprecion de texto
  207. user=$(jq -c '.inbounds[].settings.clients' < $config)
  208. v2ray new
  209. jq 'del(.inbounds[].streamSettings.kcpSettings[])' < $config > $temp
  210. rm $config
  211. jq '.inbounds[].streamSettings += {"network":"ws","wsSettings":{"path": "/ADMRufu/","headers": {"Host": "ejemplo.com"}}}' < $temp > $config
  212. chmod 777 $config
  213. rm $temp
  214. sleep 2
  215. if [[ ! -z "$user" ]]; then
  216. title "RESATURANDO USUARIOS"
  217. mv $config $temp
  218. jq --argjson a "$user" '.inbounds[].settings += {"clients":$a}' < $temp > $config
  219. chmod 777 $config
  220. sleep 2
  221. restart
  222. fi
  223. }
  224. while :
  225. do
  226. clear
  227. msg -bar
  228. print_center -verd "v2ray manager by @Rufu99"
  229. msg -bar
  230. msg -ama "INSTALACION"
  231. msg -bar3
  232. menu_func "$(msg -verd "INSTALL/RE-REINSTALL V2RAY")" \
  233. "$(msg -verm2 "DESINSTALAR V2RAY")\n$(msg -bar3)\n$(msg -ama "CONFIGRACION")\n$(msg -bar3)" \
  234. "Certif ssl/tls $(msg -ama "(menu nativo)")" \
  235. "Protocolos $(msg -ama "(menu nativo)")" \
  236. "puerto" \
  237. "alterId" \
  238. "Conf v2ray $(msg -ama "(menu nativo)")\n$(msg -bar3)\n$(msg -ama "CLIENTES")\n$(msg -bar3)" \
  239. "address" \
  240. "Host" \
  241. "Path\n$(msg -bar3)\n$(msg -ama "EXTRAS")\n$(msg -bar3)" \
  242. "Restablecer ajustes"
  243. back
  244. opcion=$(selection_fun 12)
  245. case $opcion in
  246. 1)ins_v2r;;
  247. 2)removeV2Ray;;
  248. 3)v2ray_tls;;
  249. 4)v2ray_stream;;
  250. 5)port;;
  251. 6)alterid;;
  252. 7)n_v2ray;;
  253. 8)address;;
  254. 9)host;;
  255. 10)path;;
  256. 11)reset;;
  257. 0)break;;
  258. esac
  259. [[ "$?" = "1" ]] && break
  260. done
  261. return 1