Compare commits

..

No commits in common. "fce7f1213db3f2177d99596d6abaa39060a594d4" and "ddd47d69da63920831d54cc2889d29450d3b8e48" have entirely different histories.

2 changed files with 20 additions and 33 deletions

View file

@ -457,8 +457,8 @@
</a-select>
</a-input-group>
</a-form-item>
<a-form-item label="Filter:">
<a-input size="small" v-model="xraylogModal.filter" @keyup.enter="openXrayLogs()"></a-input>
<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>
@ -676,17 +676,17 @@
const parts = log.split(' ');
if(parts.length === 10) {
if(parts.length === 9) {
const dateTime = `<b>${parts[0]} ${parts[1]}</b>`;
const from = `<b>${parts[3]}</b>`;
const to = `<b>${parts[5].replace(/^\/+/, "")}</b>`;
let outboundColor = '';
if (parts[9] === "b") {
outboundColor = ' style="color: #e04141;"'; //red for blocked
if (parts[8].startsWith('blocked')) {
outboundColor = ' style="color: #e04141;"';
}
else if (parts[9] === "p") {
outboundColor = ' style="color: #3c89e8;"'; //blue for proxies
else if (!parts[8].startsWith('direct')) {
outboundColor = ' style="color: #3c89e8;"';
}
formattedLogs += `<span${outboundColor}>
@ -695,10 +695,10 @@ ${dateTime}
${from}
${parts[4]}
${to}
${parts.slice(6, 9).join(' ')}
${parts.slice(6).join(' ')}
</span>`;
} else {
formattedLogs += `<span>${log}</span>`;
formattedLogs += `<span>${parts.join(' ')}</span>`;
}
});

View file

@ -490,8 +490,7 @@ func (s *ServerService) GetXrayLogs(
showProxy string,
freedoms []string,
blackholes []string) []string {
countInt, _ := strconv.Atoi(count)
c, _ := strconv.Atoi(count)
var lines []string
pathToAccessLog, err := xray.GetAccessLogPath()
@ -509,40 +508,28 @@ func (s *ServerService) GetXrayLogs(
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || strings.Contains(line, "api -> api") {
//skipping empty lines and api calls
continue
}
if filter != "" && !strings.Contains(line, filter) {
//applying filter if it's not empty
continue
}
//adding suffixes to further distinguish entries by outbound
if hasSuffix(line, freedoms) {
if showDirect == "false" {
if showDirect == "false" && hasSuffix(line, freedoms) {
continue
}
line = line + " f"
} else if hasSuffix(line, blackholes) {
if showBlocked == "false" {
if showBlocked == "false" && hasSuffix(line, blackholes) {
continue
}
line = line + " b"
} else {
if showProxy == "false" {
if showProxy == "false" && !hasSuffix(line, append(freedoms, blackholes...)) {
continue
}
line = line + " p"
}
lines = append(lines, line)
}
if len(lines) > countInt {
lines = lines[len(lines)-countInt:]
if len(lines) > c {
lines = lines[len(lines)-c:]
}
return lines