diff --git a/cockpit_web/src/DERPs.vue b/cockpit_web/src/DERPs.vue index 96c91b5..10f6423 100644 --- a/cockpit_web/src/DERPs.vue +++ b/cockpit_web/src/DERPs.vue @@ -211,7 +211,7 @@ function secondsFormat(s) { IP - 端口 + 端口 状态 - +
中继: {{ nn.NoDERP ? "已禁用" : nn.DERPPort }} @@ -286,35 +286,61 @@ function secondsFormat(s) {
- +
{{ nn.Statics.latency != -1 ? nn.Statics.latency + "ms" : "断开" - }} - - {{ - nn.Statics.latency != -1 ? nn.Statics.latency + "ms" : "断开" }}
+ + + + + + + {{ + new Date(nn.Statics.cert_expires_at) + .toLocaleDateString() + .replace("/", "年") + .replace("/", "月") + "日" + }} +
diff --git a/console_web/src/components/Navi.vue b/console_web/src/components/Navi.vue index 5b3e752..4116ab6 100644 --- a/console_web/src/components/Navi.vue +++ b/console_web/src/components/Navi.vue @@ -259,7 +259,7 @@ function secondsFormat(s) {
IP - 端口 + 端口 状态 - +
中继: {{ nn.NoDERP ? "已禁用" : nn.DERPPort }} @@ -330,7 +330,7 @@ function secondsFormat(s) {
- +
中继: {{ nn.NoDERP ? "已禁用" : nn.DERPPort }} @@ -466,35 +466,61 @@ function secondsFormat(s) {
- +
{{ nn.Statics.latency != -1 ? nn.Statics.latency + "ms" : "断开" - }} - - {{ - nn.Statics.latency != -1 ? nn.Statics.latency + "ms" : "断开" }}
+ + + + + + + {{ + new Date(nn.Statics.cert_expires_at) + .toLocaleDateString() + .replace("/", "年") + .replace("/", "月") + "日" + }} +
diff --git a/controller/protocol_noise_navictrl.go b/controller/protocol_noise_navictrl.go index 73262b2..937713c 100644 --- a/controller/protocol_noise_navictrl.go +++ b/controller/protocol_noise_navictrl.go @@ -162,7 +162,8 @@ type NaviStatus struct { PacketsSent uint64 `json:"packets_sent"` Version string `json:"version"` } `json:"derp"` - Latency int64 `json:"latency"` + Latency int64 `json:"latency"` + CertExpiresAt time.Time `json:"cert_expires_at"` } func (ns *NaviStatus) Scan(src interface{}) error { @@ -188,6 +189,7 @@ func (m *Mirage) updateNaviStatus(navi *NaviNode) error { start := time.Now() res204, err := http.DefaultClient.Do(req204) latency := time.Since(start) + certExpiresAt := res204.TLS.PeerCertificates[0].NotAfter if err != nil { navi.Statics = NaviStatus{ Latency: -1, @@ -210,7 +212,8 @@ func (m *Mirage) updateNaviStatus(navi *NaviNode) error { if navi.NaviKey == "" { //TODO: 非受控节点只检查204状态 navi.Statics = NaviStatus{ - Latency: latency.Milliseconds(), + Latency: latency.Milliseconds(), + CertExpiresAt: certExpiresAt, } err = m.db.Save(navi).Error return err @@ -241,6 +244,7 @@ func (m *Mirage) updateNaviStatus(navi *NaviNode) error { log.Debug().Msg(fmt.Sprintf("Navi %s status: %v", navi.HostName, status)) navi.Statics = status navi.Statics.Latency = latency.Milliseconds() + navi.Statics.CertExpiresAt = certExpiresAt m.db.Save(navi) return nil