port-ws.sh 2.4 KB

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