mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
A caller without a modem's line picks a speed from 300 to 115200 bit/s (or full) on the profile (B) or with Ctrl-B at any prompt, and it is kept with their account. What the BBS sends goes at that pace, ten bits a character, ANSI art drawn as it was; doors are told the speed and paced too. Keys come in at once, and file transfers go at the line's own speed so their protocols do not time out. Modem callers (and calls a modem server reports a rate for) are never slowed again. [general] line_speeds (may callers pick), line_speed (what they get until they do) and line_speed_ask (asked at each login) are on bbs config's Connections page; the sysop can set a user's speed on their account page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRUrCtqbnHANimX37GK
97 lines
2.5 KiB
Go
97 lines
2.5 KiB
Go
package server
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/D-Modem/bbs/internal/bbs"
|
|
"golang.org/x/crypto/ssh"
|
|
)
|
|
|
|
// TestLineSpeed: an SSH caller picks a line speed on the profile and with
|
|
// Ctrl-B; it is kept, and the next call begins at it.
|
|
func TestLineSpeed(t *testing.T) {
|
|
e, addr, _ := startSSH(t, nil)
|
|
call := func() *dialog {
|
|
c, err := sshDial(t, addr, "alice", ssh.Password("alicepass1"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
d := shell(t, c, "xterm-256color", 100, 40)
|
|
d.expect("Command: ")
|
|
return d
|
|
}
|
|
prefs := func() string {
|
|
u, _ := e.b.Store.UserByName("alice")
|
|
return u.Prefs
|
|
}
|
|
d := call()
|
|
d.send("P")
|
|
d.expect("line speed full")
|
|
d.expect("[B]aud: line speed (or Ctrl-B)")
|
|
d.send("B")
|
|
d.expect("Which? ")
|
|
d.send("a") // 56k
|
|
d.expect("Now at 56000 bit/s.")
|
|
d.expect("line speed 56000 bit/s")
|
|
if p := prefs(); p != "baud=56000" {
|
|
t.Errorf("kept %q", p)
|
|
}
|
|
d.send("Q")
|
|
d.expect("Command: ")
|
|
|
|
d = call()
|
|
d.send("P")
|
|
d.expect("line speed 56000 bit/s")
|
|
d.send("Q")
|
|
d.expect("Command: ")
|
|
d.send("\x02")
|
|
d.expect("Line speed\x1b[0m (now 56k):")
|
|
d.send("0")
|
|
d.expect("Full speed.")
|
|
d.expect("Command: ") // the prompt again
|
|
d.send("P")
|
|
d.expect("line speed full")
|
|
if p := prefs(); p != "baud=off" {
|
|
t.Errorf("kept %q", p)
|
|
}
|
|
}
|
|
|
|
// TestLineSpeedOff: with line_speeds = no, nor the profile's B nor Ctrl-B
|
|
// is there, and a speed kept is not used.
|
|
func TestLineSpeedOff(t *testing.T) {
|
|
e, addr, _ := startSSH(t, func(s *bbs.Settings) { s.LineSpeeds = false })
|
|
u, _ := e.b.Store.UserByName("alice")
|
|
if err := e.b.Store.SetPrefs(u.ID, "baud=300"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
c, err := sshDial(t, addr, "alice", ssh.Password("alicepass1"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
d := shell(t, c, "xterm-256color", 100, 40)
|
|
d.expect("Command: ")
|
|
d.send("\x02")
|
|
d.send("P")
|
|
d.expect("Terminal:")
|
|
d.expect("[Q]uit: ")
|
|
if strings.Contains(string(d.before), "ine speed") {
|
|
t.Errorf("line speeds offered: %q", d.before)
|
|
}
|
|
}
|
|
|
|
// TestLineSpeedModem: a modem caller's line has its speed; none is offered.
|
|
func TestLineSpeedModem(t *testing.T) {
|
|
e := start(t, nil, &Listener{Name: "menu", Kind: "raw", Address: "menu.sock", ANSI: "no",
|
|
Header: true, TrustUser: true, CreateUsers: true})
|
|
d := e.dial("menu.sock")
|
|
d.send("MODEM_USER=erin\nMODEM_AUTH=pam\nMODEM_RATE=26400/31200\n\n")
|
|
d.expect("Command: ")
|
|
d.send("P")
|
|
d.expect("Terminal:")
|
|
d.expect("[Q]uit: ")
|
|
if strings.Contains(string(d.before), "ine speed") {
|
|
t.Errorf("line speeds offered a modem caller: %q", d.before)
|
|
}
|
|
}
|