add vpn filter

This commit is contained in:
Alexander Kraev 2025-07-22 01:38:02 +03:00
parent 011e0f309a
commit fe75ea44b7
17 changed files with 340 additions and 46 deletions

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — لوحة تحكم متقدمة مفتوحة المصدر تعتمد على الويب مصممة لإدارة خادم Xray-core. توفر واجهة سهلة الاستخدام لتكوين ومراقبة بروتوكولات VPN والوكيل المختلفة. **3X-UI** — لوحة تحكم متقدمة مفتوحة المصدر تعتمد على الويب مصممة لإدارة خادم Xray-core. توفر واجهة سهلة الاستخدام لتكوين ومراقبة بروتوكولات VPN والوكيل المختلفة.
@ -23,10 +23,10 @@
## البدء السريع ## البدء السريع
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
للحصول على الوثائق الكاملة، يرجى زيارة [ويكي المشروع](https://github.com/MHSanaei/3x-ui/wiki). للحصول على الوثائق الكاملة، يرجى زيارة [ويكي المشروع](https://github.com/c-villain/3x-ui/wiki).
## شكر خاص إلى ## شكر خاص إلى
@ -53,4 +53,4 @@ bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.
## النجوم عبر الزمن ## النجوم عبر الزمن
[![Stargazers over time](https://starchart.cc/MHSanaei/3x-ui.svg?variant=adaptive)](https://starchart.cc/MHSanaei/3x-ui) [![Stargazers over time](https://starchart.cc/c-villain/3x-ui.svg?variant=adaptive)](https://starchart.cc/c-villain/3x-ui)

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — panel de control avanzado basado en web de código abierto diseñado para gestionar el servidor Xray-core. Ofrece una interfaz fácil de usar para configurar y monitorear varios protocolos VPN y proxy. **3X-UI** — panel de control avanzado basado en web de código abierto diseñado para gestionar el servidor Xray-core. Ofrece una interfaz fácil de usar para configurar y monitorear varios protocolos VPN y proxy.
@ -23,10 +23,10 @@ Como una versión mejorada del proyecto X-UI original, 3X-UI proporciona mayor e
## Inicio Rápido ## Inicio Rápido
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
Para documentación completa, visita la [Wiki del proyecto](https://github.com/MHSanaei/3x-ui/wiki). Para documentación completa, visita la [Wiki del proyecto](https://github.com/c-villain/3x-ui/wiki).
## Un Agradecimiento Especial a ## Un Agradecimiento Especial a

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — یک پنل کنترل پیشرفته مبتنی بر وب با کد باز که برای مدیریت سرور Xray-core طراحی شده است. این پنل یک رابط کاربری آسان برای پیکربندی و نظارت بر پروتکل‌های مختلف VPN و پراکسی ارائه می‌دهد. **3X-UI** — یک پنل کنترل پیشرفته مبتنی بر وب با کد باز که برای مدیریت سرور Xray-core طراحی شده است. این پنل یک رابط کاربری آسان برای پیکربندی و نظارت بر پروتکل‌های مختلف VPN و پراکسی ارائه می‌دهد.
@ -23,10 +23,10 @@
## شروع سریع ## شروع سریع
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
برای مستندات کامل، لطفاً به [ویکی پروژه](https://github.com/MHSanaei/3x-ui/wiki) مراجعه کنید. برای مستندات کامل، لطفاً به [ویکی پروژه](https://github.com/c-villain/3x-ui/wiki) مراجعه کنید.
## تشکر ویژه از ## تشکر ویژه از

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — advanced, open-source web-based control panel designed for managing Xray-core server. It offers a user-friendly interface for configuring and monitoring various VPN and proxy protocols. **3X-UI** — advanced, open-source web-based control panel designed for managing Xray-core server. It offers a user-friendly interface for configuring and monitoring various VPN and proxy protocols.
@ -23,10 +23,10 @@ As an enhanced fork of the original X-UI project, 3X-UI provides improved stabil
## Quick Start ## Quick Start
```bash ```bash
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
For full documentation, please visit the [project Wiki](https://github.com/MHSanaei/3x-ui/wiki). For full documentation, please visit the [project Wiki](https://github.com/c-villain/3x-ui/wiki).
## A Special Thanks to ## A Special Thanks to

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — продвинутая панель управления с открытым исходным кодом на основе веб-интерфейса, разработанная для управления сервером Xray-core. Предоставляет удобный интерфейс для настройки и мониторинга различных VPN и прокси-протоколов. **3X-UI** — продвинутая панель управления с открытым исходным кодом на основе веб-интерфейса, разработанная для управления сервером Xray-core. Предоставляет удобный интерфейс для настройки и мониторинга различных VPN и прокси-протоколов.
@ -23,10 +23,10 @@
## Быстрый старт ## Быстрый старт
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
Полную документацию смотрите в [вики проекта](https://github.com/MHSanaei/3x-ui/wiki). Полную документацию смотрите в [вики проекта](https://github.com/c-villain/3x-ui/wiki).
## Особая благодарность ## Особая благодарность

View file

@ -7,10 +7,10 @@
</picture> </picture>
</p> </p>
[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/v/release/c-villain/3x-ui.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases)
[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/actions) [![](https://img.shields.io/github/actions/workflow/status/c-villain/3x-ui/release.yml.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/actions)
[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg?style=for-the-badge)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/c-villain/3x-ui.svg?style=for-the-badge)](#)
[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg?style=for-the-badge)](https://github.com/MHSanaei/3x-ui/releases/latest) [![Downloads](https://img.shields.io/github/downloads/c-villain/3x-ui/total.svg?style=for-the-badge)](https://github.com/c-villain/3x-ui/releases/latest)
[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true&style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.en.html)
**3X-UI** — 一个基于网页的高级开源控制面板,专为管理 Xray-core 服务器而设计。它提供了用户友好的界面,用于配置和监控各种 VPN 和代理协议。 **3X-UI** — 一个基于网页的高级开源控制面板,专为管理 Xray-core 服务器而设计。它提供了用户友好的界面,用于配置和监控各种 VPN 和代理协议。
@ -23,10 +23,10 @@
## 快速开始 ## 快速开始
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)
``` ```
完整文档请参阅 [项目Wiki](https://github.com/MHSanaei/3x-ui/wiki)。 完整文档请参阅 [项目Wiki](https://github.com/c-villain/3x-ui/wiki)。
## 特别感谢 ## 特别感谢

View file

@ -35,6 +35,7 @@ func initModels() error {
&model.InboundClientIps{}, &model.InboundClientIps{},
&xray.ClientTraffic{}, &xray.ClientTraffic{},
&model.HistoryOfSeeders{}, &model.HistoryOfSeeders{},
&model.BlockedDomain{},
} }
for _, model := range models { for _, model := range models {
if err := db.AutoMigrate(model); err != nil { if err := db.AutoMigrate(model); err != nil {

View file

@ -105,3 +105,11 @@ type Client struct {
Comment string `json:"comment" form:"comment"` Comment string `json:"comment" form:"comment"`
Reset int `json:"reset" form:"reset"` Reset int `json:"reset" form:"reset"`
} }
type BlockedDomain struct {
Id int `json:"id" gorm:"primaryKey;autoIncrement"`
Domain string `json:"domain" gorm:"unique;not null"`
Comment string `json:"comment"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
}

View file

@ -145,13 +145,13 @@ install_x-ui() {
cd /usr/local/ cd /usr/local/
if [ $# == 0 ]; then if [ $# == 0 ]; then
tag_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') tag_version=$(curl -Ls "https://api.github.com/repos/c-villain/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [[ ! -n "$tag_version" ]]; then if [[ ! -n "$tag_version" ]]; then
echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}" echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}"
exit 1 exit 1
fi fi
echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..." echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..."
wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz https://github.com/c-villain/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}" echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}"
exit 1 exit 1
@ -166,7 +166,7 @@ install_x-ui() {
exit 1 exit 1
fi fi
url="https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz" url="https://github.com/c-villain/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz"
echo -e "Beginning to install x-ui $1" echo -e "Beginning to install x-ui $1"
wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz ${url} wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz ${url}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
@ -193,7 +193,7 @@ install_x-ui() {
chmod +x x-ui bin/xray-linux-$(arch) chmod +x x-ui bin/xray-linux-$(arch)
cp -f x-ui.service /etc/systemd/system/ cp -f x-ui.service /etc/systemd/system/
wget -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh wget -O /usr/bin/x-ui https://raw.githubusercontent.com/c-villain/3x-ui/main/x-ui.sh
chmod +x /usr/local/x-ui/x-ui.sh chmod +x /usr/local/x-ui/x-ui.sh
chmod +x /usr/bin/x-ui chmod +x /usr/bin/x-ui
config_after_install config_after_install

View file

@ -0,0 +1,78 @@
package controller
import (
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"x-ui/database/model"
"x-ui/web/service"
)
type BlockedDomainController struct {
service *service.BlockedDomainService
}
func NewBlockedDomainController(g *gin.RouterGroup) *BlockedDomainController {
ctrl := &BlockedDomainController{service: &service.BlockedDomainService{}}
r := g.Group("/blocked-domains")
r.GET("/", ctrl.List)
r.POST("/", ctrl.Create)
r.PUT("/:id", ctrl.Update)
r.DELETE("/:id", ctrl.Delete)
return ctrl
}
func (ctrl *BlockedDomainController) List(c *gin.Context) {
domains, err := ctrl.service.GetAll()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "obj": domains})
}
func (ctrl *BlockedDomainController) Create(c *gin.Context) {
var domain model.BlockedDomain
if err := c.ShouldBindJSON(&domain); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": err.Error()})
return
}
if err := ctrl.service.Create(&domain); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "obj": domain})
}
func (ctrl *BlockedDomainController) Update(c *gin.Context) {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": "invalid id"})
return
}
var domain model.BlockedDomain
if err := c.ShouldBindJSON(&domain); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": err.Error()})
return
}
domain.Id = id
if err := ctrl.service.Update(&domain); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "obj": domain})
}
func (ctrl *BlockedDomainController) Delete(c *gin.Context) {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": "invalid id"})
return
}
if err := ctrl.service.Delete(id); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true})
}

View file

@ -26,6 +26,7 @@ func (a *XUIController) initRouter(g *gin.RouterGroup) {
g.GET("/inbounds", a.inbounds) g.GET("/inbounds", a.inbounds)
g.GET("/settings", a.settings) g.GET("/settings", a.settings)
g.GET("/xray", a.xraySettings) g.GET("/xray", a.xraySettings)
g.GET("/blocked-domains", a.blockedDomains)
a.inboundController = NewInboundController(g) a.inboundController = NewInboundController(g)
a.settingController = NewSettingController(g) a.settingController = NewSettingController(g)
@ -47,3 +48,7 @@ func (a *XUIController) settings(c *gin.Context) {
func (a *XUIController) xraySettings(c *gin.Context) { func (a *XUIController) xraySettings(c *gin.Context) {
html(c, "xray.html", "pages.xray.title", nil) html(c, "xray.html", "pages.xray.title", nil)
} }
func (a *XUIController) blockedDomains(c *gin.Context) {
html(c, "blocked_domains.html", "menu.blocked_domains", nil)
}

View file

@ -0,0 +1,132 @@
{{define "page/blocked_domains"}}
<template>
<div>
<a-card :title="i18n('menu.blocked_domains')">
<a-button type="primary" @click="showAddModal = true" style="margin-bottom: 16px;">
{{ i18n('add') }}
</a-button>
<a-table-sortable
:data-source="domains"
:row-key="'id'"
:pagination="false"
style="margin-bottom: 16px;"
>
<a-table-column title="#" :customRender="(_, __, i) => i + 1" width="50" />
<a-table-column title="{{ i18n('domain') }}" dataIndex="domain" key="domain" />
<a-table-column title="{{ i18n('comment') }}" dataIndex="comment" key="comment" />
<a-table-column
:title="i18n('action')"
key="action"
:customRender="(_, record) => actionRender(record)"
width="120"
/>
</a-table-sortable>
<a-modal v-model="showAddModal" :title="i18n('add_domain')" @ok="addDomain">
<a-form :model="addForm">
<a-form-item :label="i18n('domain')">
<a-input v-model="addForm.domain" />
</a-form-item>
<a-form-item :label="i18n('comment')">
<a-input v-model="addForm.comment" />
</a-form-item>
</a-form>
</a-modal>
<a-modal v-model="showEditModal" :title="i18n('edit_domain')" @ok="editDomain">
<a-form :model="editForm">
<a-form-item :label="i18n('domain')">
<a-input v-model="editForm.domain" />
</a-form-item>
<a-form-item :label="i18n('comment')">
<a-input v-model="editForm.comment" />
</a-form-item>
</a-form>
</a-modal>
</a-card>
</div>
</template>
<script>
new Vue({
el: '#app',
data() {
return {
domains: [],
showAddModal: false,
showEditModal: false,
addForm: { domain: '', comment: '' },
editForm: { id: null, domain: '', comment: '' },
};
},
methods: {
i18n(key) {
// Простейший i18n, можно заменить на глобальный
const dict = {
'menu.blocked_domains': 'Запрещённые сайты',
'add': 'Добавить',
'domain': 'Домен',
'comment': 'Комментарий',
'action': 'Действия',
'add_domain': 'Добавить домен',
'edit_domain': 'Редактировать домен',
'edit': 'Редактировать',
'delete': 'Удалить',
};
return dict[key] || key;
},
fetchDomains() {
axios.get('blocked-domains/').then(res => {
if (res.data.success) {
this.domains = res.data.obj;
}
});
},
addDomain() {
axios.post('blocked-domains/', this.addForm).then(res => {
if (res.data.success) {
this.showAddModal = false;
this.addForm = { domain: '', comment: '' };
this.fetchDomains();
}
});
},
editDomain() {
axios.put(`blocked-domains/${this.editForm.id}`, this.editForm).then(res => {
if (res.data.success) {
this.showEditModal = false;
this.editForm = { id: null, domain: '', comment: '' };
this.fetchDomains();
}
});
},
deleteDomain(id) {
this.$confirm({
title: this.i18n('delete'),
content: this.i18n('domain') + '?',
onOk: () => {
axios.delete(`blocked-domains/${id}`).then(res => {
if (res.data.success) {
this.fetchDomains();
}
});
},
});
},
actionRender(record) {
return (
`<a @click="editDomainShow(${record.id})">${this.i18n('edit')}</a> |
<a @click="deleteDomain(${record.id})">${this.i18n('delete')}</a>`
);
},
editDomainShow(id) {
const d = this.domains.find(x => x.id === id);
if (d) {
this.editForm = { ...d };
this.showEditModal = true;
}
},
},
mounted() {
this.fetchDomains();
},
});
</script>
{{end}}

View file

@ -64,6 +64,11 @@
icon: 'tool', icon: 'tool',
title: '{{ i18n "menu.xray"}}' title: '{{ i18n "menu.xray"}}'
}, },
{
key: '{{ .base_path }}panel/blocked-domains',
icon: 'stop',
title: 'Запрещённые сайты'
},
{ {
key: '{{ .base_path }}logout/', key: '{{ .base_path }}logout/',
icon: 'logout', icon: 'logout',

View file

@ -0,0 +1,41 @@
package service
import (
"x-ui/database"
"x-ui/database/model"
"gorm.io/gorm"
)
type BlockedDomainService struct{}
func (s *BlockedDomainService) GetAll() ([]model.BlockedDomain, error) {
db := database.GetDB()
var domains []model.BlockedDomain
err := db.Find(&domains).Error
return domains, err
}
func (s *BlockedDomainService) GetByID(id int) (*model.BlockedDomain, error) {
db := database.GetDB()
var domain model.BlockedDomain
err := db.First(&domain, id).Error
if err != nil {
return nil, err
}
return &domain, nil
}
func (s *BlockedDomainService) Create(domain *model.BlockedDomain) error {
db := database.GetDB()
return db.Create(domain).Error
}
func (s *BlockedDomainService) Update(domain *model.BlockedDomain) error {
db := database.GetDB()
return db.Save(domain).Error
}
func (s *BlockedDomainService) Delete(id int) error {
db := database.GetDB()
return db.Delete(&model.BlockedDomain{}, id).Error
}

View file

@ -7,6 +7,7 @@ import (
"x-ui/logger" "x-ui/logger"
"x-ui/xray" "x-ui/xray"
"x-ui/web/service"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
@ -72,6 +73,28 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
return nil, err return nil, err
} }
// --- Блокировка запрещённых доменов ---
blockedDomains, err := service.BlockedDomainService{}.GetAll()
if err == nil && len(blockedDomains) > 0 {
var domains []string
for _, d := range blockedDomains {
domains = append(domains, d.Domain)
}
var routing map[string]any
if err := json.Unmarshal(xrayConfig.RouterConfig, &routing); err == nil {
rules, _ := routing["rules"].([]any)
blockRule := map[string]any{
"type": "field",
"outboundTag": "blocked",
"domain": domains,
}
routing["rules"] = append(rules, blockRule)
if newRouting, err := json.MarshalIndent(routing, "", " "); err == nil {
xrayConfig.RouterConfig = newRouting
}
}
}
s.inboundService.AddTraffic(nil, nil) s.inboundService.AddTraffic(nil, nil)
inbounds, err := s.inboundService.GetAllInbounds() inbounds, err := s.inboundService.GetAllInbounds()

View file

@ -232,6 +232,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
s.server = controller.NewServerController(g) s.server = controller.NewServerController(g)
s.panel = controller.NewXUIController(g) s.panel = controller.NewXUIController(g)
s.api = controller.NewAPIController(g) s.api = controller.NewAPIController(g)
controller.NewBlockedDomainController(g)
return engine, nil return engine, nil
} }

10
x-ui.sh
View file

@ -74,7 +74,7 @@ before_show_menu() {
} }
install() { install() {
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/main/install.sh)
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
start start
@ -93,7 +93,7 @@ update() {
fi fi
return 0 return 0
fi fi
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/main/install.sh)
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
LOGI "Update is complete, Panel has automatically restarted " LOGI "Update is complete, Panel has automatically restarted "
before_show_menu before_show_menu
@ -111,7 +111,7 @@ update_menu() {
return 0 return 0
fi fi
wget -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh wget -O /usr/bin/x-ui https://raw.githubusercontent.com/c-villain/3x-ui/main/x-ui.sh
chmod +x /usr/local/x-ui/x-ui.sh chmod +x /usr/local/x-ui/x-ui.sh
chmod +x /usr/bin/x-ui chmod +x /usr/bin/x-ui
@ -133,7 +133,7 @@ legacy_version() {
exit 1 exit 1
fi fi
# Use the entered panel version in the download link # Use the entered panel version in the download link
install_command="bash <(curl -Ls "https://raw.githubusercontent.com/mhsanaei/3x-ui/v$tag_version/install.sh") v$tag_version" install_command="bash <(curl -Ls \"https://raw.githubusercontent.com/c-villain/3x-ui/v$tag_version/install.sh\") v$tag_version"
echo "Downloading and installing panel version $tag_version..." echo "Downloading and installing panel version $tag_version..."
eval $install_command eval $install_command
@ -164,7 +164,7 @@ uninstall() {
echo "" echo ""
echo -e "Uninstalled Successfully.\n" echo -e "Uninstalled Successfully.\n"
echo "If you need to install this panel again, you can use below command:" echo "If you need to install this panel again, you can use below command:"
echo -e "${green}bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)${plain}" echo -e "${green}bash <(curl -Ls https://raw.githubusercontent.com/c-villain/3x-ui/master/install.sh)${plain}"
echo "" echo ""
# Trap the SIGTERM signal # Trap the SIGTERM signal
trap delete_script SIGTERM trap delete_script SIGTERM