jcs
/subtext
/amendments
/telnet.c
Amendments on July 16, 2022
*: Properly handle running out of sessions
Limit sessions to the number of uthreads we can handle, and then
reserve 1 session for the console.
In telnet, allocate one extra node so we can print a message to the
client that we have no free nodes, and then disconnect. Add a view
for this to make it editable.
In console, handle getting a null session back from session_create.
Amendments on July 14, 2022
telnet: When banning an IP, optionally send it via UDP to trusted proxy
If the new trusted_proxy_udp_port config option is set, send a UDP
packet containing the IP to the trusted_proxy_ip host so it can ban
it more aggressively.
Amendments on July 12, 2022
jcs made amendment
193
about 1 year ago
Amendments on July 11, 2022
telnet: When doing file transfers, fast-path to TCP buffer
We're doing IAC escaping in the zmodem code, so just move data
directly into node buffer. Also, avoid memmoving on each read since
the buffer will often have more than one byte in it, just use an
offset into ibuf and only memmove when it's over half full.
Amendments on June 23, 2022
telnet: Pre-allocate nodes, bump max to 10
This way we aren't constantly trying to find space for these big
chunks of memory for every new connection.
jcs made amendment
168
about 1 year ago
jcs made amendment
167
about 1 year ago
Amendments on June 22, 2022
telnet: Add trusted proxy IP setting for web gateway, unblock IPs
When a telnet connection comes from the configured proxy IP, allow the
REMOTE_ADDR environment variable passed to be used as the connection's
IP. Also don't auto-ban connections from the proxy.
Request TSPEED and store it as the session's terminal speed, just for
showing up in 'who' output.
Automatically unban IPs after 30 minutes by tracking the ban time.
Amendments on June 21, 2022
telnet: Don't abort TCP connection while there is an active session
telnet_idle is called outside of a uthread so just set session ending
and let it tear itself down once that thread is scheduled again
Amendments on June 17, 2022
jcs made amendment
154
about 1 year ago
telnet: Fast-track single-byte writes, spin a bit after sending
If our send succeeds and returns quickly, we can avoid having to
return and wait for uthread to cycle back to us. Since sends can take
a very long time, we can't simply switch to synchronous TCPSend calls
or we'll hang forever on a dead connection.
We can also avoid zeroing the full tcp_wds structure each time, since
it is zeroed at the node allocation and we only need to zero wds[1]
ptr and length.
Amendments on June 16, 2022
telnet: Make listening more resilient, add IP banning
MacTCP doesn't make it easy to detect when a listening socket has a
valid connection, or when it doesn't. Sometimes the connection is
accepted but then closed, sometimes TCPStatus returns a
connectionDoesntExist error, sometimes an open connection lingers in
TCP Wait. All of these were contributing to us no longer opening a
listening socket after some period of time accepting and closing
connections.
When bots try to login with a banned username, add their IP to a
ring buffer of IPs that we won't service. Unfortunately there is no
way to actually block these connections before they are accepted, so
we have to accept them, check the IP, and then close them right away.
Amendments on June 15, 2022
telnet: Use TCPNoCopyRcv instead of TCPRcv
Avoid copying input data to an intermediate node buffer, just to then
process it and copy it to the session buffer.
Doesn't seem to make things any faster, but might as well do it
Amendments on June 12, 2022
session: Close on banned username login attempt, track logged-in status
Ignore sessions that haven't logged in yet, and don't show guest
username in 'who' and logs.
Also show whether a user is a sysop in 'who'.
Amendments on April 14, 2022
focusable: Move code to separate file, fix a bunch of bugs here
Fix drawing on the wrong window, drawing in the wrong font, crash at
exit, etc.
Amendments on March 31, 2022
jcs made amendment
91
over 2 years ago
jcs made amendment
90
over 2 years ago
Amendments on March 17, 2022
jcs made amendment
87
over 2 years ago
jcs made amendment
72
over 2 years ago
Amendments on January 2, 2022
telnet: Separate TCP input buffering from IAC processing
Do IAC processing from the user's session, since it may need to send
data and we need to be able to wait for their output buffer to flush
while on their uthread