mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 09:24:46 +00:00
fix(sites): let the ask endpoint approve the news host
news.bbs.profullstack.com has its own Caddy site block so Caddy can get it a Let's Encrypt cert for NNTPS on :563. But it also falls under the *.bbs.profullstack.com on-demand-TLS block, so Caddy asks agentbbs before issuing, and the ask handler only approved members and mapped custom domains. "news" is neither, so it got a 404 and never got a cert. The news-certs timer then failed forever, and :563 kept serving the self-signed bootstrap cert, which expired on 2026-09-12. The handler now also approves the BBS's own service hosts. For now that is only AGENTBBS_NEWS_HOST. Arbitrary names still 404, so this is still not an open cert relay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7d86e0ad1e
commit
59074ffbfe
2 changed files with 20 additions and 4 deletions
|
|
@ -49,6 +49,11 @@ type Manager struct {
|
|||
usersDir string // <data>/users
|
||||
domDir string // <data>/domains (the symlink farm Caddy serves)
|
||||
baseHost string // AGENTBBS_HOST, e.g. bbs.profullstack.com (for <name>.<host>)
|
||||
// Hosts the BBS itself serves under the *.<baseHost> wildcard, which Caddy
|
||||
// therefore routes through on-demand TLS too (news.bbs.profullstack.com).
|
||||
// They are not members, so without this the ask query 404s them and they
|
||||
// never get a certificate.
|
||||
serviceHosts map[string]struct{}
|
||||
}
|
||||
|
||||
// NewManager prepares the symlink farm under dataDir/domains.
|
||||
|
|
@ -57,11 +62,16 @@ func NewManager(st store.Store, dataDir string) (*Manager, error) {
|
|||
if err := os.MkdirAll(domDir, 0o755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
svc := map[string]struct{}{}
|
||||
if h := Normalize(os.Getenv("AGENTBBS_NEWS_HOST")); h != "" {
|
||||
svc[h] = struct{}{}
|
||||
}
|
||||
return &Manager{
|
||||
st: st,
|
||||
usersDir: filepath.Join(dataDir, "users"),
|
||||
domDir: domDir,
|
||||
baseHost: strings.ToLower(strings.TrimSpace(os.Getenv("AGENTBBS_HOST"))),
|
||||
st: st,
|
||||
usersDir: filepath.Join(dataDir, "users"),
|
||||
domDir: domDir,
|
||||
baseHost: strings.ToLower(strings.TrimSpace(os.Getenv("AGENTBBS_HOST"))),
|
||||
serviceHosts: svc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -159,6 +169,10 @@ func (m *Manager) AskHandler() http.Handler {
|
|||
http.Error(w, "bad domain", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if _, ok := m.serviceHosts[d]; ok {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
// Free user-homepage subdomain: <name>.<baseHost> for any registered
|
||||
// member (e.g. alice.bbs.profullstack.com). Single label only.
|
||||
if m.baseHost != "" && strings.HasSuffix(d, "."+m.baseHost) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue