525 Commits

Author SHA1 Message Date
0xJacky 6053fa0d54 feat(cert): add self-signed certificate error codes and renewal notification
- Add self-signed certificate error codes (50032-50036)
- Add "Renew Certificate Success" notification
- Add WebSocket reverse-proxy fix self-check messages
- Refine zh translations and regenerate bundled artifacts

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 18:07:22 +08:00
0xJacky ecb32848a5 fix: count private network interfaces 2026-06-04 16:22:08 +08:00
0xJacky e43f137c92 fix: keep config search index in memory 2026-06-04 16:09:53 +08:00
0xJacky 071582ec46 fix: reduce log indexing write amplification 2026-06-04 15:20:28 +08:00
Hintay f6992d8789 fix(docker): upgrade persisted bundled nginx-ui.conf safely (#1696)
* test(self_check): add fixed-default bundled nginx-ui.conf fixture

* test(self_check): add unfixed-default bundled nginx-ui.conf fixture

* test(self_check): add customized and partial-fix fixtures

* feat(self_check): add error codes for bundled nginx-ui.conf upgrade

* feat(self_check): add CheckBundledNginxUIConf

* feat(self_check): add idempotent applyBundledConfPatch

* feat(self_check): add transactional patch-on-disk with backup restore

* feat(self_check): wire FixBundledNginxUIConf with verify+reload

* feat(self_check): register bundled nginx-ui.conf WS-fix task

* test(docker): add init-config bats fixtures

* feat(docker): hash-whitelist sync for bundled nginx-ui.conf

* feat(docker): seed nginx-ui.conf known-hashes list

* chore(docker): add maintainer script for nginx-ui.conf hash list

* ci(docker): add bats + hash-consistency workflow for init-config.sh

* feat(docker): ship nginx-ui.conf known-hashes inside the image

* feat(self-check): banner button shows Fix when all failures are fixable

* docs: add docker websocket fix guide (en)

* docs: add docker websocket fix guide (zh_CN, zh_TW)

* docs: link docker-websocket-fix page in all locale sidebars

* docs(readme): link docker websocket fix guide

* docs(readme): link docker websocket fix guide (translations)

* fix(self_check): WS-fix check independent of NGINX_UI_IGNORE_DOCKER_SOCKET

* fix(docker): respect bundled nginx host mode

Keep bundled nginx-ui.conf self-checks aligned with Docker host mode and prevent config sync failures from blocking startup.

* fix(docker): tighten bundled conf review fixes

Co-authored-by: Jacky <me@jackyu.cn>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Jacky <me@jackyu.cn>
2026-05-24 09:48:19 +08:00
Jacky 69cfa82b1d feat: self-signed certificate support (#1655) (#1688)
* feat(cert): add self-signed certificate type and config to model

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): generate self-signed leaf certificates

Add GenerateSelfSigned / SelfSignedOptions plus five new error codes
(50032-50036) and a full TDD test suite covering valid cert output,
multiple key types, empty-SAN rejection, and invalid-IP rejection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): regenerate self-signed certificates with key reuse

Add RegenerateSelfSigned, SelfSignedOptionsFromModel, deriveSelfSignedCommonName,
loadSelfSignedKey, and parsePrivateKeyPEM to support re-issuing self-signed
certificates for the auto-renewal job, reusing the on-disk private key when possible.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): add self-signed certificate renewal worker

Add auto-renewal worker for self-signed certificates that mirrors the
ACME renewal logic, using a dedicated shouldRenewSelfSignedCert threshold
function verified with TDD.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cron): schedule self-signed certificate renewal

Register setupSelfSignedCertRenewalJob as a periodic cron job (every
30 minutes) in InitCronJobs, mirroring the existing setupAutoCertJob
pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(api): add self-signed certificate generation endpoints

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): add self-signed certificate frontend API

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): add shared self-signed certificate fields component

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): add self-signed certificate generation modal and list entry

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): support self-signed certificates in the editor

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(site): generate self-signed certificates from the site editor

Extract hasTLSListen/ensureDirective/ensureTLSDirectives into a shared
useTLSDirectives composable, refactor ObtainCert.vue to use it, and add
SelfSignedCert.vue to the site cert tab so users can generate and apply
a self-signed certificate directly from the site editor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cert): validate self-signed key type and name IP-only renewals

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(cert): apply code-review cleanup

