Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
{$template "/datepicker"}
{$layout}
<first-menu>
<menu-item href="/servers">网站列表</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/server/log?serverId=' + server.id" active="true">"{{server.name}}"日志</menu-item>
<span class="disabled item">|</span>
<more-items-angle
:v-data-url="'/servers/nearby?serverId=' + server.id"
:v-url="'/servers/server/log?serverId=${serverId}'"></more-items-angle>
</first-menu>
{$template "/left_menu_with_menu"}
<div class="right-box with-menu">
<!-- 集群设置提醒 -->
<div v-if="!clusterAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
</div>
<!-- 网站设置提醒 -->
<div v-if="!serverAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前网站尚未启用访问日志,可以在 <a :href="'/servers/server/settings/accessLog?serverId=' + serverId">[这里]</a> 修改。</warning-message>
</div>
<first-menu>
<menu-item :href="buildLogUrl('')" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
<menu-item :href="buildLogUrl('hasError=1')" :active="hasError > 0">错误日志</menu-item>
<menu-item :href="buildLogUrl('hasWAF=1')" :active="hasWAF > 0">WAF日志</menu-item>
</first-menu>
<form method="get" class="ui form small" :action="path">
<input type="hidden" name="serverId" :value="serverId"/>
<input type="hidden" name="hasError" :value="hasError"/>
<input type="hidden" name="hasWAF" :value="hasWAF"/>
<http-access-log-search-box :v-ip="ip" :v-domain="domain" :v-keyword="keyword" :v-cluster-id="clusterId" :v-node-id="nodeId">
<div class="ui field">
<input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
</div>
<div class="ui field">
<div class="ui right labeled input">
<input type="text" name="hour" maxlength="2" style="width: 3.5em" v-model="hour"/>
<span class="ui label"></span>
</div>
</div>
</http-access-log-search-box>
</form>
<!-- 分区 -->
<http-access-log-partitions-box :v-day="day" :v-partition="partition" :v-query="currentQuery"></http-access-log-partitions-box>
<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>
<table class="ui table selectable" v-if="accessLogs.length > 0">
<!-- 这里之所以需要添加 :key是因为要不然不会刷新显示 -->
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
<td><http-access-log-box :v-access-log="accessLog" :v-keyword="keyword"></http-access-log-box></td>
</tr>
</table>
<div v-if="accessLogs.length > 0">
<a :href="buildLogUrl('requestId=' + lastRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasPrev">上一页</a>
<span v-else class="disabled">上一页</span>
<span class="disabled">&nbsp; | &nbsp;</span>
<a :href="buildLogUrl('requestId=' + nextRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasMore">下一页</a>
<span v-else class="disabled">下一页</span>
<page-size-selector></page-size-selector>
</div>
</div>

View File

@@ -0,0 +1,82 @@
Tea.context(function () {
this.$delay(function () {
let that = this
teaweb.datepicker("day-input", function (day) {
that.day = day
})
})
let that = this
this.accessLogs.forEach(function (accessLog) {
if (typeof (that.regions[accessLog.remoteAddr]) == "string") {
accessLog.region = that.regions[accessLog.remoteAddr]
} else {
accessLog.region = ""
}
if (accessLog.firewallRuleSetId > 0 && typeof (that.wafInfos[accessLog.firewallRuleSetId]) == "object") {
accessLog.wafInfo = that.wafInfos[accessLog.firewallRuleSetId]
} else {
accessLog.wafInfo = null
}
})
this.query = function (args) {
// 初始化时页面尚未设置Vue变量所以使用全局的变量获取
let that = TEA.ACTION.data
if (that.serverId == null) {
that.serverId = 0
}
if (that.keyword == null) {
that.keyword = ""
}
if (that.ip == null) {
that.ip = ""
}
if (that.domain == null) {
that.domain = ""
}
if (that.pageSize == null) {
that.pageSize = ""
}
if (that.day == null) {
that.day = ""
}
if (that.hour == null) {
that.hour = ""
}
let query = 'serverId=' + that.serverId + '&day=' + that.day + '&keyword=' + encodeURIComponent(that.keyword) + '&ip=' + that.ip + '&domain=' + that.domain + '&hour=' + that.hour + '&pageSize=' + that.pageSize
if (args != null && args.length > 0) {
query += "&" + args
}
return query
}
this.allQuery = function () {
if (this.query == null) {
// 尚未初始化完成
return
}
let query = this.query()
if (this.hasError == 1) {
query += "&hasError=1"
}
if (this.hasWAF == 1) {
query += "&hasWAF=1"
}
return query
}
this.currentQuery = this.allQuery()
// 构建日志URL
this.buildLogUrl = function (args) {
// 使用全局数据,确保在模板中也能正确访问
let that = TEA.ACTION.data
let query = this.query()
if (args != null && args.length > 0) {
query += "&" + args
}
return (that.path || this.path || "") + "?" + query
}
})

