===============================================================================
                              RGTEL v1.20 Win32
                  Telnet server and node launcher for DOS BBSes
                       (c) 2026 - NewWave Software
===============================================================================

 CONTENTS
   1.  What RGTEL is
   2.  Files
   3.  How a call is handled (step by step)
   4.  Installing and starting
   5.  The screen and the keys
   6.  RGTEL.INI - every setting
   7.  The Command line (*N *H *I)
   8.  Node numbers and HighNodeIPs
   9.  The BotGate (ESC x2 challenge)
  10.  Protection: whitelist, blacklist, rate limit, temp bans
  11.  ANSI screens
  12.  Logging
  13.  Restarting, shutting down, the system tray
  14.  Complete examples
  15.  Troubleshooting


===============================================================================
 1. WHAT RGTEL IS
===============================================================================

 RGTEL listens for telnet callers, keeps bots out, picks a free node, and
 starts your node batch file for each caller - handing it the node number,
 the socket handle and the caller's IP. It does the job Net2BBS does, with
 a live full-screen log and stronger protection against hammering bots.

 RGTEL itself does not talk to the BBS. A FOSSIL package does that:
 RGFOSSIL (or NetFoss) for DOS BBSes, or nothing at all for a Win32 BBS
 that uses the socket handle directly.


===============================================================================
 2. FILES
===============================================================================

   RGTEL.EXE       the server
   RGTEL.INI       settings (must be next to RGTEL.EXE)
   blacklist.txt   blocked IPs, one per line (name set by Blacklist=)
   telnet.log      the log (name set by Log=)
   CONNECT.ANS     shown to a caller who passes the BotGate    (optional)
   GOODBYE.ANS     shown when the BotGate times out            (optional)
   ERROR.ANS       shown when a wrong key is pressed at the gate (optional)

 The .ANS files are read from RGTEL's own folder. Missing ones are simply
 skipped.


===============================================================================
 3. HOW A CALL IS HANDLED
===============================================================================

   1. A caller connects to Port=.
   2. Whitelisted IP?  -> skips steps 3-6.
   3. Temp-banned?      -> dropped silently.
   4. Blacklisted?      -> "Access Denied. -Click!-" and dropped.
   5. Too many connects in RateWindow seconds?
                        -> "Connection Rate Exceeded. Try Again Later.",
                           temp-banned, dropped.
   6. Too many connections from this IP at once (MaxSameIP)?
                        -> same message, temp-banned, dropped.
   7. No free node?     -> "All Nodes Are BUSY. Please Try Again Shortly!"
   8. BotGate: the caller must press ESC twice within 15 seconds.
      (Whitelisted callers with BypassGate=1 skip this.)
   9. A node is chosen (lowest free, or highest free for HighNodeIPs).
  10. RGTEL sets SOCKET and NFNODE, fills in *N *H *I, and runs Command=
      in its own console window (see Nodeview=).
  11. When that process ends, the node is free again.


===============================================================================
 4. INSTALLING AND STARTING
===============================================================================

 1. Put RGTEL.EXE and RGTEL.INI in a folder, e.g. D:\RGTEL.
 2. Edit RGTEL.INI - at least Command=, StartPath=, Port= and Nodes=.
 3. Start RGTEL.EXE. It must stay running to accept callers.
    To start it with Windows, put a shortcut in the Startup folder.

 Port 23 is a "low" port: if RGTEL logs "Bind FAILED (WinSock error ...)"
 over and over, another program already uses the port, or Windows wants
 RGTEL run as Administrator. RGTEL keeps retrying (with growing delays),
 so it starts by itself once the port is free.


===============================================================================
 5. THE SCREEN AND THE KEYS
===============================================================================

 RGTEL shows a full-screen log: Date, Time and Activity columns. Long lines
 wrap on word boundaries. Colours:

   Red        BLOCK, DENY, BAN, RATE, Wrong key, Timed out, Failed
   Green      Passed, started, Node ...
   Magenta    Spawning ...
   Yellow     Shutdown
   Cyan       RGTEL / listening
   White      Everything else

 Keys
   ALT+X      Shut down (nodes still running are ended)
   R          Restart RGTEL (re-reads RGTEL.INI and blacklist.txt)


===============================================================================
 6. RGTEL.INI - EVERY SETTING
===============================================================================

 All settings are under [Settings]. Anything after a ";" on a line is a
 comment. On/off settings are 1 (on) or 0 (off).

 Command=                Command line run for each caller (section 7). Required.
 StartPath=              Folder the node command starts in.
                         Default: RGTEL's own folder.
 Port=                   TCP port to listen on. Default 23.
 Nodes=                  How many nodes. When all are busy, callers are told the
                         BBS is busy. Default 4.
 StartNode=              First node number. Default 1. (Nodes=4 with StartNode=1
                         gives nodes 1-4; StartNode=5 gives nodes 5-8.)
 HighNodeIPs=            Comma-separated IPs that get the HIGHEST free node
                         instead of the lowest (section 8). Default: none.
 MaxSameIP=              Most connections one IP may have at once, counting
                         nodes in use and callers still at the BotGate. Going
                         over it temp-bans the IP. 0 = no limit. Default 2.
 RateWindow=             Rate-limit window in seconds. Never less than 15.
                         Default 30.
 RateMaxConn=            Connection attempts allowed from one IP inside
                         RateWindow before it is temp-banned. 0 = rate limiting
                         off. Default 4.
 BanDuration=            Temp-ban length in seconds. 0 = no temp bans.
                         Default 300 (5 minutes).
 AutoBlacklistHits=      After this many temp-bans an IP is added to the
                         blacklist permanently. 0 = never. Default 0.
 AutoRestartOnBlacklist= Set to 1 = after an IP is auto-blacklisted, restart
                         RGTEL as soon as all nodes (and BotGate callers) are
                         idle - at once if they already are, otherwise when the
                         last caller leaves. 0 = restart by hand (R). Default 1.
 Whitelist=              Comma-separated IPs that are never banned, blacklisted,
                         rate-limited or counted against MaxSameIP. They still
                         see the BotGate unless BypassGate=1.
 BypassGate=             1 = whitelisted IPs skip the BotGate (they are shown
                         CONNECT.ANS and go straight in). Default 0.
 Blacklist=              Blacklist file name. Default blacklist.txt.
 Log=                    Log file name. Default telnet.log.
 LogMaxKB=               When the log reaches this size (KB), it is renamed to
                         <Log>.bak and a new log started. 0 = no limit. Default 0.
 Debug=                  1 = extra log lines (every rate check, whitelist hits,
                         the full command line of each node). Default 0.
 Nodeview=               How node windows appear:
                             0 = hidden (no window, no taskbar button)
                             1 = normal
                             2 = minimized
                             3 = maximized
                          Default 1.
 CloseToTray=             1 = RGTEL's own window lives in the system tray (section
                          13). Node windows still follow Nodeview. Default 0.

 Relative file names (Log=, Blacklist=) are relative to the folder RGTEL is
 started in; use full paths to be sure.


===============================================================================
 7. THE COMMAND LINE (*N *H *I)
