Files
uptimesebi/internal/api/export_test.go
T
Sebastian UnterschützandClaude Opus 5.5 5934bd74e8
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 7m28s
ci / test (pull_request) Successful in 12m52s
ci / build (pull_request) Successful in 11m21s
ci / image (pull_request) Successful in 4m38s
feat: verify custom domains by a CNAME unique to the page
A custom domain now needs a single record: a CNAME to
<label>.<status page host>, where the label is derived from the page's
domain token. The wildcard record of the status page host routes it, and
since the target belongs to one page alone it also proves who set it up;
a CNAME to the shared host would not, as any organization could then
claim a domain pointing at the platform. The TXT record stays for domains
whose CNAME cannot be seen, behind a proxy or without a subdomain.

- The domain watch looks for the records of a new domain every minute for
  a quarter of an hour, then every ten minutes for two days, and verifies
  it on its own; "Check now" still works.
- Verified domains are checked daily. When the record is gone the owners
  are told, and a week later the domain is switched off, so a record left
  behind cannot be taken over. Domains verified before keep working
  without checks.
- The editor shows the CNAME record first, the TXT way for proxies and
  apex domains, how the domain was verified and when a missing record will
  switch it off. The API returns cname_record and domain_missing_since.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-25 22:58:54 +01:00

41 lines
1.1 KiB
Go

package api
import (
"context"
"time"
"github.com/google/uuid"
)
// LookupTXT lets tests replace DNS lookups for domain verification.
var LookupTXT = &lookupTXT
// AuditActions exposes the audited routes to tests.
var AuditActions = auditActions
// DocumentedRoutes lists the routes in the OpenAPI table.
func DocumentedRoutes() []string {
out := make([]string, len(endpoints))
for i, e := range endpoints {
out[i] = e.method + " " + e.path
}
return out
}
// OpenAPI builds the OpenAPI document.
func OpenAPI() map[string]any { return buildOpenAPI("https://uptime.example") }
// WatchRegionsOf runs the region watch for the regions given only, so
// tests are not slowed down by the regions other tests left behind.
func (s *Server) WatchRegionsOf(ctx context.Context, now time.Time, ids ...uuid.UUID) error {
return s.watchRegions(ctx, now, ids)
}
// LookupCNAME lets tests replace DNS lookups for domain verification.
var LookupCNAME = &lookupCNAME
// WatchDomainOf runs the domain watch for one page only.
func (s *Server) WatchDomainOf(ctx context.Context, now time.Time, page uuid.UUID) error {
return s.watchDomains(ctx, now, &page)
}