View File

@@ -0,0 +1,40 @@
{$layout}
<first-menu>
<menu-item href="/servers">网站列表</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/server/log?serverId=' + server.id" active="true">"{{server.name}}"日志</menu-item>
<span class="disabled item">|</span>
<more-items-angle
:v-data-url="'/servers/nearby?serverId=' + server.id"
:v-url="'/servers/server/log?serverId=${serverId}'"></more-items-angle>
</first-menu>
{$template "/left_menu_with_menu"}
<div class="right-box with-menu">
<!-- 集群设置提醒 -->
<div v-if="!clusterAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
</div>
<!-- 网站设置提醒 -->
<div v-if="!serverAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前网站尚未启用访问日志,可以在 <a :href="'/servers/server/settings/accessLog?serverId=' + serverId">[这里]</a> 修改。</warning-message>
</div>
<form method="get" class="ui form small" :action="path" autocomplete="off">
<input type="hidden" name="serverId" :value="serverId"/>
<http-access-log-search-box :v-ip="ip" :v-domain="domain" :v-keyword="keyword" :v-cluster-id="clusterId" :v-node-id="nodeId"></http-access-log-search-box>
</form>
<p class="comment" v-if="isLoaded && accessLogs.length == 0">今天暂时还没有访问日志。</p>
<table class="ui table selectable" v-if="accessLogs.length > 0">
<!-- 这里之所以需要添加 :key是因为要不然不会刷新显示 -->
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
<td><http-access-log-box :v-access-log="accessLog" :v-keyword="keyword"></http-access-log-box></td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,110 @@
Tea.context(function () {
this.$delay(function () {
this.load()
})
this.hasMore = false
this.accessLogs = []
this.isLoaded = false
this.mergeAccessLogs = function (newAccessLogs, regions, wafInfos) {
let mergedLogs = newAccessLogs.concat(this.accessLogs)
let result = []
let seenRequestIds = {}
let that = this
mergedLogs.forEach(function (accessLog) {
if (accessLog == null) {
return
}
let requestId = accessLog.requestId || ""
if (requestId.length > 0) {
if (seenRequestIds[requestId] === true) {
return
}
seenRequestIds[requestId] = true
}
that.formatTime(accessLog)
let region = regions[accessLog.remoteAddr]
if (typeof (region) == "string") {
accessLog.region = region
} else if (typeof accessLog.region != "string") {
accessLog.region = ""
}
let wafInfo = wafInfos[accessLog.firewallRuleSetId]
if (accessLog.firewallRuleSetId > 0 && typeof (wafInfo) == "object") {
accessLog.wafInfo = wafInfo
} else if (typeof accessLog.wafInfo == "undefined") {
accessLog.wafInfo = null
}
result.push(accessLog)
})
return result
}
this.load = function () {
// 如果有弹窗时,暂时不更新
if (teaweb.hasPopup()) {
this.$delay(function () {
this.load()
}, 5000)
return
}
this.$post("$")
.params({
serverId: this.serverId,
requestId: this.requestId,
keyword: this.keyword,
ip: this.ip,
domain: this.domain,
clusterId: this.clusterId,
nodeId: this.nodeId
})
.success(function (resp) {
let newAccessLogs = resp.data.accessLogs || []
this.accessLogs = this.mergeAccessLogs(newAccessLogs, resp.data.regions || {}, resp.data.wafInfos || {})
let max = 100
if (this.accessLogs.length > max) {
this.accessLogs = this.accessLogs.slice(0, max)
}
this.hasMore = resp.data.hasMore
if (typeof resp.data.requestId == "string" && resp.data.requestId.length > 0) {
this.requestId = resp.data.requestId
}
})
.done(function () {
if (!this.isLoaded) {
this.$delay(function () {
this.isLoaded = true
})
}
// 自动刷新
this.$delay(function () {
this.load()
}, 5000)
})
}
this.formatTime = function (accessLog) {
let elapsedSeconds = Math.ceil(new Date().getTime() / 1000) - accessLog.timestamp
if (elapsedSeconds >= 0) {
if (elapsedSeconds < 60) {
accessLog.humanTime = elapsedSeconds + "秒前"
} else if (elapsedSeconds < 3600) {
accessLog.humanTime = Math.ceil(elapsedSeconds / 60) + "分钟前"
} else if (elapsedSeconds < 3600 * 24) {
accessLog.humanTime = Math.ceil(elapsedSeconds / 3600) + "小时前"
}
}
}
})

View File

@@ -0,0 +1,60 @@
{$layout}
<first-menu>
<menu-item href="/servers">网站列表</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/server/log?serverId=' + server.id" active="true">"{{server.name}}"日志</menu-item>
<span class="disabled item">|</span>
<more-items-angle
:v-data-url="'/servers/nearby?serverId=' + server.id"
:v-url="'/servers/server/log?serverId=${serverId}'"></more-items-angle>
</first-menu>
{$template "/left_menu_with_menu"}
<div class="right-box with-menu">
<!-- 集群设置提醒 -->
<div v-if="!clusterAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
</div>
<!-- 网站设置提醒 -->
<div v-if="!serverAccessLogIsOn">
<div class="margin"></div>
<warning-message>当前网站尚未启用访问日志,可以在 <a :href="'/servers/server/settings/accessLog?serverId=' + serverId">[这里]</a> 修改。</warning-message>
</div>
<first-menu>
<menu-item :href="buildLogUrl('')" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
<menu-item :href="buildLogUrl('hasError=1')" :active="hasError > 0">错误日志</menu-item>
<menu-item :href="buildLogUrl('hasWAF=1')" :active="hasWAF > 0">WAF日志</menu-item>
</first-menu>
<form method="get" class="ui form small" :action="path">
<input type="hidden" name="serverId" :value="serverId"/>
<input type="hidden" name="hasError" :value="hasError"/>
<input type="hidden" name="hasWAF" :value="hasWAF"/>
<http-access-log-search-box :v-ip="ip" :v-domain="domain" :v-keyword="keyword" :v-cluster-id="clusterId" :v-node-id="nodeId"></http-access-log-search-box>
</form>
<!-- 分区 -->
<http-access-log-partitions-box :v-day="day" :v-partition="partition" :v-query="currentQuery"></http-access-log-partitions-box>
<p class="comment" v-if="accessLogs.length == 0">今天暂时还没有访问日志。</p>
<table class="ui table selectable" v-if="accessLogs.length > 0">
<!-- 这里之所以需要添加 :key是因为要不然不会刷新显示 -->
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
<td><http-access-log-box :v-access-log="accessLog" :v-keyword="keyword"></http-access-log-box></td>
</tr>
</table>
<div v-if="accessLogs.length > 0">
<a :href="buildLogUrl('requestId=' + lastRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasPrev">上一页</a>
<span v-else class="disabled">上一页</span>
<span class="disabled">&nbsp; | &nbsp;</span>
<a :href="buildLogUrl('requestId=' + nextRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasMore">下一页</a>
<span v-else class="disabled">下一页</span>
<page-size-selector></page-size-selector>
</div>
</div>

