Compare commits

..

No commits in common. "23c7c81e45977c740b1f1dbb1192b9ecca30cce7" and "8822b541d001cbb821ad5d86baf09796ed1a4980" have entirely different histories.

3 changed files with 54 additions and 124 deletions

View file

@ -2,7 +2,6 @@
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
blue='\033[0;34m'
yellow='\033[0;33m' yellow='\033[0;33m'
plain='\033[0m' plain='\033[0m'
@ -261,24 +260,24 @@ install_x-ui() {
systemctl start x-ui systemctl start x-ui
echo -e "${green}x-ui ${tag_version}${plain} installation finished, it is running now..." echo -e "${green}x-ui ${tag_version}${plain} installation finished, it is running now..."
echo -e "" echo -e ""
echo -e "┌───────────────────────────────────────────────────────┐ echo -e "x-ui control menu usages: "
${blue}x-ui control menu usages (subcommands):${plain} echo -e "----------------------------------------------"
│ │ echo -e "SUBCOMMANDS:"
${blue}x-ui${plain} - Admin Management Script │ echo -e "x-ui - Admin Management Script"
${blue}x-ui start${plain} - Start │ echo -e "x-ui start - Start"
${blue}x-ui stop${plain} - Stop │ echo -e "x-ui stop - Stop"
${blue}x-ui restart${plain} - Restart │ echo -e "x-ui restart - Restart"
${blue}x-ui status${plain} - Current Status │ echo -e "x-ui status - Current Status"
${blue}x-ui settings${plain} - Current Settings │ echo -e "x-ui settings - Current Settings"
${blue}x-ui enable${plain} - Enable Autostart on OS Startup │ echo -e "x-ui enable - Enable Autostart on OS Startup"
${blue}x-ui disable${plain} - Disable Autostart on OS Startup │ echo -e "x-ui disable - Disable Autostart on OS Startup"
${blue}x-ui log${plain} - Check logs │ echo -e "x-ui log - Check logs"
${blue}x-ui banlog${plain} - Check Fail2ban ban logs │ echo -e "x-ui banlog - Check Fail2ban ban logs"
${blue}x-ui update${plain} - Update │ echo -e "x-ui update - Update"
${blue}x-ui legacy${plain} - legacy version │ echo -e "x-ui legacy - legacy version"
${blue}x-ui install${plain} - Install │ echo -e "x-ui install - Install"
${blue}x-ui uninstall${plain} - Uninstall │ echo -e "x-ui uninstall - Uninstall"
└───────────────────────────────────────────────────────┘" echo -e "----------------------------------------------"
} }
echo -e "${green}Running...${plain}" echo -e "${green}Running...${plain}"

View file

