port-xws.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "XRAY VMESS TCP" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "XRAY VMESS NONE TCP" | cut -d: -f2|sed 's/ //g')"
  10. mkcp="$(cat ~/log-install.txt | grep -w "XRAY VMESS KCP" | cut -d: -f2|sed 's/ //g')"
  11. echo -e "======================================"
  12. echo -e " Change Port XRAY Vmess"
  13. echo -e ""
  14. echo -e " [1] Change Port XRAY Vmess TCP $tls"
  15. echo -e " [2] Change Port XRAY Vmess None TCP $none"
  16. echo -e " [3] Change Port XRAY Vmess KCP $mkcp"
  17. echo -e " [x] Exit"
  18. echo -e "======================================"
  19. echo -e ""
  20. read -p " Select From Options [1-3 or x] : " prot
  21. echo -e ""
  22. case $prot in
  23. 1)
  24. read -p "New Port XRAY Vmess TCP: " tls1
  25. if [ -z $tls1 ]; then
  26. echo "Please Input Port"
  27. exit 0
  28. fi
  29. cek=$(netstat -nutlp | grep -w $tls1)
  30. if [[ -z $cek ]]; then
  31. sed -i "s/$tls/$tls1/g" /etc/xray/vmesstls.json
  32. sed -i "s/ - XRAY VMESS TCP : $tls/ - XRAY VMESS TCP : $tls1/g" /root/log-install.txt
  33. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $tls -j ACCEPT
  34. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $tls -j ACCEPT
  35. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $tls1 -j ACCEPT
  36. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $tls1 -j ACCEPT
  37. iptables-save > /etc/iptables.up.rules
  38. iptables-restore -t < /etc/iptables.up.rules
  39. netfilter-persistent save > /dev/null
  40. netfilter-persistent reload > /dev/null
  41. systemctl restart xray@vmesstls > /dev/null
  42. echo -e "\e[032;1mPort $tls1 modified successfully\e[0m"
  43. else
  44. echo "Port $tls1 is used"
  45. fi
  46. ;;
  47. 2)
  48. echo "Input Only 2 Character (eg : 69)"
  49. read -p "New Port XRAY Vmess None TCP: " none1
  50. if [ -z $none1 ]; then
  51. echo "Please Input Port"
  52. exit 0
  53. fi
  54. cek=$(netstat -nutlp | grep -w $none1)
  55. if [[ -z $cek ]]; then
  56. sed -i "s/$none/$none1/g" /etc/xray/vmessnone.json
  57. sed -i "s/ - XRAY VMESS NONE TCP : $none/ - XRAY VMESS NONE TCP : $none1/g" /root/log-install.txt
  58. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $none -j ACCEPT
  59. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $none -j ACCEPT
  60. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $none1 -j ACCEPT
  61. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $none1 -j ACCEPT
  62. iptables-save > /etc/iptables.up.rules
  63. iptables-restore -t < /etc/iptables.up.rules
  64. netfilter-persistent save > /dev/null
  65. netfilter-persistent reload > /dev/null
  66. systemctl restart xray@vmessnone > /dev/null
  67. echo -e "\e[032;1mPort $none1 modified successfully\e[0m"
  68. else
  69. echo "Port $none1 is used"
  70. fi
  71. ;;
  72. 3)
  73. read -p "New Port XRAY Vmess KCP: " mkcp1
  74. if [ -z $mkcp1 ]; then
  75. echo "Please Input Port"
  76. exit 0
  77. fi
  78. cek=$(netstat -nutlp | grep -w $mkcp1)
  79. if [[ -z $cek ]]; then
  80. sed -i "s/$mkcp/$mkcp1/g" /etc/xray/mkcp.json
  81. sed -i "s/ - XRAY VMESS KCP : $mkcp/ - XRAY VMESS KCP : $mkcp1/g" /root/log-install.txt
  82. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $mkcp -j ACCEPT
  83. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $mkcp -j ACCEPT
  84. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $mkcp1 -j ACCEPT
  85. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $mkcp1 -j ACCEPT
  86. iptables-save > /etc/iptables.up.rules
  87. iptables-restore -t < /etc/iptables.up.rules
  88. netfilter-persistent save > /dev/null
  89. netfilter-persistent reload > /dev/null
  90. systemctl restart xray@mkcp.service > /dev/null
  91. echo -e "\e[032;1mPort $mkcp1 modified successfully\e[0m"
  92. else
  93. echo "Port $mkcp1 is used"
  94. fi
  95. ;;
  96. x)
  97. exit
  98. menu
  99. ;;
  100. *)
  101. echo "Please enter an correct number"
  102. ;;
  103. esac