mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 23:02:42 +00:00
added filters to xray logs viewer
This commit is contained in:
parent
6a17285935
commit
3c4905db9a
3 changed files with 32 additions and 3 deletions
|
|
@ -137,7 +137,11 @@ func (a *ServerController) getLogs(c *gin.Context) {
|
||||||
|
|
||||||
func (a *ServerController) getXrayLogs(c *gin.Context) {
|
func (a *ServerController) getXrayLogs(c *gin.Context) {
|
||||||
count := c.Param("count")
|
count := c.Param("count")
|
||||||
logs := a.serverService.GetXrayLogs(count)
|
filter := c.PostForm("filter")
|
||||||
|
showDirect := c.PostForm("showDirect")
|
||||||
|
showBlocked := c.PostForm("showBlocked")
|
||||||
|
showProxy := c.PostForm("showProxy")
|
||||||
|
logs := a.serverService.GetXrayLogs(count, filter, showDirect, showBlocked, showProxy)
|
||||||
jsonObj(c, logs, nil)
|
jsonObj(c, logs, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,14 @@
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-input-group>
|
</a-input-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-input size="small" v-model="xraylogModal.filter"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-checkbox v-model="xraylogModal.showDirect" @change="openXrayLogs()">Direct</a-checkbox>
|
||||||
|
<a-checkbox v-model="xraylogModal.showBlocked" @change="openXrayLogs()">Blocked</a-checkbox>
|
||||||
|
<a-checkbox v-model="xraylogModal.showProxy" @change="openXrayLogs()">Proxy</a-checkbox>
|
||||||
|
</a-form-item>
|
||||||
<a-form-item :style="{ float: 'right' }">
|
<a-form-item :style="{ float: 'right' }">
|
||||||
<a-button type="primary" icon="download" @click="FileManager.downloadTextFile(xraylogModal.logs?.join('\n'), 'x-ui.log')"></a-button>
|
<a-button type="primary" icon="download" @click="FileManager.downloadTextFile(xraylogModal.logs?.join('\n'), 'x-ui.log')"></a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
@ -651,6 +659,9 @@
|
||||||
visible: false,
|
visible: false,
|
||||||
logs: [],
|
logs: [],
|
||||||
rows: 20,
|
rows: 20,
|
||||||
|
showDirect: true,
|
||||||
|
showBlocked: true,
|
||||||
|
showProxy: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
show(logs) {
|
show(logs) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
|
|
@ -817,7 +828,7 @@ ${dateTime}
|
||||||
},
|
},
|
||||||
async openXrayLogs(){
|
async openXrayLogs(){
|
||||||
xraylogModal.loading = true;
|
xraylogModal.loading = true;
|
||||||
const msg = await HttpUtil.post('server/xraylogs/'+xraylogModal.rows);
|
const msg = await HttpUtil.post('server/xraylogs/'+xraylogModal.rows,{filter: xraylogModal.filter, showDirect: xraylogModal.showDirect, showBlocked: xraylogModal.showBlocked, showProxy: xraylogModal.showProxy});
|
||||||
if (!msg.success) {
|
if (!msg.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,7 @@ func (s *ServerService) GetLogs(count string, level string, syslog string) []str
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServerService) GetXrayLogs(count string) []string {
|
func (s *ServerService) GetXrayLogs(count string, filter string, showDirect string, showBlocked string, showProxy string) []string {
|
||||||
c, _ := strconv.Atoi(count)
|
c, _ := strconv.Atoi(count)
|
||||||
var lines []string
|
var lines []string
|
||||||
|
|
||||||
|
|
@ -500,9 +500,23 @@ func (s *ServerService) GetXrayLogs(count string) []string {
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
|
|
||||||
if strings.TrimSpace(line) == "" || strings.Contains(line, "api -> api") {
|
if strings.TrimSpace(line) == "" || strings.Contains(line, "api -> api") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if filter != "" && !strings.Contains(line, filter) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if showDirect == "false" && strings.HasSuffix(line, "direct]") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if showBlocked == "false" && strings.HasSuffix(line, "blocked]") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if showProxy == "false" && !strings.HasSuffix(line, "blocked]") && !strings.HasSuffix(line, "direct]") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue