Repository navigation
M1: the NMDC hub (P1-P5, P7 TLS) on the arisrvx loop - #7
Merged
Merged
Conversation
server/src/sublevels/nmdc/ implements spec/nmdc/ P1 (framing, the Windows-1252 edge, escaping, $Lock/$Key, limits), P2 (the login state machine, nicks, $MyINFO kept verbatim, the user list), P3 (main chat echoed, $To, the hub bot with +help/+motd/+rules), P4 (search with the address rewrite and passive-to-active-only fan-out, $SR routing), P5 ($ConnectToMe/$RevConnectToMe with the rewrite and the both-passive refusal) and P7 §1 (NMDCS on its own port, TLS 1.2+, certificate reload). D14's counters are kept in memory and served at /admin/stats behind a bearer token; /stats gives the user count. The hub publishes sublevels.hubs.<id> (name, topic, user list without addresses) for native clients. Tests per spec item run without sockets; test_nmdc_listener.py runs the hub on real plain and TLS sockets. The arisrvx smoke run now logs in over NMDC and NMDCS and reads /admin/stats.
transfix
force-pushed
the
m1-nmdc-hub
branch
from
November 16, 2026 04:41
41faa83 to
a0a17b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M1's NMDC hub, part 2 of 3. It is stacked on #6 (CI on libcvc 4.0.0), so the diff against
ci-libcvc-4is this PR's own. Retarget it tomainonce #6 merges. Part 3, interop with ncdc and AirDC++ web plus the 6000+ soak, follows as its own PR.Clean room. This was written only from
spec/nmdc/(main 7b50715), the public documents it cites, this repository, and libcvc's docs and source for the host API. No Direct Connect implementation was opened.Spec sections implemented
nmdc/listener.py,hub.pynmdc/codec.py?for what it can't holdcodec.pycodec.py,hub.py$Lock EXTENDEDPROTOCOL_sublevels_<24> Pk=sublevels<ver>and the$Keycheck. Lenient by default;SUBLEVELS_STRICT_KEYcloses on a wrong keyhub.py,nmdc/myinfo.py$Supportsand the hub's own$Supportsline$GetPass/$MyPass/$BadPass,password_requires_tls, the 5-per-10-minute failure limit$Hello$MyINFOkept verbatim, with the 10 s update interval and byte-identical updates skipped$GetINFONoHello,NoGetINFOor neither;$OpList,$BotList,$UserIP$Quit,$HubTopicor the topic in$HubName, the message of the day, capacity ($HubIsFull)hub.py$To:sent to the target only; the bot and+help/+motd/+rules(placeholder texts) in chat and by private message; the length and rate limits; the sender checks (3 bad lines close the connection)hub.pyChatOnlyusers get no searches, and a$Searchfrom one closes it$SRrouted with its target stripped; at most 10 per responder per target, within 30 shub.py$ConnectToMein both forms, the address rewritten, port and suffix kept;$RevConnectToMewith the both-passive refusal; 20 requests per 10 s, 5 per remotelistener.pytls_requiredwith$ForceMovenmdc/counters.py,api.pyAlso:
$SR, CTM/RCTM, and bytes in and out;GET /admin/statsserves them behind a bearer token fromSUBLEVELS_ADMIN_TOKEN_FILEorSUBLEVELS_ADMIN_TOKEN; without a token the route answers 404.GET /statsis the public user count.sublevels.hubs.mainholdsname,topic,bot,users.count, andusers.listkeyedu<connection id>, with nick, description, client, mode, share, protocol and op. Addresses are never published. It is written at most once a second.server.pybinds the listeners beforehost.run(), so an unbindable port stops the program with its traceback. On shutdown the hub closes its connections.HubConfigfield, read fromSUBLEVELS_*variables (nmdc/config.py).python -m sublevels.serveradds--nmdc-listenand--nmdcs-listen.Where the spec is silent or a "To capture" item blocks: what I chose
$ValidateNickbefore$Keyis ignored, as P2 §1's table says. A client that never sends$Keywaits out the login timeout. The captures will show whether any client does this.$HubNameis sent at connect, before$Supportsis known, so it carries no topic. For a client withoutHubTopic, the hub sends$HubName <name> - <topic>again after login, when there is a topic.$SR: a result more than 30 s after the target's last search is dropped. The 10-per-responder count restarts at each new search by the target.$Searchor$ConnectToMeaddress for an IPv6 connection is written as[addr]:port.$ConnectToMesuffixes: any trailing letters after the port are kept (S,NS, …), so NAT-traversal suffixes pass through until the captures say what they are.$RevConnectToMebetween two passive users is never forwarded. P5 §2's NAT-traversal exception waits on a capture.!from a non-operator is ordinary chat. An unknown+commandgets "No such command … Type +help."+rules/+helphint.$GetNickListwhile online gets the whole list again.$MyINFOof the wrong shape is dropped and counts as malformed. Only one for another nick during login closes the connection.SUBLEVELS_IDENTITY_SALTis set.transport.write. A reader whose unsent output passes 4 MiB is closed.Not in M1: bans and location policy (D9, D11, D12), country on profiles (D13),
$MCTo, ZLIB, TLS detection on the plain port (P7's MAY), operator commands (P6), and native users in the NMDC view (P2 §8).Tests and checks
pytest:
test_nmdc_p1.py…test_nmdc_p5.py: the hub per spec item, without sockets, on a fake clock;test_nmdc_listener.py: two clients on real sockets doing chat, PM, search,$SR, RCTM and CTM; an NMDCS login with a self-signed certificate; TLS 1.1 refused; a too-long message; a slow reader; the certificate reload;sublevels.hubs.main;python -m sublevels.serverwith an NMDC login.The arisrvx smoke run (
server/ci/smoke.sh, arisrvx 4.0.0+cvc.1, locally):tools/nmdc_client.py, run by arisrvx's own python, logs in over NMDC and over NMDCS, chats, and sees the echo.GET /admin/statscounts 2 logins; SIGTERM gives exit 0.In-process timings with null connections at 6000 users. Not a soak; part 3 measures over sockets.
stats()