mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-23 11:26:52 +00:00
better freedom/blackhole tags handling 2
This commit is contained in:
parent
ddd47d69da
commit
91a6c02f2d
2 changed files with 34 additions and 21 deletions
|
@ -457,8 +457,8 @@
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-input-group>
|
</a-input-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item label="Filter:">
|
||||||
<a-input size="small" v-model="xraylogModal.filter"></a-input>
|
<a-input size="small" v-model="xraylogModal.filter" @keyup.enter="openXrayLogs()"></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<a-checkbox v-model="xraylogModal.showDirect" @change="openXrayLogs()">Direct</a-checkbox>
|
<a-checkbox v-model="xraylogModal.showDirect" @change="openXrayLogs()">Direct</a-checkbox>
|
||||||
|
@ -676,17 +676,17 @@
|
||||||
|
|
||||||
const parts = log.split(' ');
|
const parts = log.split(' ');
|
||||||
|
|
||||||
if(parts.length === 9) {
|
if(parts.length === 10) {
|
||||||
const dateTime = `<b>${parts[0]} ${parts[1]}</b>`;
|
const dateTime = `<b>${parts[0]} ${parts[1]}</b>`;
|
||||||
const from = `<b>${parts[3]}</b>`;
|
const from = `<b>${parts[3]}</b>`;
|
||||||
const to = `<b>${parts[5].replace(/^\/+/, "")}</b>`;
|
const to = `<b>${parts[5].replace(/^\/+/, "")}</b>`;
|
||||||
|
|
||||||
let outboundColor = '';
|
let outboundColor = '';
|
||||||
if (parts[8].startsWith('blocked')) {
|
if (parts[9] === "b") {
|
||||||
outboundColor = ' style="color: #e04141;"';
|
outboundColor = ' style="color: #e04141;"'; //red for blocked
|
||||||
}
|
}
|
||||||
else if (!parts[8].startsWith('direct')) {
|
else if (parts[9] === "p") {
|
||||||
outboundColor = ' style="color: #3c89e8;"';
|
outboundColor = ' style="color: #3c89e8;"'; //blue for proxies
|
||||||
}
|
}
|
||||||
|
|
||||||
formattedLogs += `<span${outboundColor}>
|
formattedLogs += `<span${outboundColor}>
|
||||||
|
@ -695,10 +695,10 @@ ${dateTime}
|
||||||
${from}
|
${from}
|
||||||
${parts[4]}
|
${parts[4]}
|
||||||
${to}
|
${to}
|
||||||
${parts.slice(6).join(' ')}
|
${parts.slice(6, 9).join(' ')}
|
||||||
</span>`;
|
</span>`;
|
||||||
} else {
|
} else {
|
||||||
formattedLogs += `<span>${parts.join(' ')}</span>`;
|
formattedLogs += `<span>${log}</span>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -490,7 +490,8 @@ func (s *ServerService) GetXrayLogs(
|
||||||
showProxy string,
|
showProxy string,
|
||||||
freedoms []string,
|
freedoms []string,
|
||||||
blackholes []string) []string {
|
blackholes []string) []string {
|
||||||
c, _ := strconv.Atoi(count)
|
|
||||||
|
countInt, _ := strconv.Atoi(count)
|
||||||
var lines []string
|
var lines []string
|
||||||
|
|
||||||
pathToAccessLog, err := xray.GetAccessLogPath()
|
pathToAccessLog, err := xray.GetAccessLogPath()
|
||||||
|
@ -508,28 +509,40 @@ func (s *ServerService) GetXrayLogs(
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := strings.TrimSpace(scanner.Text())
|
line := strings.TrimSpace(scanner.Text())
|
||||||
|
|
||||||
if line == "" || strings.Contains(line, "api -> api") {
|
if line == "" || strings.Contains(line, "api -> api") {
|
||||||
continue
|
//skipping api calls
|
||||||
}
|
|
||||||
if filter != "" && !strings.Contains(line, filter) {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if showDirect == "false" && hasSuffix(line, freedoms) {
|
if filter != "" && !strings.Contains(line, filter) {
|
||||||
|
//skipping empty lines
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if showBlocked == "false" && hasSuffix(line, blackholes) {
|
|
||||||
continue
|
//adding suffixes to further distinguish entries by outbound
|
||||||
}
|
if hasSuffix(line, freedoms) {
|
||||||
if showProxy == "false" && !hasSuffix(line, append(freedoms, blackholes...)) {
|
if showDirect == "false" {
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
line = line + " f"
|
||||||
|
} else if hasSuffix(line, blackholes) {
|
||||||
|
if showBlocked == "false" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
line = line + " b"
|
||||||
|
} else {
|
||||||
|
if showProxy == "false" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
line = line + " p"
|
||||||
}
|
}
|
||||||
|
|
||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(lines) > c {
|
if len(lines) > countInt {
|
||||||
lines = lines[len(lines)-c:]
|
lines = lines[len(lines)-countInt:]
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
Loading…
Reference in a new issue