From a64275fa885636b1d467fa6751b9f1ae6f6a3bda Mon Sep 17 00:00:00 2001 From: Hiddify-Official <143534788+Hiddify-Official@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:03:48 +0330 Subject: [PATCH] feat(domains): a certificate's full details and the TLS modes on hover cards Hovering a domain's certificate badge showed a few lines of text (a hint, the issuer, the expiry), and a Reality / Fake badge only "Fake and Reality TLS domains do not need a certificate of their own". - The domains API reads the stored certificate (cached per PEM): when it was issued, the names it covers, its key and the issuing organisation; with the stored fingerprint and auto-renew. - The certificate badge opens a card in the badge's colour: its state and hint, a bar of the life left with the issue and expiry dates (amber under three weeks, red under one), then issued by, covers, key, auto-renew, fingerprint, and the last error when it failed. - A TLS mode badge (Reality, Fake, DNS, a built-in server's fake-TLS name) opens a card that says what the mode does, that it needs no certificate and which name (SNI) it shows. Solid on the glass themes. Co-Authored-By: Claude Opus 5.5 --- .../admin_v2/src/features/domains/api.ts | 9 + .../features/domains/views/DomainsView.vue | 209 +++++++++++++++++- .../restapi/v2/admin/domains_page_api.py | 44 ++++ hiddifypanel/translations.i18n/en.json | 12 + hiddifypanel/translations.i18n/fa.json | 12 + hiddifypanel/translations.i18n/fr.json | 12 + hiddifypanel/translations.i18n/my.json | 12 + hiddifypanel/translations.i18n/pt.json | 12 + hiddifypanel/translations.i18n/ru.json | 12 + hiddifypanel/translations.i18n/zh.json | 12 + 10 files changed, 338 insertions(+), 8 deletions(-) diff --git a/hiddifypanel/admin_v2/src/features/domains/api.ts b/hiddifypanel/admin_v2/src/features/domains/api.ts index 70fb1ff7f..9dbde5556 100644 --- a/hiddifypanel/admin_v2/src/features/domains/api.ts +++ b/hiddifypanel/admin_v2/src/features/domains/api.ts @@ -24,7 +24,16 @@ export interface DomainTls { /** The domain needs a real certificate (valid TLS mode). */ needs_valid: boolean issuer: string + /** The issuing organisation (e.g. Let's Encrypt), read from the certificate; issuer is its short name (E7, YE1). */ + ca: string + issued_at: string | null expires_at: string | null + /** The names the certificate covers. */ + names: string[] + /** e.g. "ECDSA P-256", "RSA 2048" */ + key: string + fingerprint: string + auto_renew: boolean updated_at: string | null error: string /** The last certificate request from this page (kept for 10 minutes). */ diff --git a/hiddifypanel/admin_v2/src/features/domains/views/DomainsView.vue b/hiddifypanel/admin_v2/src/features/domains/views/DomainsView.vue index 1d2306065..991521162 100644 --- a/hiddifypanel/admin_v2/src/features/domains/views/DomainsView.vue +++ b/hiddifypanel/admin_v2/src/features/domains/views/DomainsView.vue @@ -106,14 +106,14 @@ v-if="d.tls.needs_valid" class="dm-badge" :class="`dm-tls--${certState(d)}`" - v-tooltip.top="tlsTooltip(d)" + v-tooltip.top="tlsTip(d)" > {{ certLabel(d) }} - + {{ t(`domains.tlsMode.${d.fake_mode}`) }} ECH @@ -395,12 +395,64 @@ function certLabel(d: DomainRow): string { function expiresIn(d: DomainRow): number | null { return daysUntil(d.tls.expires_at) } -function tlsTooltip(d: DomainRow): string { - const parts = [t(`domains.tls.${d.tls.status}Hint`)] - if (d.tls.issuer) parts.push(`${t('domains.tls.issuer')}: ${d.tls.issuer}`) - if (d.tls.expires_at) parts.push(`${t('domains.tls.expires')}: ${longDate(d.tls.expires_at, locale.value)} (${t('domains.tls.expiresIn', { n: expiresIn(d) })})`) - if (d.tls.error) parts.push(d.tls.error) - return parts.join('\n') +const esc = (text: string) => text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`) +const TIP_TONE: Record = { + valid: '#16a34a', + renew_failed: '#d97706', + self_signed: '#d97706', + running: 'var(--p-primary-color)', + expired: '#dc2626', + invalid: '#dc2626', + failed: '#dc2626', + missing: '#64748b', + reality: '#8b5cf6', + fake: '#f97316', + dns: '#64748b', + proxy: '#0ea5e9', +} +/** A hover card (PrimeVue tooltip with HTML, styled in the unscoped block below): an icon, a title and a line, then rows */ +function tipCard(tone: string, icon: string, title: string, sub: string, body: string) { + const value = `
${esc(title)}
${esc(sub)}
${body}
` + return { value, escape: false, class: 'dm-tip' } +} +const tipRow = (label: string, value: string, raw = false) => `
${esc(label)}
${raw ? value : esc(value)}
` + +/** The certificate badge's card: its state, how much of its life is left, and what the certificate is */ +function tlsTip(d: DomainRow) { + const state = certState(d) + const tls = d.tls + const days = expiresIn(d) + let life = '' + if (tls.issued_at && tls.expires_at) { + const start = Date.parse(tls.issued_at) + const end = Date.parse(tls.expires_at) + const left = Math.max(0, Math.min(1, (end - Date.now()) / Math.max(1, end - start))) + const urgency = days === null ? '' : days < 7 ? ' dm-tip__life--urgent' : days < 21 ? ' dm-tip__life--soon' : '' + life = `
${esc(longDate(tls.issued_at, locale.value))}${esc(days !== null && days >= 0 ? t('domains.tls.expiresIn', { n: days }) : t('domains.tls.expired'))}${esc(longDate(tls.expires_at, locale.value))}
` + } else if (tls.expires_at) { + life = `
${tipRow(t('domains.tls.expires'), `${longDate(tls.expires_at, locale.value)} · ${t('domains.tls.expiresIn', { n: days ?? 0 })}`)}
` + } + const rows: string[] = [] + if (tls.ca || tls.issuer) rows.push(tipRow(t('domains.tip.issuedBy'), [tls.ca, tls.issuer].filter(Boolean).join(' · '))) + if (tls.names?.length) { + const chips = tls.names.slice(0, 4).map((n) => `${esc(n)}`).join('') + (tls.names.length > 4 ? `+${tls.names.length - 4}` : '') + rows.push(tipRow(t('domains.tip.covers'), `${chips}`, true)) + } + if (tls.key) rows.push(tipRow(t('domains.tip.key'), tls.key)) + if (tls.expires_at) rows.push(tipRow(t('domains.tip.autoRenew'), t(tls.auto_renew ? 'domains.tip.on' : 'domains.tip.off'))) + if (tls.fingerprint) rows.push(tipRow(t('domains.tip.fingerprint'), `${esc(tls.fingerprint.slice(0, 23))}…`, true)) + const error = tls.error && state !== 'valid' ? `
${esc(tls.error.length > 160 ? `${tls.error.slice(0, 160)}…` : tls.error)}
` : '' + const hint = state === 'running' ? t('domains.cert.waiting') : state === 'failed' || state === 'renew_failed' ? t('domains.cert.failedHint') : t(`domains.tls.${tls.status}Hint`) + return tipCard(TIP_TONE[state] ?? '#64748b', certIcon(d), certLabel(d), hint, `${life}${rows.length ? `
${rows.join('')}
` : ''}${error}`) +} + +/** A decoy TLS mode's card (Reality, Fake, DNS, a built-in server's fake-TLS name): what it does, no certificate of its own */ +function modeTip(d: DomainRow) { + const key = isFakeProxyMode(d.fake_mode) ? 'proxy' : d.fake_mode + const hint = t(`domains.tlsMode.${d.fake_mode}Hint`) + const rows = [tipRow(t('domains.tip.certificate'), t('domains.tip.noCertNeeded'))] + if (d.domain) rows.push(tipRow(t('domains.tip.sni'), `${esc(d.domain)}`, true)) + return tipCard(TIP_TONE[key] ?? '#64748b', MODE_ICON[d.fake_mode] ?? 'pi pi-eye-slash', t(`domains.tlsMode.${d.fake_mode}`), hint, `
${rows.join('')}
`) } const rowItems = computed(() => { @@ -1188,6 +1240,147 @@ a.dm-row__domain:hover {