mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
A user registers a room with ChanServ (/msg ChanServ REGISTER #room, or /cs REGISTER in the BBS's chat) and is its founder. Its access list takes Atheme's flags (v V o O t i r R f s A e b F, and the VOP, AOP, SOP and FOUNDER templates): those with O or V are opped or voiced on coming in, by any way in. A registered room's ops give and take ops and voice (MODE +o/-o/+v/-v), put people out (KICK, /kick on the BBS) and set the topic. ChanServ also has DROP, INFO, OP/DEOP/VOICE/DEVOICE, TOPIC, KICK, BAN/UNBAN (b on an entry: kept out), CLEAR #room USERS (everyone out but the one asking), SET (FOUNDER, GUARD, TOPICLOCK, PRIVATE, DESCRIPTION, URL, ENTRYMSG), LIST and WHY. Status, bans and kicks are the room's, in the shared chat code, so they hold for IRC, the text BBS, 3270s, AOL, Yahoo, AIM, MSN and CB alike; front ends that know only the older events get a notice and a leaving. Unregistered rooms are as before: no ops but sysops. Page rooms and rooms a linked network or MRC carries can't be registered. A room unused for chanserv_expire days (90) is dropped; a deleted founder's room passes to the next on its list. PREFIX is now (ov)@+. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTXE7MNm3r3hHAmTG2
71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
|
|
"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"), ChanServ: s.String("chanserv", "ChanServ")}
|
|
if !ircd.ValidNick(i.Service) {
|
|
return errors.New("service: the bot's nick, a letter then letters, digits, - and _")
|
|
}
|
|
if !ircd.ValidNick(i.ChanServ) || strings.EqualFold(i.ChanServ, i.Service) {
|
|
return errors.New("chanserv: the rooms' bot's nick, a letter then letters, digits, - and _ (not service's)")
|
|
}
|
|
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.ChanServExpire, err = s.Int("chanserv_expire", 90, 0, 100000); 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
|
|
}
|