mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Count the clients of each listener
A listener counts its clients, whichever of its services they came to, old or new: those connected now, raised when a client is spawned, and those done with, raised as one leaves its service. As the listener outlives a reload, so do the counts. The services page of the admin interface shows them for each service as listenerclients and listenerprocessed; services sharing a socket show the same counts. The takeover case checks that the count goes on through three reloads and that no client is left counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d83a48fe18
commit
113c9eaebe
4 files changed
+73
-1
No files matched your search
@@ -2,6 +2,7 @@
|
||||
the same address and port takes over the old service's socket, so clients
|
||||
connecting all the while are never refused nor reset."""
|
||||
|
||||
import re
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
@@ -67,6 +68,24 @@ def run(t):
|
||||
t.eq(0, done["failed"], "no request is refused or reset by a reload "
|
||||
f"(first errors: {done['errors']})")
|
||||
|
||||
# the listener counts its clients, whichever service took them: through
|
||||
# the reloads the proxy's socket is one, its count goes on
|
||||
def listener_counts(service):
|
||||
"""The listener counters of the running service of that type: its
|
||||
item has nested ones, acl and clients, before its counters."""
|
||||
page = t.http(f"http://127.0.0.1:{adm}/S").text
|
||||
m = re.search(r"type of the service/client</description><value><!\[CDATA\[" + service +
|
||||
r"\]\].*?<name>listenerclients</name>.*?CDATA\[(\d+)\]"
|
||||
r".*?<name>listenerprocessed</name>.*?CDATA\[(\d+)\]", page, re.S)
|
||||
return (int(m.group(1)), int(m.group(2))) if m else (None, None)
|
||||
|
||||
clients, processed = listener_counts("PROXY")
|
||||
t.eq(0, clients, "no client is connected to the proxy's listener after the run")
|
||||
total = done["ok"] + done["failed"]
|
||||
t.ok(f"its count of clients done with goes on through the reloads ({processed} of {total})") \
|
||||
if processed is not None and processed >= total else \
|
||||
t.fail("its count of clients done with goes on through the reloads", f"at least {total}", processed)
|
||||
|
||||
# --- UDP: the socket is handed over too, and a session of the old
|
||||
# service goes on through it, its datagrams forwarded by the new one ---
|
||||
echo = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
Reference in new issue
Block a user