Skip to content

Instantly share code, notes, and snippets.

@vjt
Created April 20, 2026 20:41
Show Gist options
  • Select an option

  • Save vjt/ae0e65623da359472024eb0102c93c4b to your computer and use it in GitHub Desktop.

Select an option

Save vjt/ae0e65623da359472024eb0102c93c4b to your computer and use it in GitHub Desktop.
Testplan for azzurra/bahamut#10 — LIST should send RPL_LISTSTART/LISTEND to restricted users

Testplan — PR #NN: fix/issue-10-list-restricted

Scope: verify that a restricted user issuing LIST receives the numeric stream 321 (RPL_LISTSTART)323 (RPL_LISTEND)447 (ERR_RESTRICTED), instead of the current bare 447.

Preconditions

  1. Testnet ircd.conf:
    • restriction_enabled = YES (top-level) — implies restriction block present.
    • One I: line with flag R (CONF_FLAGS_I_RESTRICTED = 0x40) matching the test client's host/mask.
    • Services linked (so IsKnownNick transitions at /ns identify time; restricted path is only taken while unidentified).
  2. The restriction flag is applied only to unregistered/unidentified nicks — per check_restricted_user at src/s_misc.c:1211.

Baseline (current master, no fix)

Expected stream after LIST:

:hub.azzurra.chat 447 NICK :Your connection is restricted!

mIRC: list dialog stays open indefinitely, waiting for 323 that never comes.

After fix (this PR)

Expected stream after LIST:

:hub.azzurra.chat 321 NICK Channel :Users  Name
:hub.azzurra.chat 323 NICK :End of /LIST
:hub.azzurra.chat 447 NICK :Your connection is restricted!

mIRC: list dialog opens, closes cleanly; restriction notice surfaces as server message.

Python harness (automated)

#!/usr/bin/env python3
import socket, ssl, sys, time

HOST = "127.0.0.1"         # testnet hub
PORT = 6697                # TLS listener
NICK = "rtest"
USER = "rtest 0 * :restricted test"

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

s = ctx.wrap_socket(socket.create_connection((HOST, PORT)), server_hostname=HOST)
def send(l): s.sendall((l + "\r\n").encode()); print(">>", l)
def recv_until(pred, timeout=10.0):
    s.settimeout(timeout)
    buf = b""
    seen = []
    end = time.time() + timeout
    while time.time() < end:
        try: chunk = s.recv(4096)
        except socket.timeout: break
        if not chunk: break
        buf += chunk
        while b"\r\n" in buf:
            line, buf = buf.split(b"\r\n", 1)
            line = line.decode(errors="replace")
            print("<<", line)
            seen.append(line)
            if pred(line): return seen
    return seen

send(f"NICK {NICK}")
send(f"USER {USER}")
recv_until(lambda l: " 001 " in l)    # RPL_WELCOME — connected without identify
send("LIST")
# Give the ircd a second to emit the full stream, then collect.
time.sleep(1.5)
# Read anything pending.
s.settimeout(1.0)
try:
    while True:
        chunk = s.recv(4096)
        if not chunk: break
        for line in chunk.decode(errors="replace").splitlines():
            print("<<", line)
except socket.timeout:
    pass

# Assertions (evaluate against captured stream):
#   - line containing " 321 " present
#   - line containing " 323 " present
#   - line containing " 447 " present
#   - order: 321 index < 323 index < 447 index

Manual mIRC sanity (Mezmerize, once authorized)

  1. Connect mIRC to testnet:6697 as rtest, without identifying.
  2. Type /list in server window.
  3. Before fix: channel list dialog opens blank, never closes; Your connection is restricted! appears in status window.
  4. After fix: channel list dialog opens, closes cleanly (empty list); restriction notice appears in status.

Regression checks

  • Unrestricted LIST still works: connect identified → /list returns actual channels.
  • check_restricted_user other callers unchanged: m_userhost, m_join, m_privmsg, umode changes still emit immediate ERR_RESTRICTED with no extra numerics.
  • ERR_NOUNKNOWNLISTS case (line 3188, just above) has the same LISTSTART/LISTEND hang — out of scope for this PR, flagged as follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment