This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Undernet IRC Server Source Code.".
The branch, u2_10_12_branch has been updated
via 4441d041f2b9e494e07102618d03cf57029da5bb (commit)
via c3dc7b1b77dd33858f29c4d95562975f9e94ea1f (commit)
from 08df0f21fa4086ce98a3e9b415b5afbe78872bff (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4441d041f2b9e494e07102618d03cf57029da5bb
Author: Michael Poole <[email protected]>
Date: Sat Dec 21 21:24:06 2019 -0500
s_auth: Support asynchronous reply for "STATS iauth"
This requires a check for when clients exit, like UPING does.
It also requires m_stats() to not send RPL_ENDOFSTATS for "STATS iauth".
When iauth advertises a "S" capability, send it "? stats2".
diff --git a/doc/readme.iauth b/doc/readme.iauth
index ad057f25..6572601b 100644
--- a/doc/readme.iauth
+++ b/doc/readme.iauth
@@ -270,6 +270,7 @@ Comments: Request that the iauth program send a particular
type of
information to the server. The predefined values for <type> are:
config - iauth should send an "a", followed by all current "A" lines
stats - iauth should send an "s", followed by all current "S" lines
+ stats2 - iauth should send all current "S" lines, followed by an "s"
Compatibility: This is an Undernet extension and ircd does not send it.
IAUTH MESSAGES
@@ -332,8 +333,9 @@ Comments: Sets policy options for the iauth conversation.
Old policy
When this policy is in effect and a DNS message (N or d) is
sent for a client, that client's registration timeout is
extended or reset.
-Compatibility: The U policy is an Undernet extension and is not
- recognized by ircd.
+ S - IAuth supports the "? stats2" info request.
+Compatibility: The U and A policies are an Undernet extensions and are
+ not recognized by ircd.
V - iauth Program Version
Syntax: V :<version string>
@@ -360,7 +362,8 @@ Syntax: s
Example: s
Notify: yes
Comments: Indicates a new set of statistics will be sent. Any cached
- statistics records should be cleared.
+ statistics records should be cleared. In response to a "? stats2"
+ request, instead marks the end of a set of statistics.
S - Statistics Information
Syntax: S <module> :<module information>
diff --git a/include/client.h b/include/client.h
index 751d0fc3..ee415750 100644
--- a/include/client.h
+++ b/include/client.h
@@ -154,6 +154,7 @@ enum Flag
FLAG_BURST, /**< Server is receiving a net.burst */
FLAG_BURST_ACK, /**< Server is waiting for eob ack */
FLAG_IPCHECK, /**< Added or updated IPregistry data */
+ FLAG_IAUTH_STATS, /**< Wanted IAuth statistics */
FLAG_LOCOP, /**< Local operator -- SRB */
FLAG_SERVNOTICE, /**< server notices such as kill */
FLAG_OPER, /**< Operator */
@@ -573,6 +574,8 @@ struct Client {
#define IsUPing(x) HasFlag(x, FLAG_UPING)
/** Return non-zero if the client has no '\n' in its buffer. */
#define NoNewLine(x) HasFlag(x, FLAG_NONL)
+/** Return non-zero if the client has requested IAuth statistics. */
+#define IsIAuthStats(x) HasFlag(x, FLAG_IAUTH_STATS)
/** Return non-zero if the client has set mode +g (debugging). */
#define SendDebug(x) HasFlag(x, FLAG_DEBUG)
/** Return non-zero if the client has set mode +s (server notices). */
diff --git a/include/s_auth.h b/include/s_auth.h
index 52c6863f..657e925a 100644
--- a/include/s_auth.h
+++ b/include/s_auth.h
@@ -49,6 +49,7 @@ extern void auth_send_exit(struct Client *cptr);
extern void auth_send_xreply(struct Client *sptr, const char *routing, const
char *reply);
extern void auth_mark_closing(void);
extern void auth_close_unused(void);
+extern void auth_cancel_iauth_stats(struct Client *cptr);
extern void report_iauth_conf(struct Client *cptr, const struct StatDesc *sd,
char *param);
extern void report_iauth_stats(struct Client *cptr, const struct StatDesc *sd,
char *param);
diff --git a/include/s_stats.h b/include/s_stats.h
index 417e5c2a..5730e6c1 100644
--- a/include/s_stats.h
+++ b/include/s_stats.h
@@ -58,6 +58,7 @@ struct StatDesc
#define STAT_FLAG_LOCONLY 0x04 /**< Local user only */
#define STAT_FLAG_CASESENS 0x08 /**< Flag is case-sensitive */
#define STAT_FLAG_VARPARAM 0x10 /**< May have an extra parameter */
+#define STAT_FLAG_ASYNC 0x20 /**< Response is asynchronous */
extern void stats_init(void);
const struct StatDesc *stats_find(const char *name_or_char);
diff --git a/ircd/m_stats.c b/ircd/m_stats.c
index 60c4718e..7d4d91b7 100644
--- a/ircd/m_stats.c
+++ b/ircd/m_stats.c
@@ -165,6 +165,10 @@ m_stats(struct Client* cptr, struct Client* sptr, int
parc, char* parv[])
/* Ok, dispatch the stats function */
(*sd->sd_func)(sptr, sd, param);
+ /* If the response is asynchronous, do not send RPL_ENDOFSTATS yet. */
+ if (sd->sd_flags & STAT_FLAG_ASYNC)
+ return 0;
+
/* Done sending them the stats */
return send_reply(sptr, RPL_ENDOFSTATS, parv[1]);
}
diff --git a/ircd/s_auth.c b/ircd/s_auth.c
index 68aab5e4..85b91dcd 100644
--- a/ircd/s_auth.c
+++ b/ircd/s_auth.c
@@ -60,6 +60,7 @@
#include "s_conf.h"
#include "s_debug.h"
#include "s_misc.h"
+#include "s_stats.h"
#include "s_user.h"
#include "send.h"
@@ -158,6 +159,7 @@ enum IAuthFlag
IAUTH_TIMEOUT, /**< Refuse new connections if IAuth
is behind. */
IAUTH_EXTRAWAIT, /**< Give IAuth extra time to answer.
*/
IAUTH_UNDERNET, /**< Enable Undernet extensions. */
+ IAUTH_STATS2, /**< Support "? stats2" request. */
IAUTH_LAST_FLAG /**< total number of flags */
};
/** Declare a bitset structure indexed by IAuthFlag. */
@@ -207,6 +209,10 @@ struct IAuth {
static struct IAuth *iauth;
/** Freelist of AuthRequest structures. */
static struct AuthRequest *auth_freelist;
+/** Clients currently receiving IAuth statistics. */
+static struct SLink *iauth_stats_clients;
+/** Clients queued to get IAuth statistics. */
+static struct SLink *iauth_stats_queued;
static void iauth_sock_callback(struct Event *ev);
static void iauth_stderr_callback(struct Event *ev);
@@ -1652,6 +1658,7 @@ static int iauth_cmd_debuglevel(struct IAuth *iauth,
struct Client *cli,
* \li T IAUTH_TIMEOUT
* \li W IAUTH_EXTRAWAIT
* \li U IAUTH_UNDERNET
+ * \li S IAUTH_STATS2
*
* @param[in] iauth Active IAuth session.
* @param[in] cli Client referenced by command.
@@ -1677,6 +1684,7 @@ static int iauth_cmd_policy(struct IAuth *iauth, struct
Client *cli,
case 'T': IAuthSet(iauth, IAUTH_TIMEOUT); break;
case 'W': IAuthSet(iauth, IAUTH_EXTRAWAIT); break;
case 'U': IAuthSet(iauth, IAUTH_UNDERNET); break;
+ case 'S': IAuthSet(iauth, IAUTH_STATS2); break;
}
/* Optionally notify operators. */
@@ -1787,14 +1795,34 @@ static int iauth_cmd_newstats(struct IAuth *iauth,
struct Client *cli,
struct SLink *head;
struct SLink *next;
- head = iauth->i_stats;
- iauth->i_stats = NULL;
- for (; head; head = next) {
- next = head->next;
- MyFree(head->value.cp);
- free_link(head);
+ if (iauth_stats_clients)
+ {
+ for (head = iauth_stats_clients; head; head = next)
+ {
+ next = head->next;
+ send_reply(head->value.cptr, RPL_ENDOFSTATS, "iauthstats");
+ free_link(head);
+ }
+
+ iauth_stats_clients = iauth_stats_queued;
+ iauth_stats_queued = NULL;
+ if (iauth_stats_clients)
+ {
+ sendto_iauth(NULL, "? stats2");
+ }
}
- sendto_opmask_butone(NULL, SNO_AUTH, "New iauth statistics.");
+ else
+ {
+ head = iauth->i_stats;
+ iauth->i_stats = NULL;
+ for (; head; head = next) {
+ next = head->next;
+ MyFree(head->value.cp);
+ free_link(head);
+ }
+ sendto_opmask_butone(NULL, SNO_AUTH, "New iauth statistics.");
+ }
+
return 0;
}
@@ -1811,11 +1839,23 @@ static int iauth_cmd_stats(struct IAuth *iauth, struct
Client *cli,
struct SLink *node, **pptr;
char *line;
- for (pptr = &iauth->i_stats; *pptr; pptr = &((*pptr)->next)) ;
- node = *pptr = make_link();
line = paste_params(parc, params);
- DupString(node->value.cp, line);
- node->next = 0; /* must be explicitly cleared */
+ if (iauth_stats_clients)
+ {
+ for (node = iauth_stats_clients; node; node = node->next)
+ {
+ struct Client *cptr = node->value.cptr;
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s", line);
+ }
+ }
+ else
+ {
+ for (pptr = &iauth->i_stats; *pptr; pptr = &((*pptr)->next)) ;
+ node = *pptr = make_link();
+ DupString(node->value.cp, line);
+ node->next = 0; /* must be explicitly cleared */
+ }
+
return 0;
}
@@ -2500,20 +2540,63 @@ void report_iauth_conf(struct Client *cptr, const
struct StatDesc *sd, char *par
* @param[in] sd Stats descriptor for request.
* @param[in] param Extra parameter from user (may be NULL).
*/
- void report_iauth_stats(struct Client *cptr, const struct StatDesc *sd, char
*param)
+void report_iauth_stats(struct Client *cptr, const struct StatDesc *sd, char
*param)
{
struct SLink *link;
if (!iauth)
return;
- for (link = iauth->i_stats; link; link = link->next)
+ if (IAuthHas(iauth, IAUTH_STATS2))
{
- send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s", link->value.cp);
+ struct SLink *link;
+
+ link = make_link();
+ link->value.cptr = cptr;
+ if (iauth_stats_clients)
+ {
+ link->next = iauth_stats_queued;
+ iauth_stats_queued = link;
+ }
+ else
+ {
+ iauth_stats_clients = link;
+ sendto_iauth(NULL, "? stats2");
+ }
}
+ else
+ {
+ for (link = iauth->i_stats; link; link = link->next)
+ {
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s", link->value.cp);
+ }
+ send_reply(cptr, RPL_ENDOFSTATS, sd->sd_name);
- if (param && !strcmp(param, "get"))
+ if (param && !strcmp(param, "get") && !IAuthHas(iauth, IAUTH_STATS2))
+ {
+ sendto_iauth(NULL, "? stats");
+ }
+ }
+}
+
+static void remove_client_from_slist(struct Client *cptr, struct SLink **pptr)
+{
+ for (; *pptr != NULL; pptr = &((*pptr)->next))
{
- sendto_iauth(NULL, "? stats");
+ if ((*pptr)->value.cptr == cptr)
+ {
+ struct SLink *link = *pptr;
+ *pptr = link->next;
+ free_link(link);
+ }
}
}
+
+/** Cancel a client's request for IAuth statistics.
+ * @param[in] cptr Client to cancel request for.
+ */
+void auth_cancel_iauth_stats(struct Client *cptr)
+{
+ remove_client_from_slist(cptr, &iauth_stats_clients);
+ remove_client_from_slist(cptr, &iauth_stats_queued);
+}
diff --git a/ircd/s_misc.c b/ircd/s_misc.c
index 18ded623..08236447 100644
--- a/ircd/s_misc.c
+++ b/ircd/s_misc.c
@@ -192,6 +192,11 @@ static void exit_one_client(struct Client* bcptr, const
char* comment)
*/
if (IsUPing(bcptr))
uping_cancel(bcptr, 0);
+ /*
+ * Remove from /stats iauthstats lst
+ */
+ if (IsIAuthStats(bcptr))
+ auth_cancel_iauth_stats(bcptr);
/*
* Stop a running /LIST clean
*/
diff --git a/ircd/s_stats.c b/ircd/s_stats.c
index 0a35b820..07ddf9cb 100644
--- a/ircd/s_stats.c
+++ b/ircd/s_stats.c
@@ -652,7 +652,7 @@ struct StatDesc statsinfo[] = {
{ 'z', "memory", STAT_FLAG_OPERFEAT, FEAT_HIS_STATS_z,
count_memory, 0,
"Memory/Structure allocation information." },
- { ' ', "iauth", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM),
FEAT_HIS_STATS_IAUTH,
+ { ' ', "iauth", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM | STAT_FLAG_ASYNC),
FEAT_HIS_STATS_IAUTH,
report_iauth_stats, 0,
"IAuth statistics." },
{ ' ', "iauthconf", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM),
FEAT_HIS_STATS_IAUTH,
commit c3dc7b1b77dd33858f29c4d95562975f9e94ea1f
Author: Michael Poole <[email protected]>
Date: Tue Dec 10 21:03:14 2019 -0500
s_auth: Clean up paste_params() and its usage
diff --git a/ircd/s_auth.c b/ircd/s_auth.c
index f2e3d920..68aab5e4 100644
--- a/ircd/s_auth.c
+++ b/ircd/s_auth.c
@@ -1702,41 +1702,31 @@ static int iauth_cmd_version(struct IAuth *iauth,
struct Client *cli,
return 0;
}
-/** Paste a parameter list together into a single string.
+/** Paste a parameter list together into a single (static) string.
* @param[in] parc Number of parameters.
* @param[in] params Parameter list to paste together.
* @return Pasted parameter list.
*/
static char *paste_params(int parc, char **params)
{
- char *str, *tmp;
- int len = 0, lengths[MAXPARA], i;
+ static char buf[BUFSIZE+1];
+ int len, i, j;
/* Compute the length... */
- for (i = 0; i < parc; i++)
- len += lengths[i] = strlen(params[i]);
-
- /* Allocate memory, accounting for string lengths, spaces (parc - 1), a
- * sentinel, and the trailing \0
- */
- str = MyMalloc(len + parc + 1);
-
- /* Build the pasted string */
- for (tmp = str, i = 0; i < parc; i++) {
- if (i) /* add space separator... */
- *(tmp++) = ' ';
- if (i == parc - 1) /* add colon sentinel */
- *(tmp++) = ':';
-
- /* Copy string component... */
- memcpy(tmp, params[i], lengths[i]);
- tmp += lengths[i]; /* move to end of string */
+ for (i = len = 0; i < parc; i++) {
+ char *p = params[i];
+ if (i && (len < BUFSIZE)) /* add space separator... */
+ buf[len++] = ' ';
+ if ((i == parc - 1) && (len < BUFSIZE)) /* add colon sentinel */
+ buf[len++] = ':';
+ for (j = 0; (p[j] != '\0') && (len < BUFSIZE); ++j) /* copy arg */
+ buf[len++] = p[j];
}
- /* terminate the string... */
- *tmp = '\0';
+ /* terminate the string */
+ buf[len] = '\0';
- return str; /* return the pasted string */
+ return buf;
}
/** Clear cached iauth configuration information.
@@ -1773,15 +1763,13 @@ static int iauth_cmd_newconfig(struct IAuth *iauth,
struct Client *cli,
static int iauth_cmd_config(struct IAuth *iauth, struct Client *cli,
int parc, char **params)
{
- struct SLink *node;
+ struct SLink *node, **pptr;
+ char *line;
- if (iauth->i_config) {
- for (node = iauth->i_config; node->next; node = node->next) ;
- node = node->next = make_link();
- } else {
- node = iauth->i_config = make_link();
- }
- node->value.cp = paste_params(parc, params);
+ for (pptr = &iauth->i_config; *pptr; pptr = &((*pptr)->next)) ;
+ node = *pptr = make_link();
+ line = paste_params(parc, params);
+ DupString(node->value.cp, line);
node->next = 0; /* must be explicitly cleared */
return 0;
}
@@ -1820,14 +1808,13 @@ static int iauth_cmd_newstats(struct IAuth *iauth,
struct Client *cli,
static int iauth_cmd_stats(struct IAuth *iauth, struct Client *cli,
int parc, char **params)
{
- struct SLink *node;
- if (iauth->i_stats) {
- for (node = iauth->i_stats; node->next; node = node->next) ;
- node = node->next = make_link();
- } else {
- node = iauth->i_stats = make_link();
- }
- node->value.cp = paste_params(parc, params);
+ struct SLink *node, **pptr;
+ char *line;
+
+ for (pptr = &iauth->i_stats; *pptr; pptr = &((*pptr)->next)) ;
+ node = *pptr = make_link();
+ line = paste_params(parc, params);
+ DupString(node->value.cp, line);
node->next = 0; /* must be explicitly cleared */
return 0;
}
-----------------------------------------------------------------------
Summary of changes:
doc/readme.iauth | 9 ++-
include/client.h | 3 +
include/s_auth.h | 1 +
include/s_stats.h | 1 +
ircd/m_stats.c | 4 ++
ircd/s_auth.c | 174 ++++++++++++++++++++++++++++++++++++++----------------
ircd/s_misc.c | 5 ++
ircd/s_stats.c | 2 +-
8 files changed, 143 insertions(+), 56 deletions(-)
hooks/post-receive
--
Undernet IRC Server Source Code.
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches