mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
[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
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
|
|
"github.com/D-Modem/bbs/internal/certs"
|
|
"github.com/D-Modem/bbs/internal/config"
|
|
"github.com/D-Modem/bbs/internal/ymsg"
|
|
)
|
|
|
|
// ymsgSection reads [ymsg]: the Yahoo! Messenger server for the chat.
|
|
func (c *Config) ymsgSection(cf *config.File) error {
|
|
s := cf.Get("ymsg", "")
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
err := func() error {
|
|
y := &ymsg.Settings{Address: s.String("address", ":5050"), HTTPAddress: s.String("http_address", ""),
|
|
HTTPSAddress: s.String("https_address", ""), CertFile: s.String("tls_cert", ""),
|
|
KeyFile: s.String("tls_key", ""), Host: s.String("host", ""), System: s.String("system", "bbs")}
|
|
for _, a := range []struct{ key, v string }{{"address", y.Address}, {"http_address", y.HTTPAddress},
|
|
{"https_address", y.HTTPSAddress}} {
|
|
if a.v == "" {
|
|
continue
|
|
}
|
|
if _, _, err := net.SplitHostPort(a.v); err != nil {
|
|
return fmt.Errorf("%s: %v", a.key, err)
|
|
}
|
|
}
|
|
if y.Address == "" {
|
|
return errors.New("address: where the pager listens (:5050)")
|
|
}
|
|
if y.HTTPSAddress != "" {
|
|
if y.CertFile == "" || y.KeyFile == "" && !certs.IsACME(y.CertFile) {
|
|
return errors.New("https_address needs tls_cert and tls_key (one for login.yahoo.com: not a name a CA will sign for this host)")
|
|
}
|
|
if err := certs.Check(y.CertFile, y.KeyFile, c.acmeNames()); err != nil {
|
|
return fmt.Errorf("tls_cert, tls_key: %v", err)
|
|
}
|
|
}
|
|
if y.Host != "" && strings.ContainsAny(y.Host, ":/ ") && net.ParseIP(y.Host) == nil {
|
|
return errors.New("host: the pager's IP address or host name, without a port")
|
|
}
|
|
if y.System == "" || len(y.System) > 32 || strings.ContainsAny(y.System, "@ ") {
|
|
return errors.New("system: a Yahoo ID of 1 to 32 letters and digits")
|
|
}
|
|
var err error
|
|
if y.MaxClients, err = s.Int("max_clients", 256, 1, 100000); err != nil {
|
|
return err
|
|
}
|
|
if y.MaxPerIP, err = s.Int("max_per_ip", 4, 0, 1000); err != nil {
|
|
return err
|
|
}
|
|
c.YMSG = y
|
|
return nil
|
|
}()
|
|
if err != nil {
|
|
return fmt.Errorf("[ymsg] %w", err)
|
|
}
|
|
return nil
|
|
}
|