View File

@@ -0,0 +1,69 @@
Tea.context(function () {
let that = this
this.accessLogs.forEach(function (accessLog) {
if (typeof (that.regions[accessLog.remoteAddr]) == "string") {
accessLog.region = that.regions[accessLog.remoteAddr]
} else {
accessLog.region = ""
}
if (accessLog.firewallRuleSetId > 0 && typeof (that.wafInfos[accessLog.firewallRuleSetId]) == "object") {
accessLog.wafInfo = that.wafInfos[accessLog.firewallRuleSetId]
} else {
accessLog.wafInfo = null
}
})
this.query = function (args) {
// 初始化时页面尚未设置Vue变量所以使用全局的变量获取
let that = TEA.ACTION.data
if (that.serverId == null) {
that.serverId = 0
}
if (that.keyword == null) {
that.keyword = ""
}
if (that.ip == null) {
that.ip = ""
}
if (that.domain == null) {
that.domain = ""
}
if (that.pageSize == null) {
that.pageSize = ""
}
let query = 'serverId=' + that.serverId + '&keyword=' + encodeURIComponent(that.keyword) + '&ip=' + that.ip + '&domain=' + that.domain + '&pageSize=' + that.pageSize
if (args != null && args.length > 0) {
query += "&" + args
}
return query
}
this.allQuery = function () {
if (this.query == null) {
// 尚未初始化完成
return
}
let query = this.query()
if (this.hasError == 1) {
query += "&hasError=1"
}
if (this.hasWAF == 1) {
query += "&hasWAF=1"
}
return query
}
this.currentQuery = this.allQuery()
// 构建日志URL
this.buildLogUrl = function (args) {
// 使用全局数据,确保在模板中也能正确访问
let that = TEA.ACTION.data
let query = this.query()
if (args != null && args.length > 0) {
query += "&" + args
}
return (that.path || this.path || "") + "?" + query
}
})

View File

