port-ws.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. clear
  8. tls="$(cat ~/log-install.txt | grep -w "Vmess TLS" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "Vmess None TLS" | cut -d: -f2|sed 's/ //g')"
  10. echo -e "======================================" | lolcat
  11. echo -e "Name : Change Port Vmess"
  12. echo -e ""
  13. echo -e " [1] Change Port Vmess TLS $tls"
  14. echo -e " [2] Change Port Vmess None TLS $none"
  15. echo -e " [x] Exit"
  16. echo -e "======================================" | lolcat
  17. echo -e ""
  18. read -p " Select From Options [1-2 or x] : " prot
  19. echo -e ""
  20. case $prot in
  21. 1)
  22. read -p "New Port Vmess TLS: " tls1
  23. if [ -z $tls1 ]; then
  24. echo "Please Input Port"
  25. exit 0
  26. fi
  27. cek=$(netstat -nutlp | grep -w $tls1)
  28. if [[ -z $cek ]]; then
  29. sed -i "s/$tls/$tls1/g" /etc/v2ray/config.json
  30. sed -i "s/ - V2RAY Vmess TLS : $tls/ - V2RAY Vmess TLS : $tls1/g" /root/log-install.txt
  31. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $tls -j ACCEPT
  32. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $tls -j ACCEPT
  33. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $tls1 -j ACCEPT
  34. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $tls1 -j ACCEPT
  35. iptables-save > /etc/iptables.up.rules
  36. iptables-restore -t < /etc/iptables.up.rules
  37. netfilter-persistent save > /dev/null
  38. netfilter-persistent reload > /dev/null
  39. systemctl restart v2ray > /dev/null
  40. echo -e "\e[032;1mPort $tls1 modified successfully\e[0m"
  41. else
  42. echo "Port $tls1 is used"
  43. fi
  44. ;;
  45. 2)
  46. echo "Input Only 2 Character (eg : 69)"
  47. read -p "New Port Vmess None TLS: " none1
  48. if [ -z $none1 ]; then
  49. echo "Please Input Port"
  50. exit 0
  51. fi
  52. cek=$(netstat -nutlp | grep -w $none1)
  53. if [[ -z $cek ]]; then
  54. sed -i "s/$none/$none1/g" /etc/v2ray/none.json
  55. sed -i "s/ - V2RAY Vmess None TLS : $none/ - V2RAY Vmess None TLS : $none1/g" /root/log-install.txt
  56. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $none -j ACCEPT
  57. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $none -j ACCEPT
  58. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $none1 -j ACCEPT
  59. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $none1 -j ACCEPT
  60. iptables-save > /etc/iptables.up.rules
  61. iptables-restore -t < /etc/iptables.up.rules
  62. netfilter-persistent save > /dev/null
  63. netfilter-persistent reload > /dev/null
  64. systemctl restart v2ray@none > /dev/null
  65. echo -e "\e[032;1mPort $none1 modified successfully\e[0m"
  66. else
  67. echo "Port $none1 is used"
  68. fi
  69. ;;
  70. x)
  71. exit
  72. menu
  73. ;;
  74. *)
  75. echo "Please enter an correct number" | lolcat
  76. ;;
  77. esac