mirror of
https://github.com/D-Modem/login.git
synced 2026-11-28 20:38:06 -08:00
All of modemmenu was one package main in the repository's root. It is
now one module with the program and the pieces it is made of apart:
cmd/modemmenu/ the program (the login, the menu, access, limits,
the selections, -serve, AutoPPP, drop files, the
auth socket's server)
internal/config/ modemmenu.conf's sections and keys, {name} templates
internal/term/ the caller's line, terminal detection, PETSCII
internal/auth/ the backends and password changes
internal/telnet/ the telnet client of mode = telnet items
authd/ the auth socket's protocol and a client, for a BBS
to import (bbs's internal/menuauth is a copy of it)
samples/ the .conf, .users, .pam and .service samples
make builds ./cmd/modemmenu and installs the samples from samples/; the
docs, confref and the site's reference follow. The tests are where
their code is, none lost. TestSampleHasEveryKey now reads the keys of
internal/ too (and the exported Get, Bool...: it would have found none).
.gitignore's "modemmenu" ignored cmd/modemmenu/ as well: it is
/modemmenu now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRbjf74j8oq9R3PXhA
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
// Copyright (C) 2026 D-Modem Authors
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package telnet
|
|
|
|
import "testing"
|
|
|
|
// TestTelnetDecode: the telnet client's data, its replies to the
|
|
// server, and the caller's bytes encoded
|
|
func TestTelnetDecode(t *testing.T) {
|
|
var sent []byte
|
|
tn := &Client{conn: nil, term: "ANSI", local: map[byte]bool{}, remote: map[byte]bool{}}
|
|
tn.conn = &recorder{b: &sent}
|
|
in := []byte{'h', iac, will, optEcho, 'i', iac, iac, iac, do, optTType,
|
|
iac, sb, optTType, 1, iac, se, iac, do, 31, '!'}
|
|
out := tn.Decode(in)
|
|
if string(out) != "hi\xff!" {
|
|
t.Errorf("data %q", out)
|
|
}
|
|
want := []byte{iac, do, optEcho, iac, will, optTType, iac, sb, optTType, 0, 'A', 'N', 'S', 'I', iac, se, iac, wont, 31}
|
|
if string(sent) != string(want) {
|
|
t.Errorf("replies % x, want % x", sent, want)
|
|
}
|
|
if got := tn.Encode([]byte{'a', '\r', iac}); string(got) != "a\r\x00\xff\xff" {
|
|
t.Errorf("encode % x", got)
|
|
}
|
|
}
|
|
|
|
type recorder struct{ b *[]byte }
|
|
|
|
// Write: p kept
|
|
func (r *recorder) Write(p []byte) (int, error) {
|
|
*r.b = append(*r.b, p...)
|
|
return len(p), nil
|
|
}
|