mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
/msg BBSServ (or /BS) INFO shows the account: level, location, alias, signature, settings, unread mail, keys, tokens, the new scan. SET changes the profile's fields (location, about, alias, signature) and the terminal and menu settings, with the BBS's own checks; PASSWD the password; SCAN the areas of the new scan; KEYS lists, adds (with the password) and deletes SSH keys; TOKENS lists and revokes API tokens. Its framework (command table, parameters, HELP, CTCP) is adapted from ergo's services, under its MIT license. The bot's nick is [irc] service (default BBSServ); it answers WHOIS and ISON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package server
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"errors"
|
|
"fmt"
|
|
"net"
|
|
|
|
"github.com/Neo-Desktop/bbs-sec/internal/config"
|
|
"github.com/Neo-Desktop/bbs-sec/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")}
|
|
if !ircd.ValidNick(i.Service) {
|
|
return errors.New("service: the bot's nick, a letter then letters, digits, - and _")
|
|
}
|
|
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 != "" {
|
|
if i.CertFile == "" || i.KeyFile == "" {
|
|
return errors.New("tls_address needs tls_cert and tls_key")
|
|
}
|
|
if _, err := tls.LoadX509KeyPair(i.CertFile, i.KeyFile); err != nil {
|
|
return fmt.Errorf("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.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
|
|
}
|