Files
bbs/internal/server/ircconfig.go
T
Claude 12570cb4d7 Add an ACME client: certificates for every TLS server, renewed
[acme] gets certificates from Let's Encrypt, ZeroSSL or any ACME CA and
renews them before they run out, in the manner of acme.sh, built on lego
(MIT). [acme NAME] adds more. HTTP-01 (its own port 80 listener or the
BBS's web server there), TLS-ALPN-01 (any TLS server of the BBS on 443)
and DNS-01 (15 providers built in, exec:PROGRAM, or acme.sh's own dnsapi
scripts through acmesh:dns_xx) are supported; renewal follows renew_days
and the CA's ARI; a hook runs after each new certificate.

internal/certs is where every TLS server now gets its certificate: a
file pair read again when it changes, or the ACME client's (cert_file =
acme or acme:NAME, and by default when a TLS server has no files and
[acme] is set). Gemini keeps its pinned certificate and Yahoo its
login.yahoo.com one unless told.

bbs acme list / renew, bbs check lists them, a Certificates page in the
configurator, the sample config, Configuration Reference and a new
Certificates wiki page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSjWGPJDHVw7cyWKvE
2026-11-09 06:01:07 +00:00

64 lines
1.8 KiB
Go

package server
import (
"errors"
"fmt"
"net"
"github.com/D-Modem/bbs/internal/config"
"github.com/D-Modem/bbs/internal/ircd"
)
// ircSection reads [irc]: the IRC server for the chat rooms.
func (c *Config) ircSection(cf *config.File) error {
s := cf.Get("irc", "")
if s == nil {
return nil
}
err := func() error {
i := &ircd.Settings{Address: s.String("address", ":6667"), TLSAddress: s.String("tls_address", ""),
CertFile: s.String("tls_cert", ""), KeyFile: s.String("tls_key", ""),
ServerName: s.String("server_name", ""), Network: s.String("network", ""),
Service: s.String("service", "BBSServ")}
if !ircd.ValidNick(i.Service) {
return errors.New("service: the bot's nick, a letter then letters, digits, - and _")
}
if i.Address == "none" { // TLS only
i.Address = ""
}
for _, a := range []struct{ key, v string }{{"address", i.Address}, {"tls_address", i.TLSAddress}} {
if a.v == "" {
continue
}
if _, _, err := net.SplitHostPort(a.v); err != nil {
return fmt.Errorf("%s: %v", a.key, err)
}
}
if i.Address == "" && i.TLSAddress == "" {
return errors.New("address or tls_address: somewhere to listen")
}
if i.TLSAddress != "" {
var err error
if i.CertFile, i.KeyFile, err = c.tlsFiles(i.CertFile, i.KeyFile); err != nil {
return fmt.Errorf("tls_address: tls_cert, tls_key: %v", err)
}
}
var err error
if i.MaxClients, err = s.Int("max_clients", 64, 1, 10000); err != nil {
return err
}
if i.MaxPerIP, err = s.Int("max_per_ip", 4, 0, 1000); err != nil {
return err
}
if i.Address != "" && i.TLSAddress == "" {
c.Warnings = append(c.Warnings, "[irc] passwords go in the clear: give it a tls_address too")
}
c.IRC = i
return nil
}()
if err != nil {
return fmt.Errorf("[irc] %w", err)
}
return nil
}