- reuse certcrypto.ParsePEMPrivateKey instead of a hand-rolled PEM
  private-key parser
- stop exporting the unused ensureDirective from useTLSDirectives
- use the AutoCertState enum instead of integer literals in certColumns
- allocate the renewal Logger only when renewal is attempted, avoiding a
  per-tick goroutine and empty-log database write for non-due certificates

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cert): address PR #1688 review feedback

- clean up the partial certificate directory when the initial write
  fails, not just the database row
- log a warning when the existing self-signed private key cannot be
  reused so operators notice the public-key fingerprint has changed
- defensively copy the model's Domains and IPAddresses slices in
  SelfSignedOptionsFromModel
- require an explicit "Save now" confirmation after generating from the
  site editor, and write the directives into the editor first so the
  user can review the diff before saving

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cert): harden self-signed certificate lifecycle

Reuse private keys on manual self-signed edits, make certificate writes safer, clean managed self-signed files on delete, and guard renewal against missing config.

* fix(cert): harden self-signed frontend handling

Avoid undefined certificate redirects, rely on payload defaults for self-signed fields, and parse TLS listen directives precisely.

* fix(site): satisfy strict listen regex lint

Escape the IPv6 listen closing bracket explicitly so the strict regexp lint rule accepts TLS listen parsing.

* fix(cert): harden self-signed key handling

Co-authored-by: Jacky <me@jackyu.cn>

* docs(cert): design merging self-signed entry into issue dialog

Spec for collapsing the Certificate list header from three actions to
two by adding a Self-signed option inside the existing Issue Certificate
dialog.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(cert): plan merging self-signed into issue dialog

Step-by-step plan that turns the spec into two scoped commits:
extend DNSIssueCertificate with a self-signed type, then drop the
standalone header button from the certificate list view.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): add self-signed option in issue certificate dialog

Extend the Issue Certificate dialog's Certificate Type select with a
"Self-signed" option that swaps the form body to SelfSignedCertFields
and routes submission through cert.generate_self_signed(). ACME paths
(Wildcard / Custom Domains) are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(cert): drop standalone self-signed button from list header

Certificate creation is now consolidated under the Issue Certificate
dialog (which exposes Self-signed as a Certificate Type option), so
the duplicate header entry, its ref, handler, and modal mount are
removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(cert): design self-signed UX enhancements

Adds a reusable StringListInput, renewal-policy hint in the self-signed
form, and a required Name field (frontend + backend). Builds on the
prior merge spec.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(cert): plan self-signed UX enhancements

Six-task plan: extract StringListInput, require Name backend + test,
refactor SelfSignedCertFields with renewal hint, hide duplicate alert
in editor, seed/filter payloads with Name validation, and adopt
StringListInput in the ACME Custom Domains branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(ui): add StringListInput component

Reusable multi-row text input with Add/Remove buttons. Used in the
upcoming refactor of Custom Domains and self-signed Domains / IP
Addresses editors so all three share a single editor pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(ui): simplify StringListInput model write and add a11y label

Replace the captured-index update closure with v-model:value on
items[index] so input events are guaranteed to write to the array
slot currently bound to the DOM input. Add an aria-label suffix
on the Remove button so screen readers can distinguish rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): require Name when generating self-signed certificates

Adds binding:"required" to SelfSignedCertRequest.Name so an empty name
is rejected at the request boundary, and covers the contract with a
new API-level test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): unify self-signed editor and surface renewal hint

Switch Domains and IP Addresses to the shared StringListInput so all
self-signed field editors match the Custom Domains pattern. Add an
auto-renewal hint (suppressible via hideRenewalNote) and mark Name as
required to match the new backend contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(cert): suppress duplicate renewal alert in cert editor

SelfSignedCertManagement already has its own renewal-status alert;
pass hide-renewal-note to SelfSignedCertFields to avoid showing two
adjacent alerts saying the same thing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cert): seed and filter self-signed payloads, validate Name

StringListInput preserves empty placeholder rows for editing; seed
arrays with [''] in toSelfSignedPayload / emptySelfSignedPayload /
emptyForm so the editor always renders an empty row to type into.

Each submit/save path trims and filters the arrays before sending and
now rejects an empty Name client-side to match the new server contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(cert): make SelfSignedCertPayload.name required

Every factory already seeds name as ''; the optional marker forced
defensive (name ?? '').trim() at three call sites. Align the type
with reality.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(cert): use StringListInput for Custom Domains

