更新 main.go
This commit is contained in:
71
main.go
71
main.go
@@ -520,79 +520,79 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
|
|||||||
<h2>📥 下载地址</h2>
|
<h2>📥 下载地址</h2>
|
||||||
<div class="download-link">
|
<div class="download-link">
|
||||||
<strong>IPv4 路由列表</strong>
|
<strong>IPv4 路由列表</strong>
|
||||||
<a href="%s/chnroute.rsc" download>%s/chnroute.rsc</a>
|
<a href="%[1]s/chnroute.rsc" download>%[1]s/chnroute.rsc</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="download-link">
|
<div class="download-link">
|
||||||
<strong>IPv6 路由列表</strong>
|
<strong>IPv6 路由列表</strong>
|
||||||
<a href="%s/chnroute_v6.rsc" download>%s/chnroute_v6.rsc</a>
|
<a href="%[1]s/chnroute_v6.rsc" download>%[1]s/chnroute_v6.rsc</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 使用方法 -->
|
<!-- 使用方法 -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>🔧 RouterOS 使用方法%s</h2>
|
<h2>🔧 RouterOS 使用方法%[2]s</h2>
|
||||||
|
|
||||||
<div class="protocol-note">
|
<div class="protocol-note">
|
||||||
%s
|
%[3]s
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>一键导入脚本</h3>
|
<h3>一键导入脚本</h3>
|
||||||
<div class="code-container">
|
<div class="code-container">
|
||||||
<button class="copy-btn" onclick="copyCode('code1')">📋 复制</button>
|
<button class="copy-btn" onclick="copyCode('code1')">📋 复制</button>
|
||||||
<pre id="code1"># SSH 登录 RouterOS 后执行
|
<pre id="code1"># SSH login to RouterOS and execute
|
||||||
/tool fetch url="%s/chnroute.rsc" mode=%s
|
/tool fetch url="%[1]s/chnroute.rsc" mode=%[4]s
|
||||||
/import chnroute.rsc
|
/import chnroute.rsc
|
||||||
|
|
||||||
# 验证导入
|
# Verify import
|
||||||
/ip firewall address-list print count-only where list=chnroute</pre>
|
/ip firewall address-list print count-only where list=chnroute</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 style="margin-top: 30px;">自动更新脚本(推荐)</h3>
|
<h3 style="margin-top: 30px;">自动更新脚本(推荐)</h3>
|
||||||
<div class="code-container">
|
<div class="code-container">
|
||||||
<button class="copy-btn" onclick="copyCode('code2')">📋 复制</button>
|
<button class="copy-btn" onclick="copyCode('code2')">📋 复制</button>
|
||||||
<pre id="code2"># 创建更新脚本
|
<pre id="code2"># Create update script
|
||||||
/system script add name=update-chnroute source={
|
/system script add name=update-chnroute source={
|
||||||
:log info "开始更新 CHNRoute"
|
:log info "Start updating CHNRoute"
|
||||||
/file remove [find name="chnroute.rsc"]
|
/file remove [find name="chnroute.rsc"]
|
||||||
/tool fetch url="%s/chnroute.rsc" mode=%s
|
/tool fetch url="%[1]s/chnroute.rsc" mode=%[4]s
|
||||||
:delay 3s
|
:delay 3s
|
||||||
/ip firewall address-list remove [find list=chnroute]
|
/ip firewall address-list remove [find list=chnroute]
|
||||||
/import chnroute.rsc
|
/import chnroute.rsc
|
||||||
:local count [/ip firewall address-list print count-only where list=chnroute]
|
:local count [/ip firewall address-list print count-only where list=chnroute]
|
||||||
:log info ("CHNRoute 更新完成,共 " . $count . " 条")
|
:log info ("CHNRoute updated: " . \$count . " entries")
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置每周自动执行(每周日凌晨3点)
|
# Set weekly auto-run (every Sunday at 3:00 AM)
|
||||||
/system scheduler add name=auto-update-chnroute interval=7d00:00:00 on-event="/system script run update-chnroute" start-time=03:00:00</pre>
|
/system scheduler add name=auto-update-chnroute interval=7d00:00:00 on-event="/system script run update-chnroute" start-time=03:00:00</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 style="margin-top: 30px;">IPv6 导入脚本</h3>
|
<h3 style="margin-top: 30px;">IPv6 导入脚本</h3>
|
||||||
<div class="code-container">
|
<div class="code-container">
|
||||||
<button class="copy-btn" onclick="copyCode('code3')">📋 复制</button>
|
<button class="copy-btn" onclick="copyCode('code3')">📋 复制</button>
|
||||||
<pre id="code3"># IPv6 路由列表导入
|
<pre id="code3"># Import IPv6 route list
|
||||||
/tool fetch url="%s/chnroute_v6.rsc" mode=%s
|
/tool fetch url="%[1]s/chnroute_v6.rsc" mode=%[4]s
|
||||||
/import chnroute_v6.rsc
|
/import chnroute_v6.rsc
|
||||||
|
|
||||||
# 验证导入
|
# Verify import
|
||||||
/ipv6 firewall address-list print count-only where list=chnroute6</pre>
|
/ipv6 firewall address-list print count-only where list=chnroute6</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 style="margin-top: 30px;">IPv6 自动更新脚本</h3>
|
<h3 style="margin-top: 30px;">IPv6 自动更新脚本</h3>
|
||||||
<div class="code-container">
|
<div class="code-container">
|
||||||
<button class="copy-btn" onclick="copyCode('code4')">📋 复制</button>
|
<button class="copy-btn" onclick="copyCode('code4')">📋 复制</button>
|
||||||
<pre id="code4"># 创建 IPv6 更新脚本
|
<pre id="code4"># Create IPv6 update script
|
||||||
/system script add name=update-chnroute-v6 source={
|
/system script add name=update-chnroute-v6 source={
|
||||||
:log info "开始更新 CHNRoute IPv6"
|
:log info "Start updating CHNRoute IPv6"
|
||||||
/file remove [find name="chnroute_v6.rsc"]
|
/file remove [find name="chnroute_v6.rsc"]
|
||||||
/tool fetch url="%s/chnroute_v6.rsc" mode=%s
|
/tool fetch url="%[1]s/chnroute_v6.rsc" mode=%[4]s
|
||||||
:delay 3s
|
:delay 3s
|
||||||
/ipv6 firewall address-list remove [find list=chnroute6]
|
/ipv6 firewall address-list remove [find list=chnroute6]
|
||||||
/import chnroute_v6.rsc
|
/import chnroute_v6.rsc
|
||||||
:local count [/ipv6 firewall address-list print count-only where list=chnroute6]
|
:local count [/ipv6 firewall address-list print count-only where list=chnroute6]
|
||||||
:log info ("CHNRoute IPv6 更新完成,共 " . $count . " 条")
|
:log info ("CHNRoute IPv6 updated: " . \$count . " entries")
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置每周日凌晨3点自动执行
|
# Set weekly auto-run (every Sunday at 3:00 AM)
|
||||||
/system scheduler add name=auto-update-chnroute-v6 interval=7d00:00:00 on-event="/system script run update-chnroute-v6" start-time=03:00:00</pre>
|
/system scheduler add name=auto-update-chnroute-v6 interval=7d00:00:00 on-event="/system script run update-chnroute-v6" start-time=03:00:00</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -602,14 +602,14 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
|
|||||||
<h2>📊 服务状态<span class="badge badge-success">运行中</span></h2>
|
<h2>📊 服务状态<span class="badge badge-success">运行中</span></h2>
|
||||||
<div class="status-grid">
|
<div class="status-grid">
|
||||||
<div class="status-item">
|
<div class="status-item">
|
||||||
<div class="status-icon">%s</div>
|
<div class="status-icon">%[5]s</div>
|
||||||
<div class="status-label">IPv4 缓存</div>
|
<div class="status-label">IPv4 缓存</div>
|
||||||
<div class="status-time">已缓存 %v</div>
|
<div class="status-time">已缓存 %[6]v</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-item">
|
<div class="status-item">
|
||||||
<div class="status-icon">%s</div>
|
<div class="status-icon">%[7]s</div>
|
||||||
<div class="status-label">IPv6 缓存</div>
|
<div class="status-label">IPv6 缓存</div>
|
||||||
<div class="status-time">已缓存 %v</div>
|
<div class="status-time">已缓存 %[8]v</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -650,15 +650,14 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>`,
|
</html>`,
|
||||||
baseURL, baseURL, // 1-2: 下载地址 IPv4 (href + 显示文本)
|
baseURL, // %[1]s - 重复使用多次
|
||||||
baseURL, baseURL, // 3-4: 下载地址 IPv6 (href + 显示文本)
|
protocolBadge, // %[2]s - 协议徽章
|
||||||
protocolBadge, // 5: 协议徽章
|
protocolNote, // %[3]s - 协议提示
|
||||||
protocolNote, // 6: 协议提示
|
fetchMode, // %[4]s - 重复使用多次
|
||||||
baseURL, fetchMode, // 7-8: 一键导入 (url + mode)
|
statusIPv4, // %[5]s - IPv4 状态
|
||||||
baseURL, fetchMode, // 9-10: 自动更新 (url + mode)
|
cacheAgeIPv4, // %[6]v - IPv4 缓存时间
|
||||||
baseURL, fetchMode, // 11-12: IPv6 导入 (url + mode)
|
statusIPv6, // %[7]s - IPv6 状态
|
||||||
statusIPv4, cacheAgeIPv4, // 13-14: IPv4 状态图标 + 缓存时间
|
cacheAgeIPv6) // %[8]v - IPv6 缓存时间
|
||||||
statusIPv6, cacheAgeIPv6) // 15-16: IPv6 状态图标 + 缓存时间
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
w.Write([]byte(html))
|
w.Write([]byte(html))
|
||||||
|
|||||||
Reference in New Issue
Block a user