Comment and test cleanups

- Comments that named something else now name their own function:
  ircd member, imageboard srcPath and linker, forum when, redirect and
  errNoArea, textui sheetDraw.first; a stray comment in rest.go gone.
- confui: changeLines uses diffLines instead of repeating it.
- nntp: accept_from names are looked up when the configuration loads
  (start and reload), now said in the code and the wiki.
- Tests: tnClient.read grows its buffer for a command split at its end
  (a full buffer read nothing for ever); freeAddr folded into freeTCP;
  zipOf is a helper.
- go3270-sec 6c7224e: its comment fixes and gfxtest tidying.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
This commit is contained in:
Claude committed 2026-10-18 22:40:48 +00:00
1 parent 8b8226fcf7
commit 6abf4cf347
16 files changed
+24 -34

No files matched your search

+3 -1
View File
@@ -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
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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=
-1
View File
@@ -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
+1 -8
View File
@@ -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))
+1
View File
@@ -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"} {
+1 -1
View File
@@ -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"
+2 -2
View File
@@ -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.
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
+2 -1
View File
@@ -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 {
+2 -1
View File
@@ -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
+2
View File
@@ -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)
+1 -13
View File
@@ -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()
}
+3
View File
@@ -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)
+1 -1
View File
@@ -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.