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-11 15:11:04 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-04-11 15:11:04 +0300
commit7412bf17a927df4715b65962de5f683dade83395 (patch)
tree9a2ae08341c95ff8aa75c84c9b5c823cdb0c921a
parent519f2b462ee3340c959c57f5f92319dc011833e6 (diff)
bug fix
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
-rw-r--r--web/assets/js/model/xray.js6
-rw-r--r--web/controller/server.go25
-rw-r--r--web/html/xui/inbound_info_modal.html2
-rw-r--r--web/html/xui/index.html52
-rw-r--r--web/service/inbound.go22
-rw-r--r--web/service/server.go41
6 files changed, 118 insertions, 30 deletions
diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js
index c757f47f..f0ea1efd 100644
--- a/web/assets/js/model/xray.js
+++ b/web/assets/js/model/xray.js
@@ -1636,7 +1636,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings {
toJson() {
return {
clients: Inbound.VLESSSettings.toJsonArray(this.vlesses),
- decryption: this.decryption,
+ decryption: 'none',
fallbacks: Inbound.VLESSSettings.toJsonArray(this.fallbacks),
};
}
@@ -1696,7 +1696,7 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass {
}
};
Inbound.VLESSSettings.Fallback = class extends XrayCommonClass {
- constructor(name="", alpn=[], path='', dest='', xver=0) {
+ constructor(name="", alpn='', path='', dest='', xver=0) {
super();
this.name = name;
this.alpn = alpn;
@@ -1835,7 +1835,7 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass {
};
Inbound.TrojanSettings.Fallback = class extends XrayCommonClass {
- constructor(name="", alpn=[], path='', dest='', xver=0) {
+ constructor(name="", alpn='', path='', dest='', xver=0) {
super();
this.name = name;
this.alpn = alpn;
diff --git a/web/controller/server.go b/web/controller/server.go
index 43a1fadc..c5a3965b 100644
--- a/web/controller/server.go
+++ b/web/controller/server.go
@@ -39,6 +39,8 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
g.POST("/restartXrayService", a.restartXrayService)
g.POST("/installXray/:version", a.installXray)
g.POST("/logs/:count", a.getLogs)
+ g.POST("/getConfigJson", a.getConfigJson)
+ g.GET("/getDb", a.getDb)
}
func (a *ServerController) refreshStatus() {
@@ -117,3 +119,26 @@ func (a *ServerController) getLogs(c *gin.Context) {
}
jsonObj(c, logs, nil)
}
+
+func (a *ServerController) getConfigJson(c *gin.Context) {
+ configJson, err := a.serverService.GetConfigJson()
+ if err != nil {
+ jsonMsg(c, I18n(c, "getLogs"), err)
+ return
+ }
+ jsonObj(c, configJson, nil)
+}
+
+func (a *ServerController) getDb(c *gin.Context) {
+ db, err := a.serverService.GetDb()
+ if err != nil {
+ jsonMsg(c, I18n(c, "getLogs"), err)
+ return
+ }
+ // Set the headers for the response
+ c.Header("Content-Type", "application/octet-stream")
+ c.Header("Content-Disposition", "attachment; filename=xui.db")
+
+ // Write the file contents to the response
+ c.Writer.Write(db)
+}
diff --git a/web/html/xui/inbound_info_modal.html b/web/html/xui/inbound_info_modal.html
index 1ba15b08..1b05a12c 100644
--- a/web/html/xui/inbound_info_modal.html
+++ b/web/html/xui/inbound_info_modal.html
@@ -240,7 +240,7 @@
return infoModal.dbInbound.isEnable;
},
get subBase() {
- return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port:"") + "/sub/";
+ return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port:"") + basePath + "sub/";
},
get tgBase() {
return "https://t.me/"
diff --git a/web/html/xui/index.html b/web/html/xui/index.html
index 5a80989c..320422e3 100644
--- a/web/html/xui/index.html
+++ b/web/html/xui/index.html
@@ -76,6 +76,25 @@
<a-row>
<a-col :sm="24" :md="12">
<a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
+ 3x-ui: <a href="https://github.com/MHSanaei/3x-ui/releases" target="_blank"><a-tag color="green">v{{ .cur_ver }}</a-tag></a>
+ Xray: <a-tag color="green" style="cursor: pointer;" @click="openSelectV2rayVersion">v[[ status.xray.version ]]</a-tag>
+ Telegram: <a href="https://t.me/panel3xui" target="_blank"><a-tag color="green">@panel3xui</a-tag></a>
+ </a-card>
+ </a-col>
+ <a-col :sm="24" :md="12">
+ <a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
+ {{ i18n "pages.index.operationHours" }}:
+ <a-tag color="green">[[ formatSecond(status.uptime) ]]</a-tag>
+ <a-tooltip>
+ <template slot="title">
+ {{ i18n "pages.index.operationHoursDesc" }}
+ </template>
+ <a-icon type="question-circle" theme="filled"></a-icon>
+ </a-tooltip>
+ </a-card>
+ </a-col>
+ <a-col :sm="24" :md="12">
+ <a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
{{ i18n "pages.index.xrayStatus" }}:
<a-tag :color="status.xray.color">[[ status.xray.state ]]</a-tag>
<a-tooltip v-if="status.xray.state === State.Error">
@@ -84,7 +103,6 @@
</template>
<a-icon type="question-circle" theme="filled"></a-icon>
</a-tooltip>
- <a-tag color="green" style="cursor: pointer;" @click="openSelectV2rayVersion">[[ status.xray.version ]]</a-tag>
<a-tag color="blue" style="cursor: pointer;" @click="stopXrayService">{{ i18n "pages.index.stopXray" }}</a-tag>
<a-tag color="blue" style="cursor: pointer;" @click="restartXrayService">{{ i18n "pages.index.restartXray" }}</a-tag>
<a-tag color="blue" style="cursor: pointer;" @click="openSelectV2rayVersion">{{ i18n "pages.index.xraySwitch" }}</a-tag>
@@ -92,14 +110,10 @@
</a-col>
<a-col :sm="24" :md="12">
<a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
- {{ i18n "pages.index.operationHours" }}:
- <a-tag color="green">[[ formatSecond(status.uptime) ]]</a-tag>
- <a-tooltip>
- <template slot="title">
- {{ i18n "pages.index.operationHoursDesc" }}
- </template>
- <a-icon type="question-circle" theme="filled"></a-icon>
- </a-tooltip>
+ {{ i18n "menu.link" }}:
+ <a-tag color="blue" style="cursor: pointer;" @click="openLogs(20)">Log Reports</a-tag>
+ <a-tag color="blue" style="cursor: pointer;" @click="openConfig">Config</a-tag>
+ <a-tag color="blue" style="cursor: pointer;" @click="getBackup">Backup</a-tag>
</a-card>
</a-col>
<a-col :sm="24" :md="12">
@@ -170,13 +184,6 @@
</a-row>
</a-card>
</a-col>
- <a-col :sm="24" :md="12">
- <a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
- 3x-ui: <a href="https://github.com/MHSanaei/3x-ui/releases" target="_blank"><a-tag color="green">v{{ .cur_ver }}</a-tag></a>
- <a href="https://t.me/panel3xui" target="_blank"><a-tag color="green">Telegram</a-tag></a>
- <a-tag color="blue" style="cursor: pointer;" @click="openLogs(20)">Log Reports</a-tag>
- </a-card>
- </a-col>
</a-row>
</transition>
</a-layout-content>
@@ -226,6 +233,7 @@
</a-modal>
</a-layout>
{{template "js" .}}
+{{template "textModal"}}
<script>
const State = {
@@ -406,6 +414,18 @@
return;
}
logModal.show(msg.obj,rows);
+ },
+ async openConfig(){
+ this.loading(true);
+ const msg = await HttpUtil.post('server/getConfigJson');
+ this.loading(false);
+ if (!msg.success) {
+ return;
+ }
+ txtModal.show('config.json',JSON.stringify(msg.obj, null, 2),'config.json');
+ },
+ getBackup(){
+ window.location = basePath + 'server/getDb';
}
},
async mounted() {
diff --git a/web/service/inbound.go b/web/service/inbound.go
index 55d57997..74765ab3 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -454,19 +454,21 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
continue
}
// get settings clients
- settings := map[string][]model.Client{}
+ settings := map[string]interface{}{}
json.Unmarshal([]byte(inbound.Settings), &settings)
- clients := settings["clients"]
+ clients, ok := settings["clients"].([]model.Client)
needUpdate := false
- for client_index, client := range clients {
- if traffic.Email == client.Email {
- if client.ExpiryTime < 0 {
- clients[client_index].ExpiryTime = (time.Now().Unix() * 1000) - client.ExpiryTime
- needUpdate = true
+ if ok {
+ for client_index, client := range clients {
+ if traffic.Email == client.Email {
+ if client.ExpiryTime < 0 {
+ clients[client_index].ExpiryTime = (time.Now().Unix() * 1000) - client.ExpiryTime
+ needUpdate = true
+ }
+ client_traffic.ExpiryTime = client.ExpiryTime
+ client_traffic.Total = client.TotalGB
+ break
}
- client_traffic.ExpiryTime = client.ExpiryTime
- client_traffic.Total = client.TotalGB
- break
}
}
diff --git a/web/service/server.go b/web/service/server.go
index 91f9399a..c73fce57 100644
--- a/web/service/server.go
+++ b/web/service/server.go
@@ -13,6 +13,7 @@ import (
"runtime"
"strings"
"time"
+ "x-ui/config"
"x-ui/logger"
"x-ui/util/sys"
"x-ui/xray"
@@ -349,3 +350,43 @@ func (s *ServerService) GetLogs(count string) ([]string, error) {
return lines, nil
}
+
+func (s *ServerService) GetConfigJson() (interface{}, error) {
+ // Open the file for reading
+ file, err := os.Open(xray.GetConfigPath())
+ if err != nil {
+ return nil, err
+ }
+ defer file.Close()
+
+ // Read the file contents
+ fileContents, err := io.ReadAll(file)
+ if err != nil {
+ return nil, err
+ }
+
+ var jsonData interface{}
+ err = json.Unmarshal(fileContents, &jsonData)
+ if err != nil {
+ return nil, err
+ }
+
+ return jsonData, nil
+}
+
+func (s *ServerService) GetDb() ([]byte, error) {
+ // Open the file for reading
+ file, err := os.Open(config.GetDBPath())
+ if err != nil {
+ return nil, err
+ }
+ defer file.Close()
+
+ // Read the file contents
+ fileContents, err := io.ReadAll(file)
+ if err != nil {
+ return nil, err
+ }
+
+ return fileContents, nil
+}