===============================================================================

 Command= is run once per caller. Three codes are replaced first:

   *N   node number              e.g. 1
   *H   socket handle            e.g. 228
   *I   caller's IP address      e.g. 73.174.148.143

 RGTEL also sets these environment variables for the node:

   SOCKET   the socket handle (same as *H)
   NFNODE   the node number   (same as *N)

 RGFL/NFU and many Win32 doors read SOCKET and NFNODE.

 The socket handle is inheritable, so the node program (and anything it
 starts) can use the connection directly. RGTEL closes its own copy a
 moment after the node starts; the connection stays open for the node.

 With RGFOSSIL (DOS BBS):
   Command=D:\RGFOSSIL\RGFOSSIL.BAT /N*N /H*H D:\BATCH\TEL2RG.BAT *N *H *I
   -> RGFOSSIL.BAT /N1 /H228 D:\BATCH\TEL2RG.BAT 1 228 73.174.148.143

 With NetFoss (DOS BBS):
   Command=D:\NETFOSS\NF.BAT /N*N /H*H D:\BATCH\TEL2RG.BAT *N *H *I

 A Win32 BBS that takes a socket handle (switch names vary - see your
 BBS's documentation):
   Command=D:\BBS\WIN32BBS.EXE -H*H -N*N -IP*I

 A batch file directly:
   Command=D:\BATCH\NODE.BAT *N *H *I


===============================================================================
 8. NODE NUMBERS AND HighNodeIPs
===============================================================================

 RGTEL - not the FOSSIL - picks the node number:

   * Normally the LOWEST free node: 1, then 2, then 3 ...
   * Callers listed in HighNodeIPs get the HIGHEST free node: with Nodes=4,
     node 4, then 3, and so on.

 Why HighNodeIPs exists: web callers (fTelnet) come in through a few proxy
 IPs, and a BBS batch may run them on a special node (for example Renegade
 node 4). Without HighNodeIPs a web caller who arrives first takes node 1,
 and the next ordinary caller becomes node 2. With the proxy IPs listed:

   HighNodeIPs=168.235.108.229, 168.235.86.87, 198.46.217.114

 Web callers take the top nodes and ordinary callers keep 1, 2, 3.

 A node is free again as soon as the process RGTEL started for it ends.
 If a node window hangs, the node stays busy until it is closed.


===============================================================================
 9. THE BOTGATE (ESC x2 CHALLENGE)
===============================================================================

 Before a caller gets a node, RGTEL clears the screen and shows:

   Renegade Bot Blocker v1.20

   Press <ESC> twice for the BBS ... 15

 The counter runs down from 15 seconds.
   * Two ESC presses -> "Loading!", CONNECT.ANS, then the node starts.
   * Any other key   -> "Click!", ERROR.ANS, hang-up ("Wrong Key").
   * Time runs out   -> "Click!", GOODBYE.ANS, hang-up ("Timed Out").

 Bots almost never answer this, so they never reach the BBS. Telnet
 negotiation bytes sent by the caller's program are ignored at the gate.
 Whitelisted IPs can skip the gate with BypassGate=1.


===============================================================================
 10. PROTECTION
===============================================================================

 Order of checks: whitelist, temp-ban, blacklist, rate limit, MaxSameIP.

 Whitelist=
   Trusted IPs (your own, fTelnet proxies, friends' systems). Never banned
   or limited.

 blacklist.txt
   One IP per line. Callers get "Access Denied. -Click!-". Edit it with any
   text editor, then press R so RGTEL re-reads it.

 Rate limit (RateWindow / RateMaxConn)
   Counts connection attempts per IP in a rolling window. Example:
   RateWindow=30 and RateMaxConn=3 -> the 3rd connect inside 30 seconds is
   refused and the IP temp-banned. The log shows "RATE-LIMIT: ... BLOCKED".

 MaxSameIP
   Limits simultaneous connections from one IP, including callers still
   sitting at the BotGate. MaxSameIP=2 -> a 3rd simultaneous connection is
   refused and the IP temp-banned ("SAME-IP HAMMER").

 Temp bans (BanDuration)
   A banned IP is dropped without a word until the ban runs out ("DENY").

 Auto-blacklist (AutoBlacklistHits)
   Each temp-ban counts a "BAN-HIT". At AutoBlacklistHits the IP is written
   to blacklist.txt for good and blocked at once. With
   AutoRestartOnBlacklist=1, RGTEL then restarts itself as soon as no node
   is in use - immediately if all are idle, otherwise the moment the last
   caller leaves (the log says "Auto-Restart Deferred" and later
   "Initiating Deferred Auto-Restart").

 Temp bans and hit counts live in memory; a restart clears them.
 The blacklist file is permanent.


===============================================================================
 11. ANSI SCREENS
===============================================================================

 Put these in RGTEL's folder (CP437 ANSI art, any size):

   CONNECT.ANS   after the gate is passed, just before the BBS loads
   GOODBYE.ANS   when the gate times out
   ERROR.ANS     when a wrong key is pressed at the gate

 Keep CONNECT.ANS short - the BBS starts right after it.


===============================================================================
 12. LOGGING
===============================================================================

 Every event is written to the screen and to Log= with a timestamp:

   09-26-2026 18:56:21 RATE-CHECK: 73.174.148.143 - 2 Hits (Max 3 in 30(s))
   09-26-2026 18:56:22 BotGate: 73.174.148.143 Passed (<ESC> x2)
   09-26-2026 18:56:22 Spawning: D:\RGFOSSIL\RGFOSSIL.BAT /N1 /H228 ...
   09-26-2026 18:56:22 Node 1 Started for 73.174.148.143

 Useful lines
   Node n Started for <ip>          a caller got node n
   Spawn FAILED for Node n          Command= could not be started
   Node BUSY After Gate Pass        all nodes filled while at the gate
   BotGate: ... Timed Out / Wrong Key Pressed / Socket Closed
   RATE-LIMIT / SAME-IP HAMMER / TEMP-BAN / BAN-HIT / BLACKLIST / DENY
   Bind FAILED (WinSock error n)    the port can't be opened (section 4)

 Debug=1 adds RATE-CHECK lines, WHITELIST lines and the full "Spawning:"
 command line.

 LogMaxKB=512 keeps the log under about 512 KB; the previous log is kept
 as telnet.log.bak.

 At startup RGTEL logs its settings (whitelist count, HighNodeIPs, port,
 limiter, auto-blacklist, MaxSameIP, log limit).


===============================================================================
 13. RESTARTING, SHUTTING DOWN, THE SYSTEM TRAY
===============================================================================

 R            Restart: RGTEL starts a fresh copy of itself and exits. The new
              copy re-reads RGTEL.INI and blacklist.txt.
 ALT+X        Shut down.
 
 On shutdown or restart, nodes still in use are ENDED and their callers
 disconnected. Restart when the BBS is quiet.

 Node processes are tied to RGTEL: if RGTEL is closed or killed, Windows
 ends every node it started, so no orphan nodes are left behind.

 CloseToTray=1
   RGTEL's window is hidden and an icon placed in the system tray. Click
   the icon to show the window again for that run. Whenever the window is
   minimized it goes back to the tray. The setting carries over R restarts
   and automatic restarts. Node windows are not affected - they follow
   Nodeview=.


===============================================================================
 14. COMPLETE EXAMPLES
===============================================================================

 --- RGTEL.INI for a Renegade BBS with RGFOSSIL, 4 nodes -------------------

 [Settings]
 Command=D:\RGFOSSIL\RGFOSSIL.BAT /N*N /H*H D:\BATCH\TEL2RG.BAT *N *H *I
 StartPath=D:\RGFOSSIL
 Port=23
 Nodes=4
 MaxSameIP=2
 Log=telnet.log
 LogMaxKB=128
 Blacklist=blacklist.txt
 Debug=0
 Nodeview=2
 RateWindow=30
 RateMaxConn=3
 BanDuration=300
 AutoBlacklistHits=3
 AutoRestartOnBlacklist=1
 Whitelist=198.46.217.114
 HighNodeIPs=168.235.108.229, 168.235.86.87, 198.46.217.114
 BypassGate=0
 CloseToTray=1

 --- The node batch it runs (TEL2RG.BAT) -----------------------------------

 @ECHO OFF
 SET SOCKET=%2
 SET NFNODE=%1
 D:
 CD\RENEGADE
 RENEGADE -B57600 -Q -N%1 -IP%3 -T

 %1 = node, %2 = socket, %3 = IP. RGFOSSIL.BAT loads the FOSSIL for node
 %1 before this batch runs and unloads it afterwards.

 --- Lenient settings for a quiet test BBS ----------------------------------

 MaxSameIP=0
 RateMaxConn=0
 BanDuration=0

 --- Tight settings when bots are hammering ----------------------------------

 MaxSameIP=1
 RateWindow=60
 RateMaxConn=2
 BanDuration=3600
 AutoBlacklistHits=2

 --- Second BBS on another port, nodes 5-8 ----------------------------------

 (second copy of RGTEL in its own folder)
 Port=2323
 StartNode=5
 Nodes=4


===============================================================================
 15. TROUBLESHOOTING
===============================================================================

 "Spawn FAILED for Node n"
   The program at the start of Command= wasn't found. Check the path; with
   RGFOSSIL it must be RGFOSSIL.BAT, followed by your BBS batch.

 The node window flashes open and closes
   Set Nodeview=1 so it stays visible, and look at the message. With
   RGFOSSIL, RGFOSSIL.BAT waits 15 seconds when the FOSSIL can't load.

 Callers get node 2 while node 1 looks free
   Node 1 is still held by another caller (for example a web caller on a
   special BBS node). Add the proxy IPs to HighNodeIPs.

 A node stays "busy" after the caller left
   Its process is still running. Look at its window (Nodeview=1) or Task
   Manager. The node frees itself the moment the process ends.

 "Bind FAILED (WinSock error 10048)"
   Something else uses the port (another RGTEL, Net2BBS, a telnet service).

 "Bind FAILED (WinSock error 10013)"
   Permission denied - run RGTEL as Administrator, or use a port above 1024.

 A friend keeps getting banned
   Add their IP to Whitelist=, press R, and remove it from blacklist.txt if
   it was auto-blacklisted.

 An edit to blacklist.txt doesn't take effect
   Press R - the file is read at startup.


