Files
bbs/internal/server/infoconfig.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

65 lines
1.9 KiB
Go

package server
import (
"fmt"
"net"
"os"
"strconv"
"github.com/D-Modem/bbs/internal/config"
"github.com/D-Modem/bbs/internal/finger"
"github.com/D-Modem/bbs/internal/gopher"
)
// infoSections reads [finger] and [gopher].
func (c *Config) infoSections(cf *config.File) error {
var err error
if s := cf.Get("finger", ""); s != nil {
f := &finger.Settings{Address: s.String("address", ":79")}
if _, _, err := net.SplitHostPort(f.Address); err != nil {
return fmt.Errorf("[finger] address: %v", err)
}
if f.Online, err = s.Bool("online", true); err != nil {
return fmt.Errorf("[finger] %w", err)
}
if f.Users, err = s.Bool("users", true); err != nil {
return fmt.Errorf("[finger] %w", err)
}
if f.MaxClients, err = s.Int("max_clients", 16, 1, 1000); err != nil {
return fmt.Errorf("[finger] %w", err)
}
if f.MaxPerIP, err = s.Int("max_per_ip", 4, 0, 1000); err != nil {
return fmt.Errorf("[finger] %w", err)
}
c.Finger = f
}
if s := cf.Get("gopher", ""); s != nil {
g := &gopher.Settings{Address: s.String("address", ":70")}
_, port, err := net.SplitHostPort(g.Address)
if err != nil {
return fmt.Errorf("[gopher] address: %v", err)
}
host, _ := os.Hostname()
g.Host = s.String("hostname", host)
p, _ := strconv.Atoi(port)
if g.Port, err = s.Int("port", p, 1, 65535); err != nil {
return fmt.Errorf("[gopher] %w", err)
}
g.Areas = s.String("areas", "")
if g.Files, err = s.Bool("files", false); err != nil {
return fmt.Errorf("[gopher] %w", err)
}
if g.MaxClients, err = s.Int("max_clients", 32, 1, 1000); err != nil {
return fmt.Errorf("[gopher] %w", err)
}
if g.MaxPerIP, err = s.Int("max_per_ip", 8, 0, 1000); err != nil {
return fmt.Errorf("[gopher] %w", err)
}
if g.Areas != "" || g.Files {
c.Warnings = append(c.Warnings, "[gopher] shows message or file areas to anyone, without a login")
}
c.Gopher = g
}
return nil
}