mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
As a hub: an account flagged qwk_node (bbs user qwknode NAME, or the API's qwk_node) is another BBS's. What its REPs bring is posted under its writers' names, with its access checked, and its packets leave out what came from it. As a node: [qwknet NAME] calls the hub by FTP (FTPS explicit or implicit) every so often, or on bbs qwknet call and POST /api/v1/admin/qwknet/call. It puts a REP of what was written here in the network's areas since the last call (nothing from before joining, nothing that came by a network or peer), then takes the hub's packet and posts it in the areas of its conferences (CONFERENCE = AREA). Messages are known by conference and number (qwk_msgs), so nothing comes twice and answers keep their threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestInfoConfig(t *testing.T) {
|
|
load := func(body string) (*Config, error) {
|
|
p := filepath.Join(t.TempDir(), "bbs.conf")
|
|
os.WriteFile(p, []byte("[listen telnet]\ntype = telnet\naddress = :2300\n"+body), 0600)
|
|
return Load(p)
|
|
}
|
|
c, err := load(`
|
|
[general]
|
|
page_command = /usr/local/bin/notify 'BBS page' {user} {reason}
|
|
[finger]
|
|
users = no
|
|
[gopher]
|
|
address = :7070
|
|
hostname = bbs.example.org
|
|
areas = general,announce*
|
|
files = yes
|
|
`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if strings.Join(c.Settings.PageCommand, "|") != "/usr/local/bin/notify|BBS page|{user}|{reason}" {
|
|
t.Errorf("page command %q", c.Settings.PageCommand)
|
|
}
|
|
if c.Finger.Address != ":79" || !c.Finger.Online || c.Finger.Users {
|
|
t.Errorf("finger %+v", c.Finger)
|
|
}
|
|
if g := c.Gopher; g.Host != "bbs.example.org" || g.Port != 7070 || g.Areas != "general,announce*" || !g.Files {
|
|
t.Errorf("gopher %+v", g)
|
|
}
|
|
if !strings.Contains(strings.Join(c.Warnings, "\n"), "[gopher] shows message or file areas to anyone") {
|
|
t.Errorf("no warning: %v", c.Warnings)
|
|
}
|
|
c, err = load("[gopher]\n")
|
|
if err != nil || c.Gopher.Port != 70 || c.Gopher.Areas != "" || c.Gopher.Files {
|
|
t.Errorf("defaults %+v %v", c.Gopher, err)
|
|
}
|
|
for body, want := range map[string]string{
|
|
"[finger]\naddress = 79\n": "[finger] address",
|
|
"[gopher]\nport = 0\n": "[gopher]",
|
|
"[general]\npage_command = 'x\n": "page_command",
|
|
"[general]\nqwk_id = too-long-id\n": "qwk_id",
|
|
} {
|
|
if _, err := load(body); err == nil || !strings.Contains(err.Error(), want) {
|
|
t.Errorf("%q: %v", body, err)
|
|
}
|
|
}
|
|
}
|