@@ -0,0 +1,7 @@
table td {
word-break: break-all;
}
table td.title {
width: 12em !important;
}
/*# sourceMappingURL=viewPopup.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["viewPopup.less"],"names":[],"mappings":"AAAA,KAAM;EACL,qBAAA;;AAGD,KAAM,GAAE;EACP,sBAAA","file":"viewPopup.css"}

View File

@@ -0,0 +1,160 @@
{$layout "layout_popup"}
{$template "/code_editor"}
<div class="ui menu tabular tiny">
<a class="item" :class="{active: tab == 'summary'}" @click.prevent="switchTab('summary')">综合信息</a>
<a class="item" :class="{active: tab == 'response'}" @click.prevent="switchTab('response')">响应数据Response</a>
<a class="item" :class="{active: tab == 'request'}" @click.prevent="switchTab('request')">请求数据Request</a>
<a class="item" :class="{active: tab == 'cookie'}" @click.prevent="switchTab('cookie')">Cookie</a>
<a class="item" :class="{active: tab == 'client'}" @click.prevent="switchTab('client')">终端信息</a>
</div>
<div v-if="tab == 'summary'">
<table class="ui table selectable small">
<tr>
<td style="width: 50%">请求概要<em>(Request)</em>{{accessLog.request}}</td>
<td>请求ID{{accessLog.requestId}}</td>
</tr>
<tr>
<td>请求方法<em>(RequestMethod)</em>{{accessLog.requestMethod}}</td>
<td>请求URI<em>(RequestURI)</em>{{accessLog.requestURI}}</td>
</tr>
<tr>
<td>主机地址<em>(Host)</em>{{accessLog.host}}</td>
<td>终端地址<em>(RemoteAddr:RemotePort)</em>{{accessLog.remoteAddr}}:{{accessLog.remotePort}}</td>
</tr>
<tr>
<td>请求来源<em>(Referer)</em>
<span v-if="accessLog.referer != null && accessLog.referer.length > 0">{{accessLog.referer}}</span>
<span v-else class="disabled">[没有设置]</span>
</td>
<td>终端信息<em>(UserAgent)</em>
<span v-if="accessLog.userAgent != null && accessLog.userAgent.length > 0">{{accessLog.userAgent}}</span>
<span v-else class="disabled">[没有设置]</span>
</td>
</tr>
<tr>
<td>状态<em>(StatusMessage)</em><span :class="{red:accessLog.status>=400, green:accessLog.status<400}">{{accessLog.status}} {{accessLog.statusMessage}} <span v-if="accessLog.originStatus >= 400 || (accessLog.originStatus > 0 && accessLog.originStatus != accessLog.status)" class="grey small">(源站{{accessLog.originStatus}}</span></span></td>
<td>文件类型<em>(ContentType)</em>
<span v-if="accessLog.contentType != null && accessLog.contentType.length > 0">{{accessLog.contentType}}</span>
<span v-else>-</span>
</td>
</tr>
<tr>
<td>下行流量<em>(BytesSent)</em>
<span v-if="accessLog.bytesSent != null">{{accessLog.bytesSent}}
<span v-if="accessLog.bytesSent > 0" class="grey small">{{teaweb.formatBytes(accessLog.bytesSent)}}</span>
</span>
<span v-else class="disabled">0</span>
</td>
<td>源站地址:
<span v-if="accessLog.originAddress != null && accessLog.originAddress">{{accessLog.originAddress}}</span>
<span v-else class="disabled">未访问源站</span>
</td>
</tr>
<tr>
<td>ISO8601时间{{accessLog.timeISO8601}}</td>
<td>本地时间<em>(TimeLocal)</em>{{accessLog.timeLocal}}</td>
</tr>
<tr v-if="wafInfo != null">
<td class="color-border">WAF策略{{wafInfo.policy.name}}</td>
<td>WAF规则分组
<span v-if="wafInfo.group != null">{{wafInfo.group.name}}</span>
<span v-else>-</span>
</td>
</tr>
<tr v-if="wafInfo != null && wafInfo.set != null">
<td class="color-border">WAF规则集
<a :href="'/servers/components/waf/group?firewallPolicyId=' + accessLog.firewallPolicyId + '&type=inbound&groupId=' + accessLog.firewallRuleGroupId+ '#set' + accessLog.firewallRuleSetId" v-if="wafInfo.policy.serverId == 0" target="_parent">{{wafInfo.set.name}}</a>
<a :href="'/servers/server/settings/waf/group?serverId=' + accessLog.serverId + '&firewallPolicyId=' + accessLog.firewallPolicyId + '&type=inbound&groupId=' + accessLog.firewallRuleGroupId + '#set' + accessLog.firewallRuleSetId" target="_parent" v-if="wafInfo.policy.serverId > 0">{{wafInfo.set.name}}</a> </td>
<td></td>
</tr>
<tr v-if="accessLog.errors != null && accessLog.errors.length > 0">
<td colspan="2">
<div v-for="error in accessLog.errors">
<pre><span class="red">{{error}}</span></pre>
</div>
</td>
</tr>
</table>
</div>
<div v-if="tab == 'response'">
<table class="ui table definition selectable small">
<tr>
<td class="title">Status</td>
<td>{{accessLog.status}} {{accessLog.statusMessage}}</td>
</tr>
</table>
<table class="ui table definition selectable small" v-if="responseHeaders.length > 0">
<tbody v-for="header in responseHeaders">
<tr v-for="value in header.values">
<td class="title">
<span v-if="header.isGeneral">{{header.name}}</span>
<span style="font-style: italic" v-else>{{header.name}}</span>
</td>
<td>{{value}}</td>
</tr>
</tbody>
</table>
</div>
<div v-if="tab == 'request'">
<table class="ui table definition selectable small">
<tbody v-for="header in requestHeaders">
<tr v-for="value in header.values">
<td class="title">
<span v-if="header.isGeneral">{{header.name}}</span>
<span style="font-style: italic" v-else>{{header.name}}</span>
</td>
<td>{{value}}</td>
</tr>
</tbody>
<tbody v-if="requestBody.length > 0">
<tr>
<td colspan="2">请求内容:</td>
</tr>
<tr>
<td colspan="2">
<source-code-box :type="requestContentType" width="0" height="200">{{requestBody}}</source-code-box>
</td>
</tr>
</tbody>
</table>
</div>
<div v-if="tab == 'cookie'">
<p class="comment" v-if="cookies.length == 0">暂时没有Cookie数据。</p>
<div v-else>
<table class="ui table definition selectable small">
<tr v-for="cookie in cookies">
<td class="title">{{cookie.name}}</td>
<td>{{cookie.value}}</td>
</tr>
</table>
</div>
</div>
<div v-if="tab == 'client'">
<table class="ui table definition selectable small">
<tr>
<td class="title">综合信息<em>(UserAgent)</em></td>
<td>
<span v-if="accessLog.userAgent != null && accessLog.userAgent.length > 0">{{accessLog.userAgent}}</span>
<span class="disabled" v-else>[没有设置]</span>
</td>
</tr>
<tr>
<td>IP</td>
<td>{{accessLog.remoteAddr}}</td>
</tr>
<tr v-if="region != null">
<td>区域</td>
<td>{{region.full}}</td>
</tr>
<tr v-if="region != null && region.isp != null && region.isp.length > 0">
<td>ISP</td>
<td>{{region.isp}}</td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,74 @@
Tea.context(function () {
this.tab = "summary"
this.teaweb= teaweb
this.switchTab = function (tab) {
this.tab = tab
}
// 请求Header
this.requestHeaders = []
if (this.accessLog.header != null) {
for (let k in this.accessLog.header) {
let v = this.accessLog.header[k]
if (typeof (v) != "object") {
continue
}
this.requestHeaders.push({
name: k,
values: v.values,
isGeneral: !k.startsWith("X-")
})
}
}
this.requestHeaders.sort(function (v1, v2) {
return (v1.name < v2.name) ? -1 : 1
})
// 响应Header
this.responseHeaders = []
if (this.accessLog.sentHeader != null) {
for (let k in this.accessLog.sentHeader) {
let v = this.accessLog.sentHeader[k]
if (typeof (v) != "object") {
continue
}
this.responseHeaders.push({
name: k,
values: v.values,
isGeneral: !k.startsWith("X-")
})
}
}
this.responseHeaders.sort(function (v1, v2) {
return (v1.name < v2.name) ? -1 : 1
})
// Cookie
this.cookies = []
if (this.accessLog.cookie != null) {
for (let k in this.accessLog.cookie) {
let v = this.accessLog.cookie[k]
if (typeof (v) != "string") {
continue
}
this.cookies.push({
name: k,
value: v
})
}
}
this.cookies.sort(function (v1, v2) {
if (v1.name.startsWith("_")) {
if (v2.name.startsWith("_")) {
return (v1.name < v2.name) ? -1 : 1
}
return -1
}
if (v2.name.startsWith("_")) {
return 1
}
return (v1.name.toUpperCase() < v2.name.toUpperCase()) ? -1 : 1
})
})

View File

@@ -0,0 +1,7 @@
table td {
word-break: break-all;
}
table td.title {
width: 12em !important;
}