v2ray.sh 7.6 KB

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