Drop the inline multi-row template + add/remove helpers in favour of
the shared StringListInput component, matching the editor used by the
self-signed branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(ui): regenerate components.d.ts for StringListInput

Auto-generated by unplugin-vue-components after the new component
was added under app/src/components/StringListInput/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cert): render key_type for both legacy and canonical forms

The backend's helper.GetKeyType normalizes key_type to its canonical
form (EC256, RSA2048…) on every write — self-signed generation as well
as the ModifyCert BeforeExecuteHook. The frontend PrivateKeyTypeMask
was keyed only by the legacy form (P256, 2048…), so maskRender returned
"/" for every cert that took a write path through normalization.

Two reported symptoms with the same root cause:
- New self-signed cert always shows "/" in the Key Type column
- Editing any ACME cert (issue #1697) flips its column to "/" after save

Add formatPrivateKeyType / normalizePrivateKeyType helpers that map both
forms to the frontend's legacy key. Use them in the list column renderer
and when loading certs into the self-signed and ACME editor forms so the
ASelect highlights the correct option.

Fixes #1697.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* style(cert): cap self-signed fields width at 600px

The fields stretched full-width inside the certificate editor page; cap
the form at 600px to match AutoCertManagement and keep the editing area
readable. Modal consumers were already bounded by their own width, so
the change is invisible there.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: update translations

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Hintay <hintay@me.com>
2026-05-24 09:22:21 +08:00
Hintay 8a787e2485 feat(dns): support IP version selection for DDNS (#1695)
* feat(dns): support IP version selection for DDNS

- Add ip_version setting (ipv4 / ipv6 / ipv4_ipv6 / ipv6_ipv4 /
  both_required) persisted on DDNSConfig and exposed via the API
- Validate target record types against the selected version and reject
  inconsistent combinations on save
- Probe public IPv4 and IPv6 endpoints concurrently so a stalled family
  no longer eats the shared timeout budget
- Atomically create A/AAAA records when adding missing names and roll
  back partial successes on failure
- Surface per-family resolution warnings instead of failing the whole
  tick when at least one family resolves
- Frontend exposes an IP version selector and filters record options to
  the families allowed by the active selection

* fix(dns): preserve DDNS missing record creation

Co-authored-by: Jacky <me@jackyu.cn>

* fix(dns): restore best-effort dual-stack semantics in record creation

Two fixes after reviewing a cursor agent commit that introduced
regressions:

- DDNSManager.vue: revert mode="tags" back to mode="multiple" and
  drop the now-dead findSelectedRecordType helper. The placeholder
  text is also updated to remove the misleading "Type or" prefix
  since multiple-mode does not allow free input.
- createDDNSRecordsForMissingName: revert the unified "create whatever
  family is available" behaviour. best-effort modes (ipv4_ipv6 /
  ipv6_ipv4) again create only the first available family in policy
  order; both_required keeps creating both atomically.

* refactor(dns): remove both_required DDNS mode

The "all-or-nothing" runtime semantic of both_required conflicts with the
user-accessibility goal of the upcoming sibling cleanup logic, and the
mode itself overlaps with dual-stack best-effort once cleanup exists.
Remove the constant, policy case, validation function, runtime
short-circuit, and error code.

* test(dns): drop both_required test coverage

* feat(dns/ui): drop both_required option from DDNS mode select

* feat(dns): persist cleanup flag and family failure timestamps

Add CleanupConflictingRecords (default true), IPv4FailedSince, and
IPv6FailedSince to model.DDNSConfig and the request/response DTOs.
toDDNSResponse seeds CleanupConflictingRecords=true for unconfigured
domains so the frontend form starts in the desired default state.
The new fields are wired through but no behavior changes yet.

* feat(dns): add isDualStackMode helper

* refactor(dns): silently skip records outside policy during save

UI filters records to the active IP version policy, so an explicit
mismatch error only fires for stale form state or direct API misuse.
Silent skip is more graceful and lets the existing empty-targets
check surface the real failure mode (ErrDDNSTargetRequired).

* feat(dns): auto-pair existing sibling records on save (dual-stack, flag on)

* feat(dns): auto-create missing sibling records on save (dual-stack, flag on)

* feat(dns): delete records of unreachable families on save

When dual-stack mode is active and CleanupConflictingRecords is on,
sibling records at managed names whose family is currently unreachable
get deleted from the provider. The handler returns the deleted-record
list so the frontend can surface a confirmation toast.

* test(dns): cover flag-off and single-stack save-time behavior

* feat(dns): track per-family IP detection failure timestamps

* feat(dns): evict targets of persistently failed families

Dual-stack DDNS configs with CleanupConflictingRecords enabled now
delete records of any family whose public IP has been undetectable for
longer than ddnsFamilyFailureGrace (default 1 hour). Single-stack
modes and the flag-off path skip this branch entirely.

* test(dns): cover runtime no-eviction and delete-failure retry paths

* feat(dns/ui): add cleanup conflicting records toggle (dual-stack only)

* feat(dns/ui): notify users of unmanaged sibling records in single-stack modes

* feat(dns/ui): toast when conflicting records are removed on save

* style(dns/ui): fix indent-binary-ops lint warning

* fix(dns): refuse save when no public IP detected (dual-stack cleanup mode)

Previously the §6.3 completion phase would happily delete every existing
sibling record of unreachable families even when neither family was
detected, leaving cfg.Targets empty and the domain at NXDOMAIN. Now we
short-circuit with ErrDDNSIPUnavailable before running §6.3, preserving
the user's DNS state until they recover connectivity.

* fix(dns): delete in-target records when family IP becomes unreachable

The §6.3 completion phase short-circuited on containsTargetForName
before checking whether the family's IP was still reachable. That meant
a user-selected A record at "home" survived a save under ipv4_ipv6 +
cleanup-on even when IPv4 stopped resolving, contradicting the
Appendix A "✗ / ✓ / on" row of the design spec.

Move the in-targets check inside the IP-detected branch so the
IP-undetected branch can still delete the stale record and pull it
out of targets. Adds tests covering the cross-family pivot plus the
previously-missing spec §10.2 cases (#4, #7, #11, #12, #13).

* fix(dns): persist cleanup flag and preserve failure timestamps on save

UpdateDDNSConfigWithDetails was constructing the new cfg without
carrying CleanupConflictingRecords from the input and without
preserving IPv4FailedSince / IPv6FailedSince from the existing
config. The former meant runtime eviction never triggered in
production (the cfg was always persisted with the flag at zero
value); the latter meant every save reset the family failure
grace timer to nil, indefinitely delaying eviction.

Both gaps slipped through the test matrix because no test
reloaded the cfg from the database after save. Add round-trip
regression tests for both fields plus the new GetDDNSConfig
default alignment.

Also surface delete-record provider failures via a dedicated
ErrDDNSRecordDeleteFailed code so users can distinguish them
from genuine "record not found" cases.

* fix(dns): use standard RFC3339 time format

Co-authored-by: Jacky <me@jackyu.cn>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Jacky <me@jackyu.cn>
2026-05-23 20:46:00 +08:00
Hintay 013634e8ca feat(cert): preserve config and add retry on issuance failure (#1694)
* feat(cert): add Status, LastError, LastAttemptAt fields

* feat(cert): sweep stale pending certs at startup

* feat(cert): invoke SweepStalePending at cron startup

* feat(cert): skip non-success status in auto-renew worker

* feat(cert): persist draft on issuance entry, status transitions on completion

* feat(cert): expose status, last_error, last_attempt_at on Cert type

* feat(cert): show Pending/Failed status badges in cert list

* feat(cert): add RetryCert component and wire into list actions

* feat(cert): inline Retry button on issuance error in wildcard modal

* chore(cert): minor cleanups after retry-on-failure review

- Remove unused model.FirstOrInit helper (last caller was rewritten in the issuance handler change).
- Normalize cleanup_test setupTestDB DSN to ":memory:" for per-test isolation, matching issue_test.go.
- Reset errored state in DNSIssueCertificate.open() as a defensive guard against stale state on modal reopen.

* refactor(cert): extract IssueCertModal wrapper shared by Renew and Retry

Both RenewCert.vue and RetryCert.vue carried near-identical AModal +
ObtainCertLive scaffolding (modalVisible/modalClosable refs, template ref,
modal props). Lift the shared shell into IssueCertModal.vue and expose a
single start() method returning Promise<CertificateResult>. The trigger
components now own only the parts that actually differ: button styling,
emit name, pre-issuance hook (certStore.save for Renew), and success toast.

* chore(cert): fix small bugs with review

- shortError now truncates by rune count instead of bytes, so non-ASCII
  error messages (e.g. localized ACME / DNS provider errors) cannot be
  split mid-rune. TestShortError gains a CJK case asserting valid UTF-8.
- Cert.last_attempt_at is typed string | null on the frontend to reflect
  that the *time.Time pointer serializes as null for legacy / pre-attempt
  rows.
- Drop redundant ?. on refModal / refObtainCertLive in the three click
  handlers. The refs are bound to components rendered alongside their
  trigger button, so they are guaranteed to be mounted by the time the
  handler fires.

* fix(cert): guard certificate issuance ref before retry

Co-authored-by: Jacky <me@jackyu.cn>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Jacky <me@jackyu.cn>
2026-05-23 20:34:52 +08:00
Hintay 82c637c36b fix: expand TLS includes for maintenance mode (#1692)
* fix: expand TLS includes for maintenance mode

Preserve maintenance-mode TLS handshake behavior by expanding allowed include files into ssl directives instead of copying include directives verbatim.

* fix: harden maintenance include path validation

Validate maintenance include paths before file-system access and add regression coverage for relative path escapes.

* refactor(site): simplify maintenance include expansion and tests
2026-05-23 03:19:40 +09:00
Jacky c4259c15e2 fix(nginx_log): repair advanced search filters and status faceting (#1687)
The advanced log search filters were almost entirely non-functional:

- The status filter issued a text term query against the numeric
  "status" field, so it never matched any document.
- The IP and method filters used the field names "remote_addr" and
  "request_method", which do not exist in the index ("ip" / "method").
- The path, user agent, referer, browser, OS and device filters were
  never wired into the query builder.

Faceting on the numeric "status" field also used a terms facet, which
cannot bucket a numeric field and produced garbage prefix-coded terms.

Changes:
- Correct the IP and method field names in the query builder.
- Match status codes with inclusive numeric range queries.
- Wire in the missing path / user agent / referer (match phrase) and
  browser / OS / device (term) filters.
- Split comma-joined browser/OS/device values in the search handler so
  multi-select works.
- Facet the numeric status field with numeric ranges so the status
  code distribution is accurate.
- Add regression tests covering every filter and the status facet
  against a real Bleve index.

Closes #1669

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 14:23:26 +08:00
Hintay 10b1e9995d fix: harden recovery migration flow 2026-05-21 17:43:25 +09:00
Hintay 10867218d4 feat: migrate legacy recovery codes (#1684) 2026-05-21 16:31:41 +08:00
Jacky aa0bf7324e fix: normalize DNS provider env values (#1682)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-05-20 16:54:34 +08:00
0xJacky 6c86e5a594 chore: prepare v2.3.11 2026-05-17 17:31:06 +08:00
lucaszhu-hue d87e7785ad feat: integrate Atlas Cloud provider (#1674) 2026-05-15 23:47:54 +08:00
0xJacky 6859e18d4b fix(cert): migrate ACME client to lego v5 2026-05-13 08:38:20 +08:00
0xJacky 3f04b3e776 fix(cert): normalize legacy key types 2026-05-12 14:52:25 +00:00
Jacky ba2bbe3ac2 fix: resolve concurrent map iteration and map write crash in sitecheck (#1661)
Fixed fatal error 'concurrent map iteration and map write' that caused
nginx-ui nodes to crash and become unresponsive.

The issue occurred when the sitecheck CollectSites() method iterated over
site.IndexedSites while the cache scanner's scanForSite() was concurrently
modifying the same map. This race condition caused sporadic crashes.

Solution:
- Added GetAllIndexedSites() function in internal/site/index.go that safely
  returns a snapshot copy of the IndexedSites map while holding the read lock
- Modified CollectSites() in internal/sitecheck/checker.go to use this
  thread-safe function instead of directly accessing the global map

Fixes #1673

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-05-06 11:28:57 +08:00
0xJacky 0662353420 chore: prepare v2.3.10 2026-04-28 12:36:18 +08:00
0xJacky 0301578295 fix(notification): render external notification placeholders 2026-04-28 09:05:52 +08:00
0xJacky 30908f3c28 chore: prepare v2.3.9 2026-04-27 12:22:46 +08:00
0xJacky fd61e8ea6f fix(config): restrict executable nginx directives 2026-04-27 11:32:04 +08:00
Adamthereal 61185c26f4 test(middleware): add CSWSH hardening cases for CheckWebSocketOrigin (#1647)
Locks in the v2.3.5 origin-validation fix for CVE-2026-34403 / GHSA-78mf-482w-62qj
with named regression cases for every bypass class documented in the advisory:
subdomain confusion, suffix confusion, scheme downgrade, port mismatch, default-
port normalization, ws/wss scheme equivalence, case-insensitive host, IPv6 literal,
RFC 7239 Forwarded parsing, multi-valued X-Forwarded-Host, scheme-only / malformed
origin rejection, node_secret query fallback, empty-secret regression, trailing-
slash tolerance on configured trusted origins.

17 table-driven subtests in a new file; zero production code changes; no new
dependencies.

Co-authored-by: Panguard AI <support@panguard.ai>
2026-04-22 09:33:50 +08:00
0xJacky 3e411d38dd Harden config write paths 2026-04-21 22:40:50 +08:00
0xJacky 7864e378f5 chore: prepare v2.3.8 2026-04-21 15:15:12 +08:00
0xJacky d25c9975d6 fix(analytic): avoid websocket keepalive race 2026-04-20 23:50:45 +08:00
0xJacky 57b6f982ec fix: preserve forwarded host for docker websocket checks 2026-04-20 23:39:22 +08:00
0xJacky 899c9f1995 fix(cert): throttle auto-renew retries and expose renewal errors 2026-04-20 23:19:50 +08:00
0xJacky 25dea9f620 fix(setup): harden first-run installation flow 2026-04-18 23:47:45 +08:00
0xJacky a67285b713 chore: prepare v2.3.7 2026-04-18 11:04:41 +00:00
0xJacky 7ed73f621a feat(analytic): implement WebSocket keepalive mechanism 2026-04-18 11:02:52 +00:00
0xJacky 535c8efb38 fix(sitecheck): bound outbound connections and add global controls (#1608)
The site checker created a fresh http.Transport per request and per
EnhancedSiteChecker, with Go's default Happy-Eyeballs dialer. When
server_name entries resolved to ingress services returning many A
records (ngrok, AWS ALB, Cloudflare), each sweep opened enough flows
to exhaust conntrack tables on consumer routers (UniFi).

Introduce a package-level shared http.Transport with MaxConnsPerHost=2,
MaxIdleConnsPerHost=2 and FallbackDelay=-1 (disables IPv6 dial races),
plumb it through SiteChecker and EnhancedSiteChecker, and only build a
custom client when the per-site HealthCheckConfig truly diverges on
TLS. Reuse the response body fetched by the health check for favicon
extraction so each site is hit at most once per sweep, and dedupe sites
sharing the same host:port before fan-out.

Add a [site_check] settings section (Enabled, Concurrency, Interval-
Seconds) so operators can disable the checker entirely or tune the
sweep cadence; clamp Concurrency to [1, 20] and IntervalSeconds to
>=30. Document the new section in en, zh_CN and zh_TW guides and add
sidebar entries.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 16:06:06 +08:00
0xJacky c38e0a28b8 fix(sites): honor configured healthcheck protocol (#1628)
The site healthcheck built its request URL from the indexed site URL
(e.g. http://example.com) and never rewrote the scheme to match the
user-configured HealthCheckConfig.Protocol. As a result, sites
configured for HTTPS were probed over HTTP and always shown as
unreachable. TestHealthCheck compounded the issue by using
siteConfig.Scheme (default "http") instead of req.Config.Protocol.

Introduce rewriteCheckURLScheme which aligns only the URL scheme with
the configured protocol while preserving path, query, and port, and
call it from CheckSiteWithConfig. TestHealthCheck now passes the stored
site URL and relies on the same rewrite, so the "Test" button exercises
the same code path as the scheduled checker.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 16:03:23 +08:00
0xJacky 329e8589e9 fix(cert): restore WebSocket connection for certificate issuance (#1630)
`ObtainCert.job()` called `issueCert()` synchronously after `step.value++`,
before Vue mounted `<ObtainCertLive>`, so `refObtainCertLive.value` was
null and the optional-chain call silently no-oped — no log entry, no
WebSocket connection, progress stuck at 0%. Add an `await nextTick()`
so the live component is mounted before its method is invoked.

Also harden the long-token WebSocket fallback: switch the frontend to
URL-safe base64 (avoids `+` being decoded as a space in query strings)
and accept both URL-safe and standard base64 in `getTokenWS` for
backward compatibility.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 14:54:29 +08:00
the fire inside me 89c1fdfb44 fix upstream (#1637) 2026-04-15 23:26:19 +08:00
0xJacky 863f36179c chore: prepare v2.3.6 2026-04-04 15:44:07 +00:00
0xJacky 0b0f854f9b feat(backup): enhance backup and restore functionality with crypto secret handling
- Added tests to verify backup and restore processes when the crypto secret changes, ensuring hash verification passes.
- Updated `writeManifestFiles` and `verifyBackupManifest` functions to accept an AES key for improved security.
- Implemented fallback mechanism for verifying manifest signatures using both AES-derived and legacy signing keys.
- Enhanced the overall robustness of the backup and restore system to handle legacy signatures and different crypto secrets.
2026-04-04 14:26:34 +00:00
Jacky d454a2a9d2 fix(mcp): prevent panic on nil interface conversion for tool arguments (#1622)
* fix(mcp): prevent panic on nil interface conversion for tool arguments

Add safe argument extraction helper functions in internal/mcp/args.go
that handle nil values gracefully instead of panicking on direct type
assertions.

This fixes the issue where MCP config tools panic with:
'interface conversion: interface {} is nil, not string'
when called via Claude Desktop with protocol version 2025-11-25.

Affected tools:
- nginx_config_list
- nginx_config_get
- nginx_config_add
- nginx_config_modify
- nginx_config_rename
- nginx_config_mkdir
- nginx_config_history
- nginx_config_enable

Fixes #36ec

Co-authored-by: Jacky <me@jackyu.cn>

* Add required argument validation to MCP config handlers to prevent data loss

The safe argument extraction helpers (mcp.GetString, etc.) return zero values
for nil/missing arguments, which could cause silent data loss. This adds
explicit validation for required arguments in:

- config_modify: validate relative_path and content
- config_add: validate name and content
- config_rename: validate orig_name and new_name
- config_mkdir: validate folder_name

This follows the same pattern already used in handleNginxConfigEnable.

* Add required argument validation to config_get and config_history handlers

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-04-04 10:51:50 +08:00
0xJacky 9f1b9bbbba refactor(ws): implement SafeWebSocketWriter for serialized access
- Introduced SafeWebSocketWriter to ensure thread-safe writes to WebSocket connections.
- Updated WebSocket handling in certificate issuance, revocation, Nginx log tailing, and system upgrades to use the new writer.
- Enhanced WebSocket client management in the site navigation module for improved message handling and connection stability.
2026-04-04 02:01:20 +00:00
0xJacky d895c4a336 enhance(ws): improve session security 2026-04-04 09:48:18 +08:00
0xJacky 7d9887bfe8 fix: enhance WebSocket origin validation for trusted node requests 2026-04-03 11:31:41 +08:00
0xJacky fb37c94276 feat: implement short token endpoint for WebSocket authentication
- Added `InitTokenRouter` to define the `/token/short` endpoint for issuing short tokens.
- Created `IssueShortToken` function to handle short token generation and response.
- Updated WebSocket middleware to require short token for authentication, preventing CSWSH attacks.
- Modified user store and login handling to integrate short token functionality.
- Enhanced documentation to reflect changes in WebSocket security requirements.
2026-04-02 00:06:04 +08:00
0xJacky 926b3248b3 feat: enhance service initialization logic with mutex handling and return types 2026-03-16 13:59:45 +00:00
0xJacky 95ab34bbe1 feat: implement migration to encrypt sensitive JSON fields in database models 2026-03-16 11:34:10 +08:00
0xJacky 9e41ecf9df feat: add support for root block configuration in NgxConfig and implement parsing logic 2026-03-16 03:15:27 +00:00
0xJacky af6d3b9ae4 chore: prepare v2.3.5 2026-03-15 16:17:04 +00:00
0xJacky f89916e0fb feat: add ResolveConfPathInDirPreserveLeaf function for symlink handling in configuration paths 2026-03-16 00:03:32 +08:00
0xJacky 20412b5b54 refactor: configuration path resolution for sites and streams 2026-03-15 22:20:29 +08:00
0xJacky b06cce311a fix: correct recovery code verification logic in OTP handling 2026-03-15 19:18:03 +08:00
0xJacky bc8df5beda feat: add DELETE endpoint for DDNS configuration and implement deletion logic 2026-03-15 02:44:48 +00:00