@ -185,25 +185,6 @@
<a-tag>↑ [[ sizeFormat(infoModal.clientStats.up) ]] / [[ sizeFormat(infoModal.clientStats.down) ]] ↓</a-tag> <a-tag>↑ [[ sizeFormat(infoModal.clientStats.up) ]] / [[ sizeFormat(infoModal.clientStats.down) ]] ↓</a-tag>
</td> </td>
</tr> </tr>
<tr v-if="app.ipLimitEnable">
<td>{{ i18n "pages.inbounds.IPLimit" }}</td>
<td>
<a-tag>[[ infoModal.clientSettings.limitIp ]]</a-tag>
</td>
</tr>
<tr v-if="app.ipLimitEnable">
<td>{{ i18n "pages.inbounds.IPLimitlog" }}</td>
<td>
<a-tag>[[ infoModal.clientIps ]]</a-tag>
<a-icon type="sync" :spin="refreshing" @click="refreshIPs" style="margin: 0 5px;"></a-icon>
<a-tooltip :title="[[ dbInbound.address ]]">
<template slot="title">
<span>{{ i18n "pages.inbounds.IPLimitlogclear" }}</span>
</template>
<a-icon type="delete" @click="clearClientIps"></a-icon>
</a-tooltip>
</td>
</tr>
</table> </table>
<table style="display: inline-table; margin-block: 10px; width: 100%; text-align: center;"> <table style="display: inline-table; margin-block: 10px; width: 100%; text-align: center;">
<tr> <tr>
@ -436,18 +417,6 @@
</template> </template>
</a-modal> </a-modal>
<script> <script>
function refreshIPs(email) {
return HttpUtil.post(`/panel/inbound/clientIps/${email}`).then((msg) => {
if (msg.success) {
try {
return JSON.parse(msg.obj).join(', ');
} catch (e) {
return msg.obj;
}
}
});
}
const infoModal = { const infoModal = {
visible: false, visible: false,
inbound: new Inbound(), inbound: new Inbound(),
@ -462,7 +431,6 @@
isExpired: false, isExpired: false,
subLink: '', subLink: '',
subJsonLink: '', subJsonLink: '',
clientIps: '',
show(dbInbound, index) { show(dbInbound, index) {
this.index = index; this.index = index;
this.inbound = dbInbound.toInbound(); this.inbound = dbInbound.toInbound();
@ -470,12 +438,6 @@
this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null; this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null;
this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry; this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry;
this.clientStats = this.inbound.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : []; this.clientStats = this.inbound.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
if (app.ipLimitEnable && this.clientSettings.limitIp) {
refreshIPs(this.clientStats.email).then((ips) => {
this.clientIps = ips;
})
}
if (this.inbound.protocol == Protocols.WIREGUARD) { if (this.inbound.protocol == Protocols.WIREGUARD) {
this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n') this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n')
} else { } else {
@ -504,7 +466,6 @@
el: '#inbound-info-modal', el: '#inbound-info-modal',
data: { data: {
infoModal, infoModal,
refreshing: false,
get dbInbound() { get dbInbound() {
return this.infoModal.dbInbound; return this.infoModal.dbInbound;
}, },
@ -541,26 +502,6 @@
remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down; remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down;
return remained > 0 ? sizeFormat(remained) : '-'; return remained > 0 ? sizeFormat(remained) : '-';
}, },
refreshIPs() {
this.refreshing = true;
refreshIPs(this.infoModal.clientStats.email)
.then((ips) => {
this.infoModal.clientIps = ips;
})
.finally(() => {
this.refreshing = false;
});
},
clearClientIps() {
HttpUtil.post(`/panel/inbound/clearClientIps/${this.infoModal.clientStats.email}`)
.then((msg) => {
if (!msg.success) {
return;
}
this.infoModal.clientIps = 'No IP Record';
})
.catch(() => {});
},
}, },
}); });
</script> </script>

82
x-ui.sh
View file

