mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
internal/mrc joins the BBS to MRC as its own connector: one connection to the MRC server ([mrc]: address, TLS) carries all its users. The chat rooms beginning mrc- are MRC's (mrc-lobby is its lobby), so callers on terminals, 3270s, the web and IRC (#mrc-lobby) chat with other BBSes there under their names. The protocol is as Synchronet's mrc-connector.js and mrc-session.js speak it: the SYSTEM~PLATFORM handshake, INFO, IMALIVE and CAPABILITIES; IMALIVE to the server's PING; each user's IAMHERE every minute, NEWROOM:old:new, arrival and leaving notices, LOGOFF; lines as <name> text and actions; Mystic's pipe colors taken out of what comes. !COMMAND in a room goes to the MRC server, its answer to the asker alone; private messages likewise. A dropped line is retried, those here put back. [mrc] require limits who may go in. The chat hub gains a Relay: told of joins, leaves and lines in the rooms it carries, giving them what comes (RelayEvent, RelayTo). On IRC, MRC's users show as nick_Site!mrc@site, and room notices go to the channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net"
|
|
"regexp"
|
|
|
|
"github.com/Neo-Desktop/bbs-sec/internal/bbs"
|
|
"github.com/Neo-Desktop/bbs-sec/internal/config"
|
|
"github.com/Neo-Desktop/bbs-sec/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
|
|
}
|