Files
bbs/internal/server/mrcconfig.go
T
Claude 7399e0fa36 Point repository references at the D-Modem organisation
The repositories moved from Neo-Desktop to the D-Modem GitHub
organisation: D-Modem-RE is now D-Modem/D-Modem, pico-serial is
D-Modem/hardware, modemmenu (PBX-Modem) is D-Modem/menu, bbs-sec is
D-Modem/bbs and go3270-sec is D-Modem/go3270.  Update links, module
paths, submodule URLs and source-location strings to match.  Copyright
notices still name Neo-Desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUwD2JJ5d6fgHmpVTw
2026-10-29 09:02:40 +00:00

48 lines
1.3 KiB
Go

package server
import (
"errors"
"fmt"
"net"
"regexp"
"github.com/D-Modem/bbs/internal/bbs"
"github.com/D-Modem/bbs/internal/config"
"github.com/D-Modem/bbs/internal/mrc"
)
var roomPrefix = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,9}$`)
// mrcSection reads [mrc]: Multi Relay Chat.
func (c *Config) mrcSection(cf *config.File) error {
s := cf.Get("mrc", "")
if s == nil {
return nil
}
err := func() error {
m := &mrc.Settings{Address: s.String("address", mrc.DefaultAddress), Prefix: s.String("prefix", "mrc-"),
SystemName: s.String("system_name", ""), Web: s.String("web", ""), Telnet: s.String("telnet", ""),
SSH: s.String("ssh", ""), Sysop: s.String("sysop", c.Settings.Sysop),
Description: s.String("description", c.Settings.Name), Require: s.String("require", "")}
var err error
if m.TLS, err = s.Bool("tls", false); err != nil {
return err
}
if _, _, err := net.SplitHostPort(m.Address); err != nil {
return fmt.Errorf("address: host:port (%v)", err)
}
if !roomPrefix.MatchString(m.Prefix) {
return errors.New("prefix: what begins MRC's rooms here: up to 10 lower case letters, digits and -")
}
if _, err := bbs.ParseRequire(m.Require); err != nil {
return fmt.Errorf("require: %v", err)
}
c.MRC = m
return nil
}()
if err != nil {
return fmt.Errorf("[mrc] %w", err)
}
return nil
}