Re-authenticate clients of old services against the new configuration

After a reload, unless noforce, a client of an old service goes by the
rules of the newest service on its listener, the one accepting there
now. It takes one of that service's maxconn slots, which counts it
there and keeps that service and its configuration alive until the
client is done, and is re-authenticated as its client: access lists,
users, authentication, bandwidth limits and traffic counters come from
the new configuration. A later reload moves it on, giving the slot
back. The client stays its own service's child, which keeps its
filters and TLS state.

It is dropped if its service was removed or is of another type now
(26), or if the newest service has no free slot (27); what the
re-authentication refuses ends it as before. A service without a
listener (UDP, connecting back) keeps its clients as they are.

This restores what force did before the configuration was kept per
service: since then a client compared its version with its own
service's configuration, which never changes, and was never checked
again. Services now take their configuration's version as it is: a
reload numbers the new configuration before reading it, and so does
startup now, where services were numbered one ahead.

A listener now stays with its old service until that service's last
client is gone, those clients looking the newest service up through
it; the socket itself is still closed as soon as nobody accepts on it.
Connection limits are given back in the configuration they were taken
in. PSRV() is the service whose rules apply to a client.

The reload case checks that a download of a user the new configuration
keeps finishes under it, and that one of a user it removes is cut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-14 23:16:00 +03:00
1 parent 3520e6e7cf
commit 724c92f3f6
8 files changed
+168 -50

No files matched your search

+6
View File
@@ -226,6 +226,9 @@ extern int timetoexit, needreload;
extern time_t curtime; /* the clock, kept by the main thread */
extern struct extparam *conf, *runconf;
/* the service whose rules apply to a client: its own, or after a reload the
newest one on its listener */
#define PSRV(param) ((param)->newsrv? (param)->newsrv : (param)->srv)
extern _3proxy_mutex_t confref_mutex, listener_mutex;
struct extparam * confget(void);
void confhold(struct extparam *c);
@@ -397,6 +400,9 @@ void freeauth(struct auth *);
void freefilter(struct filter *filter);
void freeconf(struct extparam *confp);
void confbegin(void);
int reattach(struct clientparam *param);
/* reattach() where configurations are reloaded, NULL elsewhere */
extern int (*reattachfunc)(struct clientparam *param);
struct passwords * copypwl (struct passwords *pwl);
void freepwl(struct passwords *pw);
int copyfilter(struct filter *, struct srvparam *srv);