diff options
| author | EuAndreh <eu@euandre.org> | 2026-04-26 16:21:30 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2026-04-26 16:21:30 -0300 |
| commit | e4a3a71f79a5993341c0f92ac46a36d4e83ffd9a (patch) | |
| tree | dab171d3ed495bd2b0da82e98edcf60bf8f109c8 /src/papod.clj | |
| parent | Forward client tags through PRIVMSG to recipients (diff) | |
| download | papod-e4a3a71f79a5993341c0f92ac46a36d4e83ffd9a.tar.gz papod-e4a3a71f79a5993341c0f92ac46a36d4e83ffd9a.tar.xz | |
Track unregistered connections and honor MODE -o
Add :n-unreg counter on the components map: incremented when a
client connects, decremented when it registers or disconnects.
LUSERS now reports the real unregistered count from this counter
(previously always 0 because unregistered clients are not in
:clients).
Also handle the 'o' character in user-mode setting so MODE <self>
-o actually clears :oper?, fixing the LuserOpers oper-count test.
Diffstat (limited to 'src/papod.clj')
| -rw-r--r-- | src/papod.clj | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/papod.clj b/src/papod.clj index 860e7ef..a9b4e41 100644 --- a/src/papod.clj +++ b/src/papod.clj @@ -965,6 +965,8 @@ (swap! client assoc :network-id (:default-network-id components))) (swap! client assoc :registered? true) + (when-let [n (:n-unreg components)] + (swap! n (fn [v] (max 0 (dec v))))) (when (:clients components) (swap! (:clients components) assoc nick {:w w :client-atom client})) @@ -3169,6 +3171,8 @@ (case c \i (swap! client assoc :invisible? adding?) \T (swap! client assoc :no-ctcp? adding?) + \o (when-not adding? + (swap! client assoc :oper? false)) nil)) [(str ":" (client-target client) " MODE " (client-target client) @@ -3518,16 +3522,9 @@ :oper?)) @clients)) 0) - n-unreg (if clients - (count - (filter - (fn [[_ m]] - (not - (some-> (:client-atom m) - deref - :registered?))) - @clients)) - 0)] + n-unreg (or (some-> (:n-unreg components) + deref) + 0)] [(numeric-reply client "251" (str ":There are " n-users " users and 0 invisible on 1 servers")) @@ -3944,7 +3941,8 @@ :chan-limits (atom {}) :invites (atom {}) :whowas (atom []) - :max-users (atom 0)})) + :max-users (atom 0) + :n-unreg (atom 0)})) (defconst- +idle-timeout-ms+ (if-let [t (System/getenv "PAPOD_IDLE_TIMEOUT")] @@ -3968,6 +3966,8 @@ :w w :connection-id conn-id :socket socket})] ;; Record connection start + (when-let [n (:n-unreg components)] + (swap! n inc)) (when-let [conn (:conn components)] @(d/transact conn [{:db/ensure :papod.connection/attrs @@ -3986,6 +3986,11 @@ (recur new-acc)))))) (catch Exception _) (finally + ;; If still unregistered, decrement count + (when (and (not (:registered? @client)) + (:n-unreg components)) + (swap! (:n-unreg components) + (fn [v] (max 0 (dec v))))) ;; Clean up in-memory state FIRST (before slow I/O) (when-let [nick (:nick @client)] ;; Record WHOWAS history (skip if QUIT already did) |
