package web import ( "strconv" "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" ) // EvidenceView shows what a checker saw of one HTTP exchange. type EvidenceView struct { MonitorID string MonitorName string Time string Region string OK bool Error string // FailedAt is the catalog key of the stage a failed exchange stopped // in, or empty. FailedAt string RemoteAddr string Phases []TimingPhase Total string Steps []EvidenceStep TLS *TLSView ContentType string Body string Truncated bool Binary bool } // TimingPhase is one part of the request time; Percent sizes its bar. type TimingPhase struct { Key string Value string Percent float64 } // EvidenceStep is one request and response of the redirect chain. type EvidenceStep struct { Method string URL string Status string Proto string RequestHeaders [][2]string ResponseHeaders [][2]string } // TLSView describes the server certificate. type TLSView struct { Version string Cipher string Subject string Issuer string Names string NotBefore string NotAfter string DaysLeft int } // EvidenceRow links to evidence from the monitor page. type EvidenceRow struct { URL string Time string Region string OK bool Detail string } templ evidenceList(rows []EvidenceRow) {
@sectionHeading("evidence.title")

{ i18n.T(ctx, "evidence.intro") }

} templ headerTable(rows [][2]string) { for _, h := range rows { }
{ h[0] } { h[1] }
} templ EvidencePage(p Page, me Me, v EvidenceView) { @consoleShell(p, me) {

← { v.MonitorName }

if v.OK { @statusDot(StatusUp) } else { @statusDot(StatusDown) } { i18n.T(ctx, "evidence.heading") }

{ v.Time } · { v.Region } if v.RemoteAddr != "" { { " · " + v.RemoteAddr } }

if !v.OK {

{ v.Error } if v.FailedAt != "" { { i18n.T(ctx, "evidence.failed_at", "Stage", i18n.T(ctx, "evidence.stage_"+v.FailedAt)) } }

}
@sectionHeading("evidence.timing")
for i, ph := range v.Phases {
{ i18n.T(ctx, "evidence.phase_"+ph.Key) }
{ ph.Value }
}
{ i18n.T(ctx, "evidence.total") }
{ v.Total }
@sectionHeading("evidence.chain")
    for i, st := range v.Steps {
  1. { strconv.Itoa(i + 1) } { st.Method } { st.URL } if st.Status != "" { { st.Status } { st.Proto } } else { { i18n.T(ctx, "evidence.no_response") } }
    { i18n.T(ctx, "evidence.headers") }

    { i18n.T(ctx, "evidence.request") }

    @headerTable(st.RequestHeaders)

    { i18n.T(ctx, "evidence.response") }

    @headerTable(st.ResponseHeaders)
  2. }
if v.TLS != nil {
@sectionHeading("evidence.certificate")
{ i18n.T(ctx, "evidence.cert_subject") }
{ v.TLS.Subject }
{ i18n.T(ctx, "evidence.cert_names") }
{ v.TLS.Names }
{ i18n.T(ctx, "evidence.cert_issuer") }
{ v.TLS.Issuer }
{ i18n.T(ctx, "evidence.cert_valid") }
{ v.TLS.NotBefore } – { v.TLS.NotAfter } = 14) }> if v.TLS.DaysLeft < 0 { { i18n.T(ctx, "evidence.cert_expired") } } else { { i18n.T(ctx, "evidence.cert_days_left", "Count", v.TLS.DaysLeft) } }
{ i18n.T(ctx, "evidence.tls_version") }
{ v.TLS.Version } · { v.TLS.Cipher }
}
@sectionHeading("evidence.body") if v.Binary {

{ i18n.T(ctx, "evidence.body_binary") }

} else if v.Body == "" {

{ i18n.T(ctx, "evidence.body_empty") }

} else {

{ v.ContentType } if v.Truncated { { " · " + i18n.T(ctx, "evidence.body_truncated") } }

{ v.Body }
}
} }