mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
tls_cert = ca ([msn], [ymsg], [oscar]) and cert_file = ca ([gemini]) have the BBS's CA sign the server's certificate for the names its clients ask for: bbs serve makes the CA if there is none, signs at start and looks daily, keeping keys across renewals (Gemini's good as long as the CA, as its clients pin). RSA 2048 throughout; bbs ca init -sha1 for Windows before XP SP3. bbs ca issue signs a certificate for a TLS proxy; bbs ca package (and serve, into ca/install-ca.zip) writes what puts the CA on callers' machines: the .cer, an .inf and .reg writing the machine's trusted roots (Windows 95 on), remove-ca.reg, an install .bat (certutil), a macOS/iOS .mobileconfig, the PEM and a README with the fingerprint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTuaG98f8wiWHbNhPo
73 lines
2.2 KiB
Go
73 lines
2.2 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/oscar"
|
|
)
|
|
|
|
// oscarSection reads [oscar]: the AIM and ICQ server for the chat.
|
|
func (c *Config) oscarSection(cf *config.File) error {
|
|
s := cf.Get("oscar", "")
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
err := func() error {
|
|
o := &oscar.Settings{Address: s.String("address", ":5190"), Host: s.String("host", ""),
|
|
System: s.String("system", "OnlineHost")}
|
|
if _, _, err := net.SplitHostPort(o.Address); err != nil {
|
|
return fmt.Errorf("address: %v", err)
|
|
}
|
|
if o.Host != "" {
|
|
if _, _, err := net.SplitHostPort(o.Host); err != nil {
|
|
return fmt.Errorf("host: %v (host:port, where clients reconnect)", err)
|
|
}
|
|
}
|
|
if o.System == "" || len(o.System) > 16 || strings.ContainsAny(o.System, "@,;") {
|
|
return fmt.Errorf("system: a screen name of 1 to 16 letters, digits and spaces")
|
|
}
|
|
var err error
|
|
if o.MaxClients, err = s.Int("max_clients", 256, 1, 100000); err != nil {
|
|
return err
|
|
}
|
|
// each client opens a few connections (sign-on, BOS, chat rooms)
|
|
if o.MaxPerIP, err = s.Int("max_per_ip", 16, 0, 1000); err != nil {
|
|
return err
|
|
}
|
|
base, err := s.Int("uin_base", 100000, 10000, 2000000000)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o.UINBase = uint32(base)
|
|
o.TLSAddress, o.TLSCert, o.TLSKey = s.String("tls_address", ""), s.String("tls_cert", ""), s.String("tls_key", "")
|
|
o.TLSHost = s.String("tls_host", "")
|
|
if o.TLSAddress != "" {
|
|
if _, _, err := net.SplitHostPort(o.TLSAddress); err != nil {
|
|
return fmt.Errorf("tls_address: %v", err)
|
|
}
|
|
if o.TLSCert == "" || o.TLSKey == "" && !certs.IsACME(o.TLSCert) && !certs.IsCA(o.TLSCert) {
|
|
return errors.New("tls_address needs tls_cert and tls_key")
|
|
}
|
|
if err := certs.Check(o.TLSCert, o.TLSKey, c.acmeNames()); err != nil {
|
|
return fmt.Errorf("tls_cert, tls_key: %v", err)
|
|
}
|
|
}
|
|
if o.TLSHost != "" {
|
|
if h, _, err := net.SplitHostPort(o.TLSHost); err != nil || h == "" {
|
|
return errors.New("tls_host: host:port, where clients come by TLS (its host the certificate's name)")
|
|
}
|
|
}
|
|
c.OSCAR = o
|
|
return nil
|
|
}()
|
|
if err != nil {
|
|
return fmt.Errorf("[oscar] %w", err)
|
|
}
|
|
return nil
|
|
}
|