mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 21:20:07 +00:00
commit
844efda925
17 changed files with 340 additions and 46 deletions
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
|
||||
**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.
|
|||
|
||||
## النجوم عبر الزمن
|
||||
|
||||
[](https://starchart.cc/MHSanaei/3x-ui)
|
||||
[](https://starchart.cc/c-villain/3x-ui)
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](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.
|
||||
|
@ -23,10 +23,10 @@ Como una versión mejorada del proyecto X-UI original, 3X-UI proporciona mayor e
|
|||
## 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
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
|
||||
**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) مراجعه کنید.
|
||||
|
||||
## تشکر ویژه از
|
||||
|
||||
|
|
12
README.md
12
README.md
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](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.
|
||||
|
@ -23,10 +23,10 @@ As an enhanced fork of the original X-UI project, 3X-UI provides improved stabil
|
|||
## Quick Start
|
||||
|
||||
```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
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
|
||||
**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).
|
||||
|
||||
## Особая благодарность
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
</picture>
|
||||
</p>
|
||||
|
||||
[](https://github.com/MHSanaei/3x-ui/releases)
|
||||
[](https://github.com/MHSanaei/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/MHSanaei/3x-ui/releases/latest)
|
||||
[](https://github.com/c-villain/3x-ui/releases)
|
||||
[](https://github.com/c-villain/3x-ui/actions)
|
||||
[](#)
|
||||
[](https://github.com/c-villain/3x-ui/releases/latest)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
|
||||
**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)。
|
||||
|
||||
## 特别感谢
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ func initModels() error {
|
|||
&model.InboundClientIps{},
|
||||
&xray.ClientTraffic{},
|
||||
&model.HistoryOfSeeders{},
|
||||
&model.BlockedDomain{},
|
||||
}
|
||||
for _, model := range models {
|
||||
if err := db.AutoMigrate(model); err != nil {
|
||||
|
|
|
@ -105,3 +105,11 @@ type Client struct {
|
|||
Comment string `json:"comment" form:"comment"`
|
||||
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"`
|
||||
}
|
||||
|
|
|
@ -145,13 +145,13 @@ install_x-ui() {
|
|||
cd /usr/local/
|
||||
|
||||
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
|
||||
echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}"
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}"
|
||||
exit 1
|
||||
|
@ -166,7 +166,7 @@ install_x-ui() {
|
|||
exit 1
|
||||
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"
|
||||
wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz ${url}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
@ -193,7 +193,7 @@ install_x-ui() {
|
|||
|
||||
chmod +x x-ui bin/xray-linux-$(arch)
|
||||
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/bin/x-ui
|
||||
config_after_install
|
||||
|
|
78
web/controller/blocked_domain.go
Normal file
78
web/controller/blocked_domain.go
Normal 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})
|
||||
}
|
|
@ -26,6 +26,7 @@ func (a *XUIController) initRouter(g *gin.RouterGroup) {
|
|||
g.GET("/inbounds", a.inbounds)
|
||||
g.GET("/settings", a.settings)
|
||||
g.GET("/xray", a.xraySettings)
|
||||
g.GET("/blocked-domains", a.blockedDomains)
|
||||
|
||||
a.inboundController = NewInboundController(g)
|
||||
a.settingController = NewSettingController(g)
|
||||
|
@ -47,3 +48,7 @@ func (a *XUIController) settings(c *gin.Context) {
|
|||
func (a *XUIController) xraySettings(c *gin.Context) {
|
||||
html(c, "xray.html", "pages.xray.title", nil)
|
||||
}
|
||||
|
||||
func (a *XUIController) blockedDomains(c *gin.Context) {
|
||||
html(c, "blocked_domains.html", "menu.blocked_domains", nil)
|
||||
}
|
||||
|
|
132
web/html/blocked_domains.html
Normal file
132
web/html/blocked_domains.html
Normal 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}}
|
|
@ -64,6 +64,11 @@
|
|||
icon: 'tool',
|
||||
title: '{{ i18n "menu.xray"}}'
|
||||
},
|
||||
{
|
||||
key: '{{ .base_path }}panel/blocked-domains',
|
||||
icon: 'stop',
|
||||
title: 'Запрещённые сайты'
|
||||
},
|
||||
{
|
||||
key: '{{ .base_path }}logout/',
|
||||
icon: 'logout',
|
||||
|
|
41
web/service/blocked_domain.go
Normal file
41
web/service/blocked_domain.go
Normal 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
|
||||
}
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"x-ui/logger"
|
||||
"x-ui/xray"
|
||||
"x-ui/web/service"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
@ -72,6 +73,28 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
|
|||
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)
|
||||
|
||||
inbounds, err := s.inboundService.GetAllInbounds()
|
||||
|
|
|
@ -232,6 +232,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
|||
s.server = controller.NewServerController(g)
|
||||
s.panel = controller.NewXUIController(g)
|
||||
s.api = controller.NewAPIController(g)
|
||||
controller.NewBlockedDomainController(g)
|
||||
|
||||
return engine, nil
|
||||
}
|
||||
|
|
10
x-ui.sh
10
x-ui.sh
|
@ -74,7 +74,7 @@ before_show_menu() {
|
|||
}
|
||||
|
||||
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
|
||||
start
|
||||
|
@ -93,7 +93,7 @@ update() {
|
|||
fi
|
||||
return 0
|
||||
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
|
||||
LOGI "Update is complete, Panel has automatically restarted "
|
||||
before_show_menu
|
||||
|
@ -111,7 +111,7 @@ update_menu() {
|
|||
return 0
|
||||
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/bin/x-ui
|
||||
|
||||
|
@ -133,7 +133,7 @@ legacy_version() {
|
|||
exit 1
|
||||
fi
|
||||
# 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..."
|
||||
eval $install_command
|
||||
|
@ -164,7 +164,7 @@ uninstall() {
|
|||
echo ""
|
||||
echo -e "Uninstalled Successfully.\n"
|
||||
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 ""
|
||||
# Trap the SIGTERM signal
|
||||
trap delete_script SIGTERM
|
||||
|
|
Loading…
Reference in a new issue