Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-04-18 21:04:06 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-04-18 21:04:06 +0300
commit3e0faecaaebd8394a1a9d18ec11b5a60f210b654 (patch)
tree70226a9e7a73155d05410bda80a38673f8db2a83 /web/controller
parentdc7dbae14a37492ac3a7e3822b3e0b250e248173 (diff)
improve reality setting
split xtls from tls - remove iran warp - remove old setting reality from franzkafka (it was a messy code) -and other improvement Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/controller')
-rw-r--r--web/controller/inbound.go10
-rw-r--r--web/controller/server.go16
-rw-r--r--web/controller/sub.go8
3 files changed, 24 insertions, 10 deletions
diff --git a/web/controller/inbound.go b/web/controller/inbound.go
index f7ea35eb..8e385248 100644
--- a/web/controller/inbound.go
+++ b/web/controller/inbound.go
@@ -33,7 +33,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) {
g.POST("/update/:id", a.updateInbound)
g.POST("/clientIps/:email", a.getClientIps)
g.POST("/clearClientIps/:email", a.clearClientIps)
- g.POST("/addClient/", a.addInboundClient)
+ g.POST("/addClient", a.addInboundClient)
g.POST("/delClient/:email", a.delInboundClient)
g.POST("/updateClient/:index", a.updateInboundClient)
g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
@@ -151,19 +151,19 @@ func (a *InboundController) clearClientIps(c *gin.Context) {
jsonMsg(c, "Log Cleared", nil)
}
func (a *InboundController) addInboundClient(c *gin.Context) {
- inbound := &model.Inbound{}
- err := c.ShouldBind(inbound)
+ data := &model.Inbound{}
+ err := c.ShouldBind(data)
if err != nil {
jsonMsg(c, I18n(c, "pages.inbounds.revise"), err)
return
}
- err = a.inboundService.AddInboundClient(inbound)
+ err = a.inboundService.AddInboundClient(data)
if err != nil {
jsonMsg(c, "something worng!", err)
return
}
- jsonMsg(c, "Client added", nil)
+ jsonMsg(c, "Client(s) added", nil)
if err == nil {
a.xrayService.SetToNeedRestart()
}
diff --git a/web/controller/server.go b/web/controller/server.go
index 24c3d623..c365ae4b 100644
--- a/web/controller/server.go
+++ b/web/controller/server.go
@@ -41,6 +41,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
g.POST("/logs/:count", a.getLogs)
g.POST("/getConfigJson", a.getConfigJson)
g.GET("/getDb", a.getDb)
+ g.POST("/getNewX25519Cert", a.getNewX25519Cert)
}
func (a *ServerController) refreshStatus() {
@@ -114,7 +115,7 @@ func (a *ServerController) getLogs(c *gin.Context) {
count := c.Param("count")
logs, err := a.serverService.GetLogs(count)
if err != nil {
- jsonMsg(c, I18n(c, "getLogs"), err)
+ jsonMsg(c, "getLogs", err)
return
}
jsonObj(c, logs, nil)
@@ -123,7 +124,7 @@ func (a *ServerController) getLogs(c *gin.Context) {
func (a *ServerController) getConfigJson(c *gin.Context) {
configJson, err := a.serverService.GetConfigJson()
if err != nil {
- jsonMsg(c, I18n(c, "getLogs"), err)
+ jsonMsg(c, "get config.json", err)
return
}
jsonObj(c, configJson, nil)
@@ -132,7 +133,7 @@ func (a *ServerController) getConfigJson(c *gin.Context) {
func (a *ServerController) getDb(c *gin.Context) {
db, err := a.serverService.GetDb()
if err != nil {
- jsonMsg(c, I18n(c, "getLogs"), err)
+ jsonMsg(c, "get Database", err)
return
}
// Set the headers for the response
@@ -142,3 +143,12 @@ func (a *ServerController) getDb(c *gin.Context) {
// Write the file contents to the response
c.Writer.Write(db)
}
+
+func (a *ServerController) getNewX25519Cert(c *gin.Context) {
+ cert, err := a.serverService.GetNewX25519Cert()
+ if err != nil {
+ jsonMsg(c, "get x25519 certificate", err)
+ return
+ }
+ jsonObj(c, cert, nil)
+}
diff --git a/web/controller/sub.go b/web/controller/sub.go
index 5695f032..9a8dfc19 100644
--- a/web/controller/sub.go
+++ b/web/controller/sub.go
@@ -29,14 +29,18 @@ func (a *SUBController) initRouter(g *gin.RouterGroup) {
func (a *SUBController) subs(c *gin.Context) {
subId := c.Param("subid")
host := strings.Split(c.Request.Host, ":")[0]
- subs, err := a.subService.GetSubs(subId, host)
- if err != nil {
+ subs, header, err := a.subService.GetSubs(subId, host)
+ if err != nil || len(subs) == 0 {
c.String(400, "Error!")
} else {
result := ""
for _, sub := range subs {
result += sub + "\n"
}
+
+ // Add subscription-userinfo
+ c.Writer.Header().Set("subscription-userinfo", header)
+
c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
}
}