@ -743,8 +743,7 @@ install_firewall() {
ufw allow ssh ufw allow ssh
ufw allow http ufw allow http
ufw allow https ufw allow https
ufw allow 2053/tcp #webPort ufw allow 2053/tcp
ufw allow 2096/tcp #subport
# Enable the firewall # Enable the firewall
ufw --force enable ufw --force enable
@ -1376,11 +1375,6 @@ iplimit_remove_conflicts() {
done done
} }
ip_validation() {
ipv6_regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
ipv4_regex="^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)$"
}
iplimit_main() { iplimit_main() {
echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit" echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit"
echo -e "${green}\t2.${plain} Change Ban Duration" echo -e "${green}\t2.${plain} Change Ban Duration"
@ -1434,8 +1428,7 @@ iplimit_main() {
;; ;;
5) 5)
read -rp "Enter the IP address you want to ban: " ban_ip read -rp "Enter the IP address you want to ban: " ban_ip
ip_validation if [[ $ban_ip =~ ^(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]))$ || $ban_ip =~ ^(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})$ ]]; then
if [[ $ban_ip =~ $ipv4_regex || $ban_ip =~ $ipv6_regex ]]; then
fail2ban-client set 3x-ipl banip "$ban_ip" fail2ban-client set 3x-ipl banip "$ban_ip"
echo -e "${green}IP Address ${ban_ip} has been banned successfully.${plain}" echo -e "${green}IP Address ${ban_ip} has been banned successfully.${plain}"
else else
@ -1445,8 +1438,7 @@ iplimit_main() {
;; ;;
6) 6)
read -rp "Enter the IP address you want to unban: " unban_ip read -rp "Enter the IP address you want to unban: " unban_ip
ip_validation if [[ $unban_ip =~ ^(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]))$ || $unban_ip =~ ^(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})$ ]]; then
if [[ $unban_ip =~ $ipv4_regex || $unban_ip =~ $ipv6_regex ]]; then
fail2ban-client set 3x-ipl unbanip "$unban_ip" fail2ban-client set 3x-ipl unbanip "$unban_ip"
echo -e "${green}IP Address ${unban_ip} has been unbanned successfully.${plain}" echo -e "${green}IP Address ${unban_ip} has been unbanned successfully.${plain}"
else else
@ -1703,41 +1695,39 @@ show_usage() {
show_menu() { show_menu() {
echo -e " echo -e "
╔────────────────────────────────────────────────╗ ${green}3X-UI Panel Management Script${plain}
${green}3X-UI Panel Management Script${plain} ${green}0.${plain} Exit Script
${green}0.${plain} Exit Script │ ————————————————
│────────────────────────────────────────────────│ ${green}1.${plain} Install
${green}1.${plain} Install │ ${green}2.${plain} Update
${green}2.${plain} Update │ ${green}3.${plain} Update Menu
${green}3.${plain} Update Menu │ ${green}4.${plain} Legacy Version
${green}4.${plain} Legacy Version │ ${green}5.${plain} Uninstall
${green}5.${plain} Uninstall │ ————————————————
│────────────────────────────────────────────────│ ${green}6.${plain} Reset Username & Password & Secret Token
${green}6.${plain} Reset Username & Password & Secret Token │ ${green}7.${plain} Reset Web Base Path
${green}7.${plain} Reset Web Base Path │ ${green}8.${plain} Reset Settings
${green}8.${plain} Reset Settings │ ${green}9.${plain} Change Port
${green}9.${plain} Change Port │ ${green}10.${plain} View Current Settings
${green}10.${plain} View Current Settings │ ————————————————
│────────────────────────────────────────────────│ ${green}11.${plain} Start
${green}11.${plain} Start │ ${green}12.${plain} Stop
${green}12.${plain} Stop │ ${green}13.${plain} Restart
${green}13.${plain} Restart │ ${green}14.${plain} Check Status
${green}14.${plain} Check Status │ ${green}15.${plain} Logs Management
${green}15.${plain} Logs Management │ ————————————————
│────────────────────────────────────────────────│ ${green}16.${plain} Enable Autostart
${green}16.${plain} Enable Autostart │ ${green}17.${plain} Disable Autostart
${green}17.${plain} Disable Autostart │ ————————————————
│────────────────────────────────────────────────│ ${green}18.${plain} SSL Certificate Management
${green}18.${plain} SSL Certificate Management │ ${green}19.${plain} Cloudflare SSL Certificate
${green}19.${plain} Cloudflare SSL Certificate │ ${green}20.${plain} IP Limit Management
${green}20.${plain} IP Limit Management │ ${green}21.${plain} Firewall Management
${green}21.${plain} Firewall Management │ ${green}22.${plain} SSH Port Forwarding Management
${green}22.${plain} SSH Port Forwarding Management │ ————————————————
│────────────────────────────────────────────────│ ${green}23.${plain} Enable BBR
${green}23.${plain} Enable BBR │ ${green}24.${plain} Update Geo Files
${green}24.${plain} Update Geo Files │ ${green}25.${plain} Speedtest by Ookla
${green}25.${plain} Speedtest by Ookla │
╚────────────────────────────────────────────────╝
" "
show_status show_status
echo && read -p "Please enter your selection [0-25]: " num echo && read -p "Please enter your selection [0-25]: " num