diff --git a/docs/wiki/Newsgroups-and-NNTP.md b/docs/wiki/Newsgroups-and-NNTP.md index 5d96c19..c612618 100644 --- a/docs/wiki/Newsgroups-and-NNTP.md +++ b/docs/wiki/Newsgroups-and-NNTP.md @@ -59,7 +59,9 @@ anything else a caller writes. The first time only records where to start: the history is not dumped on a new peer. - the peer may *feed* us by `IHAVE` from the addresses in `accept_from`; - nobody else may use `IHAVE`. + nobody else may use `IHAVE`. Names there are looked up when the + configuration is loaded (at the start and each reload), not on each + connection: if a peer's address changes, reload, or list its addresses. An article is taken once (a history of Message-IDs, also of those refused), never if this site is in its Path already (so two peers that both carry a diff --git a/go.mod b/go.mod index 23a88a3..5470998 100644 --- a/go.mod +++ b/go.mod @@ -48,4 +48,4 @@ require ( modernc.org/token v1.1.0 // indirect ) -replace github.com/racingmars/go3270 => github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223431-ff000f5c7fb0 +replace github.com/racingmars/go3270 => github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223830-6c7224eb64db diff --git a/go.sum b/go.sum index d32d877..e4901f9 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223431-ff000f5c7fb0 h1:4g45xKps5HyFkqKBwPnPvknE1Dus9JSZakBz/orjfm4= -github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223431-ff000f5c7fb0/go.mod h1:JCzKbsCGdevsd+2iLMRw3Cd+Wk7vmBeGlnfHmeJEcsU= +github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223830-6c7224eb64db h1:CjI39aIVZ6ZXcC3LvYvjznIzXEKfD5R9vs4SeW2SQkU= +github.com/Neo-Desktop/go3270-sec v0.9.14-0.20261018223830-6c7224eb64db/go.mod h1:JCzKbsCGdevsd+2iLMRw3Cd+Wk7vmBeGlnfHmeJEcsU= github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE= github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/api/rest.go b/internal/api/rest.go index ae788fb..e1dfd30 100644 --- a/internal/api/rest.go +++ b/internal/api/rest.go @@ -255,7 +255,6 @@ func (s *Server) agent(r *http.Request) *bbs.Node { return s.B.Agent(whoOf(r).user, "api") } -// lines splits a body into lines for the BBS's editor's checks. // --- login // login: a session token for a name and password, checked and throttled diff --git a/internal/confui/confui.go b/internal/confui/confui.go index 0e11a97..b9c53b8 100644 --- a/internal/confui/confui.go +++ b/internal/confui/confui.go @@ -301,14 +301,7 @@ func (e *Editor) review() error { // changeLines are what saving would do, a line each: the file's changes // (those at a restart marked) and then the database's. func (e *Editor) changeLines() []view.Line { - var lines []view.Line - for _, c := range confedit.Diff(e.orig, e.doc) { - if c.Live() { - lines = append(lines, view.T(view.Good, c.String())) - } else { - lines = append(lines, view.T(view.Warn, c.String()+" (at a restart)")) - } - } + lines := e.diffLines(confedit.Diff(e.orig, e.doc)) if e.db != nil { for _, o := range e.db.ops() { lines = append(lines, view.T(view.Good, o.desc)) diff --git a/internal/files/archive_test.go b/internal/files/archive_test.go index d810fee..56157a4 100644 --- a/internal/files/archive_test.go +++ b/internal/files/archive_test.go @@ -16,6 +16,7 @@ import ( // zipOf is a ZIP of those of FILE_ID.DIZ, doom.exe, sub/FILE_ID.DIZ and // readme.txt given, in that order, dated 1994. func zipOf(t *testing.T, files map[string][]byte) []byte { + t.Helper() var b bytes.Buffer z := zip.NewWriter(&b) for _, n := range []string{"FILE_ID.DIZ", "doom.exe", "sub/FILE_ID.DIZ", "readme.txt"} { diff --git a/internal/forum/format.go b/internal/forum/format.go index 724d384..f96e35b 100644 --- a/internal/forum/format.go +++ b/internal/forum/format.go @@ -58,7 +58,7 @@ var funcs = template.FuncMap{ }, } -// whenTime is a time as boards show it: today, yesterday, or the date. +// when is a time as boards show it: today, yesterday, or the date. func when(t time.Time) string { if t.IsZero() { return "never" diff --git a/internal/forum/forum.go b/internal/forum/forum.go index ef305ec..cadae90 100644 --- a/internal/forum/forum.go +++ b/internal/forum/forum.go @@ -441,10 +441,10 @@ func (q *req) needLogin() bool { return true } -// back sends the user on after a form. +// redirect sends the user on after a form. func (q *req) redirect(to string) { http.Redirect(q.w, q.r, to, http.StatusSeeOther) } -// errNotFound pages +// errNoArea is a forum that is not there, or not open to the user. var errNoArea = errors.New("there is no such forum, or it is not open to you") // setCookie gives the browser its session. diff --git a/internal/imageboard/imageboard.go b/internal/imageboard/imageboard.go index de7fe77..27f685b 100644 --- a/internal/imageboard/imageboard.go +++ b/internal/imageboard/imageboard.go @@ -665,7 +665,7 @@ func (s *Server) file(q *req, b *store.Board, kind, name string) { http.ServeContent(q.w, q.r, "", fi.ModTime(), f) } -// paths are where a board's files are kept. +// srcPath is where a post's file is kept (thumbPath its thumbnail). func (s *Server) srcPath(dir string, tim int64, ext string) string { return filepath.Join(s.conf().Dir, dir, "src", strconv.FormatInt(tim, 10)+ext) } diff --git a/internal/imageboard/markup.go b/internal/imageboard/markup.go index d8ac42d..9bec933 100644 --- a/internal/imageboard/markup.go +++ b/internal/imageboard/markup.go @@ -17,7 +17,7 @@ import ( var tokenPat = regexp.MustCompile(`>>>/([a-z0-9]{1,16})/(\d{1,12})?|>>(\d{1,12})|https?://[^\s<>"'\x60]+|\[/?spoiler\]`) -// Linker finds what a comment's quotes point at. +// linker finds what a comment's quotes point at. type linker interface { // thread is the thread a post of this board is in (ok false: it is // not there) diff --git a/internal/ircd/commands.go b/internal/ircd/commands.go index 7d5d705..9c9ed46 100644 --- a/internal/ircd/commands.go +++ b/internal/ircd/commands.go @@ -198,7 +198,8 @@ func (c *client) part(ch string) { c.send(nil, c.source(), "PART", "#"+name) } -// prefix is a member's name in NAMES and WHO: @ for sysops. +// member is a room member as NAMES and WHO give one: nick, user (how they +// came), host (their node), and op for a sysop (@). func (c *client) member(m bbs.RoomMember) (nick, user, host string, op bool) { nick, user, host = Nick(m.Name), m.Via, fmt.Sprintf("node%d", m.Node) if u, err := c.s.B.Store.UserByName(m.Name); err == nil && u.Sysop { diff --git a/internal/nntp/peer.go b/internal/nntp/peer.go index 745bd06..5a4333d 100644 --- a/internal/nntp/peer.go +++ b/internal/nntp/peer.go @@ -30,7 +30,8 @@ type Peer struct { Pull bool // fetch its new articles Push bool // offer it ours (IHAVE, or POST if it takes no IHAVE) Interval time.Duration - // addresses it connects from: it may IHAVE (and read) + // addresses it connects from: it may IHAVE (and read); names in the + // configuration are looked up when it is loaded AcceptFrom []net.IP // the most articles a run takes or gives, each way MaxPerRun int diff --git a/internal/server/newsconfig.go b/internal/server/newsconfig.go index 713422a..cf34cc6 100644 --- a/internal/server/newsconfig.go +++ b/internal/server/newsconfig.go @@ -134,6 +134,8 @@ func peer(s *config.Section) (*nntp.Peer, error) { if p.Initial, err = s.Int("initial", 100, 0, 100000); err != nil { return nil, err } + // names are looked up here, once: at the start and each reload, so a + // peer whose address changes needs a reload (or its addresses given) for _, h := range strings.Fields(strings.ReplaceAll(s.String("accept_from", ""), ",", " ")) { if ip := net.ParseIP(h); ip != nil { p.AcceptFrom = append(p.AcceptFrom, ip) diff --git a/internal/server/qwk_test.go b/internal/server/qwk_test.go index 761a74e..147b08f 100644 --- a/internal/server/qwk_test.go +++ b/internal/server/qwk_test.go @@ -2,7 +2,6 @@ package server import ( "bytes" - "net" "os" "os/exec" "path/filepath" @@ -92,7 +91,7 @@ func TestQWKByIndFile(t *testing.T) { if _, err := exec.LookPath("s3270"); err != nil { t.Skip("no s3270") } - addr := freeAddr(t) + addr := freeTCP(t) e := start(t, nil, &Listener{Name: "telnet", Kind: "telnet", Address: addr, TN3270: true}) rep := qwkSetup(t, e) dir := t.TempDir() @@ -117,14 +116,3 @@ func TestQWKByIndFile(t *testing.T) { t.Errorf("no word of the replies:\n%s", out) } } - -// freeAddr is a local TCP address free to listen on. -func freeAddr(t *testing.T) string { - t.Helper() - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - return ln.Addr().String() -} diff --git a/internal/server/server_test.go b/internal/server/server_test.go index b1d6181..42e6137 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -386,6 +386,9 @@ func (tc *tnClient) read(t *testing.T) { return 1 } for i+need() >= len(b) { + if n == len(buf) { + buf = append(buf, make([]byte, 4096)...) // room for the rest + } m, err := tc.c.Read(buf[n:]) if err != nil { t.Fatal(err) diff --git a/internal/textui/sheet.go b/internal/textui/sheet.go index 1c7b772..47dfb5b 100644 --- a/internal/textui/sheet.go +++ b/internal/textui/sheet.go @@ -110,7 +110,7 @@ type sheetDraw struct { top int // the first entry shown } -// rows: where the entries' window begins, and how many rows it has +// first is the row where the entries' window begins, below the notes. func (d *sheetDraw) first() int { return 3 + min(len(d.sh.Note), 3) } // height is how many rows the entries' window has, at least 3.