mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-29 19:32:51 +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) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -457,6 +457,14 @@
|
|||
</a-select>
|
||||
</a-input-group>
|
||||
</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-button type="primary" icon="download" @click="FileManager.downloadTextFile(xraylogModal.logs?.join('\n'), 'x-ui.log')"></a-button>
|
||||
</a-form-item>
|
||||
|
|
@ -651,6 +659,9 @@
|
|||
visible: false,
|
||||
logs: [],
|
||||
rows: 20,
|
||||
showDirect: true,
|
||||
showBlocked: true,
|
||||
showProxy: true,
|
||||
loading: false,
|
||||
show(logs) {
|
||||
this.visible = true;
|
||||
|
|
@ -817,7 +828,7 @@ ${dateTime}
|
|||
},
|
||||
async openXrayLogs(){
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ func (s *ServerService) GetLogs(count string, level string, syslog string) []str
|
|||
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)
|
||||
var lines []string
|
||||
|
||||
|
|
@ -500,9 +500,23 @@ func (s *ServerService) GetXrayLogs(count string) []string {
|
|||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
||||
if strings.TrimSpace(line) == "" || strings.Contains(line, "api -> api") {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue