From: wiebe Date: Fri, 23 Jan 2009 23:02:32 +0000 (+0100) Subject: split.patch: add SPLIT_BURST state flag, added wildcard support for mask in /SPLIT... X-Git-Url: https://jfr.im/git/irc/quakenet/snircd-patchqueue.git/commitdiff_plain/0c63b280e02018b7260c7aef8aabb0e65e255ee2 split.patch: add SPLIT_BURST state flag, added wildcard support for mask in /SPLIT and /STATS, changed to TStime() --- diff --git a/opernowildbadchan.patch b/opernowildbadchan.patch index 189d42e..0f88799 100644 --- a/opernowildbadchan.patch +++ b/opernowildbadchan.patch @@ -1,4 +1,4 @@ -Disallow wildcards in badchan set by local oper, and if local badchan by remote oper. +Disallow wildcards in badchan set by local oper, and for local badchan by remote oper. diff -r 5eee2151f0b1 ircd/gline.c --- a/ircd/gline.c Thu Jan 22 21:50:34 2009 +0100 diff --git a/split.patch b/split.patch index 02e4160..dc82c16 100644 --- a/split.patch +++ b/split.patch @@ -7,9 +7,21 @@ Add split.c split.h m_split.c NOTE: feature SPLIT is default enabled as that is just easier when working on this patch. -diff -r bc3532fbd97a include/handlers.h ---- a/include/handlers.h Tue Jan 20 17:24:09 2009 +0100 -+++ b/include/handlers.h Tue Jan 20 17:25:52 2009 +0100 +diff -r bcffa56c93d4 doc/api/log.txt +--- a/doc/api/log.txt Fri Jan 23 18:45:25 2009 +0100 ++++ b/doc/api/log.txt Fri Jan 23 23:04:58 2009 +0100 +@@ -41,7 +41,7 @@ + + + enum LogSys { +- LS_SYSTEM, LS_CONFIG, LS_OPERMODE, LS_GLINE, LS_JUPE, LS_WHO, LS_NETWORK, ++ LS_SYSTEM, LS_CONFIG, LS_OPERMODE, LS_GLINE, LS_JUPE, LS_SPLIT, LS_WHO, LS_NETWORK, + LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET, + LS_DEBUG, LS_OLDLOG, + LS_LAST_SYSTEM +diff -r bcffa56c93d4 include/handlers.h +--- a/include/handlers.h Fri Jan 23 18:45:25 2009 +0100 ++++ b/include/handlers.h Fri Jan 23 23:04:58 2009 +0100 @@ -139,6 +139,7 @@ extern int m_registered(struct Client*, struct Client*, int, char*[]); extern int m_sethost(struct Client*, struct Client*, int, char*[]); @@ -34,10 +46,10 @@ diff -r bc3532fbd97a include/handlers.h extern int ms_squit(struct Client*, struct Client*, int, char*[]); extern int ms_stats(struct Client*, struct Client*, int, char*[]); extern int ms_topic(struct Client*, struct Client*, int, char*[]); -diff -r bc3532fbd97a include/ircd_features.h ---- a/include/ircd_features.h Tue Jan 20 17:24:09 2009 +0100 -+++ b/include/ircd_features.h Tue Jan 20 17:25:52 2009 +0100 -@@ -110,6 +110,10 @@ +diff -r bcffa56c93d4 include/ircd_features.h +--- a/include/ircd_features.h Fri Jan 23 18:45:25 2009 +0100 ++++ b/include/ircd_features.h Fri Jan 23 23:04:58 2009 +0100 +@@ -111,6 +111,10 @@ FEAT_SETHOST_USER, FEAT_SETHOST_AUTO, @@ -48,7 +60,7 @@ diff -r bc3532fbd97a include/ircd_features.h /* HEAD_IN_SAND Features */ FEAT_HIS_SNOTICES, FEAT_HIS_SNOTICES_OPER_ONLY, -@@ -137,6 +141,7 @@ +@@ -138,6 +142,7 @@ FEAT_HIS_STATS_q, FEAT_HIS_STATS_R, FEAT_HIS_STATS_r, @@ -56,9 +68,20 @@ diff -r bc3532fbd97a include/ircd_features.h FEAT_HIS_STATS_s, FEAT_HIS_STATS_t, FEAT_HIS_STATS_T, -diff -r bc3532fbd97a include/msg.h ---- a/include/msg.h Tue Jan 20 17:24:09 2009 +0100 -+++ b/include/msg.h Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 include/ircd_log.h +--- a/include/ircd_log.h Fri Jan 23 18:45:25 2009 +0100 ++++ b/include/ircd_log.h Fri Jan 23 23:04:58 2009 +0100 +@@ -55,6 +55,7 @@ + LS_OPERMODE, /**< Uses of OPMODE, CLEARMODE< etc. */ + LS_GLINE, /**< Adding, (de-)activating or removing GLINEs. */ + LS_JUPE, /**< Adding, (de-)activating or removing JUPEs. */ ++ LS_SPLIT, /**< Adding, (de-)activating or removing SPLITs. */ + LS_WHO, /**< Use of extended WHO privileges. */ + LS_NETWORK, /**< New server connections. */ + LS_OPERKILL, /**< Kills by IRC operators. */ +diff -r bcffa56c93d4 include/msg.h +--- a/include/msg.h Fri Jan 23 18:45:25 2009 +0100 ++++ b/include/msg.h Fri Jan 23 23:04:58 2009 +0100 @@ -332,6 +332,10 @@ #define TOK_JUPE "JU" #define CMD_JUPE MSG_JUPE, TOK_JUPE @@ -70,9 +93,9 @@ diff -r bc3532fbd97a include/msg.h #define MSG_OPMODE "OPMODE" /* OPMO */ #define TOK_OPMODE "OM" #define CMD_OPMODE MSG_OPMODE, TOK_OPMODE -diff -r bc3532fbd97a include/numeric.h ---- a/include/numeric.h Tue Jan 20 17:24:09 2009 +0100 -+++ b/include/numeric.h Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 include/numeric.h +--- a/include/numeric.h Fri Jan 23 18:45:25 2009 +0100 ++++ b/include/numeric.h Fri Jan 23 23:04:58 2009 +0100 @@ -117,6 +117,7 @@ RPL_STATSVLINE 227 unreal */ #define RPL_STATSALINE 226 /* Hybrid, Undernet */ @@ -90,7 +113,7 @@ diff -r bc3532fbd97a include/numeric.h #define RPL_GLIST 280 /* Undernet extension */ #define RPL_ENDOFGLIST 281 /* Undernet extension */ #define RPL_JUPELIST 282 /* Undernet extension - jupe -Kev */ -@@ -441,6 +444,7 @@ +@@ -442,6 +445,7 @@ /* ERR_GHOSTEDCLIENT 503 efnet */ /* ERR_VWORLDWARN 503 austnet */ @@ -98,13 +121,12 @@ diff -r bc3532fbd97a include/numeric.h #define ERR_SILELISTFULL 511 /* Undernet extension */ /* ERR_NOTIFYFULL 512 aircd */ /* ERR_TOOMANYWATCH 512 Numeric List: Dalnet */ -diff -r bc3532fbd97a include/split.h +diff -r bcffa56c93d4 include/split.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/include/split.h Tue Jan 20 17:25:53 2009 +0100 -@@ -0,0 +1,120 @@ -+/* TODO: ifndef ? */ -+#ifndef INCLUDED_jupe_h -+#define INCLUDED_jupe_h ++++ b/include/split.h Fri Jan 23 23:04:58 2009 +0100 +@@ -0,0 +1,106 @@ ++#ifndef INCLUDED_split_h ++#define INCLUDED_split_h +/* + * IRC - Internet Relay Chat, include/split.h + * Copyright (C) 1990 Jarkko Oikarinen and @@ -129,7 +151,6 @@ diff -r bc3532fbd97a include/split.h + * @brief Interface and declarations for split server handling. + * @version $Id: jupe.h 1208 2004-10-03 14:12:35Z entrope $ + */ -+/* TODO: ifndef ? */ +#ifndef INCLUDED_sys_types_h +#include +#define INCLUDED_sys_types_h @@ -155,10 +176,11 @@ diff -r bc3532fbd97a include/split.h +}; + +/** Split state flags. */ -+#define SPLIT_ACTIVE 0x0001 /**< Split is active. */ -+#define SPLIT_REMOVING 0x0002 /**< Split is about to be destroyed. */ ++#define SPLIT_ACTIVE 0x01 /**< Split is active. */ ++#define SPLIT_REMOVING 0x02 /**< Split is being force removed (instead of deactivated). */ ++#define SPLIT_BURST 0x04 /**< Split is for a server that is in progress of linking, ++ and will be destroyed at the end of burst */ + -+/* TODO: these ; after } needed ? */ +/* Actions to perform on a SPLIT. */ +enum SplitAction { + SPLIT_ACTIVATE, /**< SPLIT should be activated. */ @@ -167,35 +189,22 @@ diff -r bc3532fbd97a include/split.h + SPLIT_REMOVE /**< SPLIT should be removed. */ +}; + -+/* TODO: what values to use here? */ +/* Split update flags. */ -+#define SPLIT_EXPIRE 0x0002 /**< Expiration time update. */ -+#define SPLIT_LIFETIME 0x0004 /**< Record lifetime update. */ -+#define SPLIT_REASON 0x0008 /**< Reason update. */ -+#define SPLIT_CREATION 0x0010 /**< Creation time update. */ -+#define SPLIT_MODIFY 0x0020 /**< No state change. */ ++#define SPLIT_EXPIRE 0x02 /**< Expiration time update. */ ++#define SPLIT_LIFETIME 0x04 /**< Record lifetime update. */ ++#define SPLIT_REASON 0x08 /**< Reason update. */ ++#define SPLIT_CREATION 0x10 /**< TODO: Creation time update - unused. */ ++#define SPLIT_MODIFY 0x20 /**< No state change. */ + +/* mask for Split update flags. */ +#define SPLIT_UPDATE (SPLIT_EXPIRE | SPLIT_LIFETIME | SPLIT_REASON) + +/* test whether a split entry is active. */ +#define SplitIsActive(s) ((s)->sp_flags & SPLIT_ACTIVE) -+/* test whether a split entry is marked for forecd removal. */ -+#define SplitIsRemoving(s) ((s)->sp_flags & SPLIT_REMOVING) -+ -+/* TODO: these are not used? some are, check! */ -+/* get the server name for a split entry. */ -+#define SplitServer(s) ((s)->sp_server) -+/* get the reason for a split entry. */ -+#define SplitReason(s) ((s)->sp_reason) -+/* get the creation time for split entry. */ -+#define SplitCreation(s) ((s)->sp_creation) -+/* get the expiration time for split entry. */ -+#define SplitExpire(s) ((s)->sp_expire) -+/* get the last modification time for split entry. */ -+#define SplitLastMod(s) ((s)->sp_lastmod) -+/* get the life time for split entry. */ -+#define SplitLifeTime(s) ((s)->sp_lifetime) ++/* test whether a split entry is marked for forced removal. */ ++#define SplitIsRemoving(s) ((s)->sp_flags & SPLIT_REMOVING) ++/* test whether a split entry is part of a netmerge. */ ++#define SplitIsBurst(s) ((s)->sp_flags & SPLIT_BURST) + +extern int split_add(struct Client *cptr, struct Client *sptr, + char *server, const char *reason, @@ -214,17 +223,17 @@ diff -r bc3532fbd97a include/split.h +extern void split_burst(struct Client *cptr); +extern int split_resend(struct Client *cptr, struct Split *split); +extern int split_list(struct Client *sptr, char *server); -+extern int split_merge(struct Client *server); -+extern int split_break(struct Client *server, const char *reason); ++extern void split_newserver(struct Client *acptr); ++extern int split_netmerge(struct Client *sptr); ++extern int split_netbreak(struct Client *victim, const char *reason); +extern void split_conf(); +extern void split_stats(struct Client *sptr, const struct StatDesc *sd, char *param); +extern int split_memory_count(size_t *sp_size); + -+/* TODO: endif ? */ -+#endif /* INCLUDED_jupe_h */ -diff -r bc3532fbd97a ircd/Makefile.in ---- a/ircd/Makefile.in Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/Makefile.in Tue Jan 20 17:25:53 2009 +0100 ++#endif /* INCLUDED_split_h */ +diff -r bcffa56c93d4 ircd/Makefile.in +--- a/ircd/Makefile.in Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/Makefile.in Fri Jan 23 23:04:58 2009 +0100 @@ -173,6 +173,7 @@ m_sethost.c \ m_settime.c \ @@ -282,9 +291,9 @@ diff -r bc3532fbd97a ircd/Makefile.in uping.o: uping.c ../config.h ../include/uping.h ../include/ircd_defs.h \ ../include/ircd_events.h ../config.h ../include/res.h \ ../include/client.h ../include/dbuf.h ../include/msgq.h \ -diff -r bc3532fbd97a ircd/ircd.c ---- a/ircd/ircd.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/ircd.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/ircd.c +--- a/ircd/ircd.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/ircd.c Fri Jan 23 23:04:58 2009 +0100 @@ -55,6 +55,7 @@ #include "s_misc.h" #include "s_stats.h" @@ -303,10 +312,10 @@ diff -r bc3532fbd97a ircd/ircd.c event_loop(); return 0; -diff -r bc3532fbd97a ircd/ircd_features.c ---- a/ircd/ircd_features.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/ircd_features.c Tue Jan 20 17:25:53 2009 +0100 -@@ -364,6 +364,10 @@ +diff -r bcffa56c93d4 ircd/ircd_features.c +--- a/ircd/ircd_features.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/ircd_features.c Fri Jan 23 23:04:58 2009 +0100 +@@ -365,6 +365,10 @@ F_B(SETHOST_USER, 0, 0, 0), F_B(SETHOST_AUTO, 0, 0, 0), @@ -317,7 +326,7 @@ diff -r bc3532fbd97a ircd/ircd_features.c /* HEAD_IN_SAND Features */ F_B(HIS_SNOTICES, 0, 1, 0), F_B(HIS_SNOTICES_OPER_ONLY, 0, 1, 0), -@@ -391,6 +395,7 @@ +@@ -392,6 +396,7 @@ F_B(HIS_STATS_q, 0, 1, 0), F_B(HIS_STATS_R, 0, 1, 0), F_B(HIS_STATS_r, 0, 1, 0), @@ -325,9 +334,20 @@ diff -r bc3532fbd97a ircd/ircd_features.c F_B(HIS_STATS_s, 0, 1, 0), F_B(HIS_STATS_t, 0, 1, 0), F_B(HIS_STATS_T, 0, 1, 0), -diff -r bc3532fbd97a ircd/m_endburst.c ---- a/ircd/m_endburst.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/m_endburst.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/ircd_log.c +--- a/ircd/ircd_log.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/ircd_log.c Fri Jan 23 23:04:58 2009 +0100 +@@ -154,6 +154,7 @@ + S(OPERMODE, -1, SNO_HACK4), + S(GLINE, -1, SNO_GLINE), + S(JUPE, -1, SNO_NETWORK), ++ S(SPLIT, -1, SNO_NETWORK), + S(WHO, -1, 0), + S(NETWORK, -1, SNO_NETWORK), + S(OPERKILL, -1, 0), +diff -r bcffa56c93d4 ircd/m_endburst.c +--- a/ircd/m_endburst.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/m_endburst.c Fri Jan 23 23:04:58 2009 +0100 @@ -85,6 +85,7 @@ #include "client.h" #include "hash.h" @@ -357,15 +377,15 @@ diff -r bc3532fbd97a ircd/m_endburst.c sendto_opmask_butone(0, SNO_NETWORK, "Completed net.burst from %C.", sptr); + /* cleanup SPLITs, but only bother ops when FEAT_SPLIT is enabled. */ -+ split = split_merge(sptr); ++ split = split_netmerge(sptr); + if (feature_bool(FEAT_SPLIT)) + sendto_opmask_butone(0, SNO_NETWORK, "Removed %d SPLIT entries.", split); if (MyConnect(sptr)) sendcmdto_one(&me, CMD_END_OF_BURST_ACK, sptr, ""); -diff -r bc3532fbd97a ircd/m_reburst.c ---- a/ircd/m_reburst.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/m_reburst.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/m_reburst.c +--- a/ircd/m_reburst.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/m_reburst.c Fri Jan 23 23:04:58 2009 +0100 @@ -102,6 +102,7 @@ #include "ircd_snprintf.h" #include "gline.h" @@ -385,9 +405,30 @@ diff -r bc3532fbd97a ircd/m_reburst.c default: break; } -diff -r bc3532fbd97a ircd/m_split.c +diff -r bcffa56c93d4 ircd/m_server.c +--- a/ircd/m_server.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/m_server.c Fri Jan 23 23:04:58 2009 +0100 +@@ -47,6 +47,7 @@ + #include "s_misc.h" + #include "s_serv.h" + #include "send.h" ++#include "split.h" + #include "userload.h" + + /* #include -- Now using assert in ircd_log.h */ +@@ -764,6 +765,9 @@ + sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s", + cli_name(sptr), cli_name(acptr)); + } ++ /* new server - mark SPLIT for this server */ ++ split_newserver(acptr); ++ + /* + * Old sendto_serv_but_one() call removed because we now need to send + * different names to different servers (domain name matching). +diff -r bcffa56c93d4 ircd/m_split.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/ircd/m_split.c Tue Jan 20 17:25:53 2009 +0100 ++++ b/ircd/m_split.c Fri Jan 23 23:04:58 2009 +0100 @@ -0,0 +1,374 @@ +/* + * IRC - Internet Relay Chat, ircd/m_split.c @@ -603,7 +644,7 @@ diff -r bc3532fbd97a ircd/m_split.c + struct Split *asplit = 0; + unsigned int flags = 0; + enum SplitAction action = SPLIT_MODIFY; -+ time_t expire = 0, lastmod = CurrentTime, creation = CurrentTime; ++ time_t expire = 0, lastmod = TStime(), creation = TStime(); + char *server = parv[1], *end; + const char *reason = NULL; + @@ -640,7 +681,7 @@ diff -r bc3532fbd97a ircd/m_split.c + /* user wants a listing of a specific SPLIT */ + if (parc == 2) + return split_list(sptr, server); -+ expire = strtol(parv[2], &end, 10) + CurrentTime; /* and the expiration */ ++ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */ + if (*end != '\0') + return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, + "%s :Bad expire time", parv[2]); @@ -662,7 +703,7 @@ diff -r bc3532fbd97a ircd/m_split.c + + case SPLIT_ACTIVATE: /* TODO: require expire and reason when new */ + if (parc > 2) { -+ expire = strtol(parv[2], &end, 10) + CurrentTime; /* and the expiration */ ++ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */ + if (*end != '\0') + return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, + "%s :Bad expire time", parv[2]); @@ -677,7 +718,7 @@ diff -r bc3532fbd97a ircd/m_split.c + + case SPLIT_DEACTIVATE: /* TODO: duplicate code? must be a cleaner way */ + if (parc > 2) { -+ expire = strtol(parv[2], &end, 10) + CurrentTime; /* and the expiration */ ++ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */ + if (*end != '\0') + return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, + "%s :Bad expire time", parv[2]); @@ -763,9 +804,9 @@ diff -r bc3532fbd97a ircd/m_split.c + + return split_list(sptr, parv[1]); +} -diff -r bc3532fbd97a ircd/parse.c ---- a/ircd/parse.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/parse.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/parse.c +--- a/ircd/parse.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/parse.c Fri Jan 23 23:04:58 2009 +0100 @@ -505,6 +505,13 @@ 0, MAXPARA, MFLG_SLOW, 0, NULL, /* UNREG, CLIENT, SERVER, OPER, SERVICE */ @@ -780,9 +821,9 @@ diff -r bc3532fbd97a ircd/parse.c }, { MSG_OPMODE, -diff -r bc3532fbd97a ircd/s_conf.c ---- a/ircd/s_conf.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_conf.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_conf.c +--- a/ircd/s_conf.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_conf.c Fri Jan 23 23:04:58 2009 +0100 @@ -53,6 +53,7 @@ #include "s_debug.h" #include "s_misc.h" @@ -799,9 +840,9 @@ diff -r bc3532fbd97a ircd/s_conf.c return ret; } -diff -r bc3532fbd97a ircd/s_debug.c ---- a/ircd/s_debug.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_debug.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_debug.c +--- a/ircd/s_debug.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_debug.c Fri Jan 23 23:04:58 2009 +0100 @@ -48,6 +48,7 @@ #include "s_user.h" #include "s_stats.h" @@ -839,9 +880,9 @@ diff -r bc3532fbd97a ircd/s_debug.c send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Hash: client %d(%zu), chan is the same", HASHSIZE, -diff -r bc3532fbd97a ircd/s_err.c ---- a/ircd/s_err.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_err.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_err.c +--- a/ircd/s_err.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_err.c Fri Jan 23 23:04:58 2009 +0100 @@ -490,7 +490,7 @@ /* 228 */ { RPL_STATSQLINE, "Q %s :%s", "228" }, @@ -872,9 +913,9 @@ diff -r bc3532fbd97a ircd/s_err.c /* 511 */ { ERR_SILELISTFULL, "%s :Your silence list is full", "511" }, /* 512 */ -diff -r bc3532fbd97a ircd/s_misc.c ---- a/ircd/s_misc.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_misc.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_misc.c +--- a/ircd/s_misc.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_misc.c Fri Jan 23 23:04:58 2009 +0100 @@ -53,6 +53,7 @@ #include "s_stats.h" #include "s_user.h" @@ -902,14 +943,14 @@ diff -r bc3532fbd97a ircd/s_misc.c + IsUser(killer) ? "SQUIT by " : "", IsUser(killer) ? cli_name(killer) : "", + IsUser(killer) ? ": " : "", comment); + sendto_opmask_butone(0, SNO_NETWORK, "Created %d SPLIT entries.", -+ split_break(victim, splitreason)); ++ split_netbreak(victim, splitreason)); + } } /* -diff -r bc3532fbd97a ircd/s_serv.c ---- a/ircd/s_serv.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_serv.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_serv.c +--- a/ircd/s_serv.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_serv.c Fri Jan 23 23:04:58 2009 +0100 @@ -54,6 +54,7 @@ #include "s_misc.h" #include "s_user.h" @@ -926,9 +967,9 @@ diff -r bc3532fbd97a ircd/s_serv.c /* * Pass on my client information to the new server -diff -r bc3532fbd97a ircd/s_stats.c ---- a/ircd/s_stats.c Tue Jan 20 17:24:09 2009 +0100 -+++ b/ircd/s_stats.c Tue Jan 20 17:25:53 2009 +0100 +diff -r bcffa56c93d4 ircd/s_stats.c +--- a/ircd/s_stats.c Fri Jan 23 18:45:25 2009 +0100 ++++ b/ircd/s_stats.c Fri Jan 23 23:04:58 2009 +0100 @@ -52,6 +52,7 @@ #include "s_stats.h" #include "s_user.h" @@ -949,10 +990,10 @@ diff -r bc3532fbd97a ircd/s_stats.c stats_sline, 0, "Spoofed hosts information." }, { 'T', "motds", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_T, -diff -r bc3532fbd97a ircd/split.c +diff -r bcffa56c93d4 ircd/split.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/ircd/split.c Tue Jan 20 17:25:53 2009 +0100 -@@ -0,0 +1,771 @@ ++++ b/ircd/split.c Fri Jan 23 23:04:58 2009 +0100 +@@ -0,0 +1,773 @@ +/* + * IRC - Internet Relay Chat, ircd/split.c + * Copyright (C) 1990 Jarkko Oikarinen and @@ -1029,7 +1070,7 @@ diff -r bc3532fbd97a ircd/split.c + memset(asplit, 0, sizeof(*asplit)); + /* TODO: some limit for servername length? HOSTLEN? */ + DupString(asplit->sp_server, server); /* copy vital information */ -+ /* TODO: some limit for reason length? QUITLEN TOPICLEN? */ ++ /* TODO: some limit for reason length? QUITLEN TOPICLEN? */ + /* TODO: prefix the reason here with the opername/ID? */ + DupString(asplit->sp_reason, reason); + /* TODO: what we use creation for and do we need it? */ @@ -1039,7 +1080,6 @@ diff -r bc3532fbd97a ircd/split.c + /* TODO: TStime() is CurrentTime + TSoffset */ + asplit->sp_lastmod = lastmod; + asplit->sp_lifetime = lifetime; -+ /* CHECK: does this make it active upon creation regardless of the flags given? */ + asplit->sp_flags = flags & SPLIT_ACTIVE; /* set split flags */ + + asplit->sp_next = GlobalSplitList; /* link it into the list */ @@ -1086,7 +1126,6 @@ diff -r bc3532fbd97a ircd/split.c + unsigned int flags) +{ + -+ /* TODO: check for proper masks - at least one dot and no wildcards? */ + struct Split *asplit; + struct Client *acptr; + @@ -1115,26 +1154,13 @@ diff -r bc3532fbd97a ircd/split.c + * You cannot set a negative (or zero) duration, nor can you set an + * duration greater than SPLIT_MAX_EXPIRE. + */ -+ if (expire - CurrentTime <= 0 || expire - CurrentTime > SPLIT_MAX_EXPIRE) { ++ if (expire - TStime() <= 0 || expire - TStime() > SPLIT_MAX_EXPIRE) { + if (!IsServer(cptr) && MyConnect(cptr)) -+ return send_reply(cptr, ERR_BADEXPIRE, expire - CurrentTime); -+ if (expire <= CurrentTime) /* no point going further */ -+ /* TODO: check lifetime then ? because the SPLIT may simply be deactivated -+ * and we did not see it before -+ * if it were to be activated again we would get it again -+ * but should we not keep the same state on each server? -+ */ ++ return send_reply(cptr, ERR_BADEXPIRE, expire - TStime()); ++ if (lifetime <= TStime()) /* no point going further */ + /* CHECK: sptr may have the wrong idea about the nettime? + * or we could be wrong? -+ * SETTIME ? could be dangerous and mess up things.. + * perhaps raise some sort of warning to ops -+ * maybe if the difference is larger than a poor RTT over the network? -+ * 60 seconds? -+ * no no no! - see above -+ */ -+ /* TODO: raise error with timestamps to SNO_OLDSNO? -+ * in the form of -+ * Nick collision on nick (nick 1232368192 <- hub.xx.quakenet.org 1232368192 (Same user@host)) + */ + return 0; + } @@ -1147,8 +1173,7 @@ diff -r bc3532fbd97a ircd/split.c + !(flags & SPLIT_ACTIVE) ? " deactivated " : " ", + server, expire, reason); + -+ /* TODO: add SPLIT log stuff or use JUPE? */ -+ log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, ++ log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C adding%sSPLIT for %s, expiring at %Tu: %s", + sptr, !(flags & SPLIT_ACTIVE) ? " deactivated " : " ", + server, expire, reason); @@ -1187,13 +1212,13 @@ diff -r bc3532fbd97a ircd/split.c + char buf[BUFSIZE]; + int pos = 0; + ++ /* TODO: assert() on other inputs? */ + assert(split); + assert(NULL != cptr); + assert(NULL != sptr); + -+ /* TODO: add action in the debug notice too */ -+ Debug((DEBUG_DEBUG, "split_modify(\"%s\", \"%s\", \"%s\", \"%s\", %Tu, %Tu, %Tu, " -+ "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), split->sp_server, reason, ++ Debug((DEBUG_DEBUG, "split_modify(\"%s\", \"%s\", \"%s\", \"%s\", %d, %Tu, %Tu, %Tu, " ++ "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), split->sp_server, reason, action, + creation, expire, lastmod, lifetime, flags)); + + /* not modifying SPLIT for server that is linked @@ -1206,50 +1231,46 @@ diff -r bc3532fbd97a ircd/split.c + * we can get SPLITs for a linked server. + * also more than one server can be bursting at a time. + */ -+ /* TODO: should we free it here or let that be done in end of burst? -+ * only when that is the ONLY situation we can get to this point! -+ * but if we free here and it is a burst, the count is incorrect in -+ * split_netmerge -+ * IsBurst() is that true for only that single server or for all its downlinks? -+ * I would guess single server only.. argh! -+ */ + if ((acptr = FindServer(split->sp_server))) { + if (MyUser(sptr)) + sendcmdto_one(&me, CMD_NOTICE, sptr, + "%C :Cannot modify SPLIT %s - server is linked.", sptr, split->sp_server); -+ split_free(split); /* and free it */ ++ /* SPLIT is not for a server part of a netmerge */ ++ if (!SplitIsBurst(split)) ++ split_free(split); /* and free it */ + return 0; + } + + /* First, let's check lastmod... */ -+ if (SplitLastMod(split) > lastmod) { /* we have a more recent version */ ++ if (split->sp_lastmod > lastmod) { /* we have a more recent version */ + if (IsBurstOrBurstAck(cptr)) + return 0; /* middle of a burst, it'll resync on its own */ + return split_resend(cptr, split); /* resync the server */ -+ } else if (SplitLastMod(split) == lastmod) ++ } else if (split->sp_lastmod == lastmod) + return 0; /* we have that version of the split entry... */ + + /* All right, we know that there's a change of some sort. What is it? */ + /* first, check out the expiration time... */ + /* TODO: expire != 0 or NULL - check that we have something? */ + if (expire != 0 && expire != split->sp_expire) { -+ if (expire - CurrentTime <= 0 || expire - CurrentTime > SPLIT_MAX_EXPIRE) { ++ if (expire - TStime() <= 0 || expire - TStime() > SPLIT_MAX_EXPIRE) { + if (!IsServer(sptr) && MyConnect(sptr)) /* bad expiration time */ -+ send_reply(sptr, ERR_BADEXPIRE, expire - CurrentTime); -+ if (expire - CurrentTime <= 0) /* no point in going further */ -+ /* TODO: same as in split_add - check lifetime? */ -+ return 0; ++ return send_reply(sptr, ERR_BADEXPIRE, expire - TStime()); + } + flags |= SPLIT_EXPIRE; + } else + flags &= ~SPLIT_EXPIRE; -+ ++ + /* Next, check out lifetime */ + if (!(flags & SPLIT_LIFETIME) || !lifetime) + lifetime = split->sp_lifetime; /* use Split lifetime */ + + lifetime = IRCD_MAX(lifetime, expire); /* set lifetime to the max */ + ++ /* now that we have the correct lifetime, check it */ ++ if (lifetime - TStime() <= 0) /* no point in going further */ ++ return 0; ++ + /* OK, let's see which is greater... */ + if (lifetime > split->sp_lifetime) + flags |= SPLIT_LIFETIME; /* have to update lifetime */ @@ -1268,7 +1289,7 @@ diff -r bc3532fbd97a ircd/split.c + if ((action == SPLIT_ACTIVATE && SplitIsActive(split)) || + (action == SPLIT_DEACTIVATE && !SplitIsActive(split)) || + /* can't activate an expired split entry */ -+ (IRCD_MAX(split->sp_expire, expire) <= CurrentTime)) ++ (IRCD_MAX(split->sp_expire, expire) <= TStime())) + action = SPLIT_MODIFY; /* no activity state modifications */ + + Debug((DEBUG_DEBUG, "About to perform changes; flags 0x%04x, action %s", @@ -1337,9 +1358,8 @@ diff -r bc3532fbd97a ircd/split.c + cli_name(sptr) : cli_name((cli_user(sptr))->server), + split->sp_server, buf); + -+ /* TODO: add SPLIT log stuff or use JUPE? */ + /* and log the change */ -+ log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, ++ log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C modifying SPLIT for %s:%s", + sptr, split->sp_server, buf); + @@ -1371,8 +1391,7 @@ diff -r bc3532fbd97a ircd/split.c + + /* deactivate entry and mark it for removal (used in split_propagate) */ + split->sp_flags |= SPLIT_REMOVING; -+ /* CHECK: turn bit SPLIT_ACTIVE off? */ -+ split->sp_flags |= SPLIT_ACTIVE; ++ split->sp_flags &= ~SPLIT_ACTIVE; + + /* TODO: add opername? */ + /* inform ops and log it */ @@ -1381,8 +1400,7 @@ diff -r bc3532fbd97a ircd/split.c + cli_name(sptr) : cli_name((cli_user(sptr))->server), + split->sp_server, split->sp_expire, split->sp_reason, reason); + -+ /* TODO: add SPLIT log stuff or use JUPE? */ -+ log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, ++ log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C removing SPLIT for %s, expiring at %Tu: %s (%s)", + sptr, split->sp_server, split->sp_expire, split->sp_reason, reason); + @@ -1450,13 +1468,12 @@ diff -r bc3532fbd97a ircd/split.c + + /* TODO: also check if the server in SPLIT entry is linked atm? */ + /* past lifetime */ -+ if (split->sp_lifetime <= CurrentTime) ++ if (split->sp_lifetime <= TStime()) + return 1; + + /* past expire time, deactivate entry if it is active */ -+ if ((split->sp_expire <= CurrentTime) && SplitIsActive(split)) -+ /* CHECK: turn bit SPLIT_ACTIVE off */ -+ split->sp_flags &= SPLIT_ACTIVE; ++ if ((split->sp_expire <= TStime()) && SplitIsActive(split)) ++ split->sp_flags &= ~SPLIT_ACTIVE; + + return 0; +} @@ -1518,99 +1535,125 @@ diff -r bc3532fbd97a ircd/split.c +split_list(struct Client *sptr, char *server) +{ + struct Split *split; -+ struct Split *ssplit; ++ int count = 0; + + assert(NULL != sptr); + -+ /* TODO: wildcard matching? */ -+ if (server) { -+ if (!(split = split_find(server))) /* no such split */ -+ return send_reply(sptr, ERR_NOSUCHSPLIT, server); -+ -+ /* send split information along */ ++ /* go through SPLITs */ ++ for (split = GlobalSplitList; split; split = split->sp_next) { ++ if (split_expire(split)) { /* expire any that need expiring */ ++ split_free(split); ++ continue; ++ } ++ if (server && match(server, split->sp_server)) ++ continue; ++ count++; + send_reply(sptr, RPL_SPLITLIST, split->sp_server, -+ split->sp_creation, split->sp_expire, -+ split->sp_lastmod, split->sp_lifetime, ++ split->sp_creation, split->sp_expire, split->sp_lastmod, split->sp_lifetime, + SplitIsActive(split) ? '+' : '-', split->sp_reason); -+ } else { -+ for (split = GlobalSplitList; split; split = ssplit) { /* go through splits */ -+ ssplit = split->sp_next; -+ -+ if (split_expire(split)) /* expire any that need expiring */ -+ split_free(split); -+ else /* send split information along */ -+ send_reply(sptr, RPL_SPLITLIST, split->sp_server, -+ split->sp_creation, split->sp_expire, -+ split->sp_lastmod, split->sp_lifetime, -+ SplitIsActive(split) ? '+' : '-', split->sp_reason); -+ } + } + ++ /* server given and nothing found */ ++ if (server && !count) ++ return send_reply(sptr, ERR_NOSUCHSPLIT, server); ++ + /* end of splitlist information */ + return send_reply(sptr, RPL_ENDOFSPLITLIST); +} + + ++/** Mark SPLIT for new server with SPLIT_BURST ++ * @param[in] acptr Server introduced to the network ++ */ ++void ++split_newserver(struct Client *acptr) ++{ ++ struct Split *split; ++ ++ assert(NULL != acptr); ++ ++ Debug((DEBUG_DEBUG, "split_newserver(\"%s\")", cli_name(acptr))); ++ ++ /* mark the SPLIT with SPLIT_BURST ++ * so we know this SPLIT is marked for removal already ++ * but not remove it just yet to get the correct count ++ * of SPLITs removed at the end of burst. ++ * also we need the SPLIT in case the net breaks again ++ * before end of burst? ++ */ ++ if ((split = split_find(cli_name(acptr)))) ++ split->sp_flags |= SPLIT_BURST; ++ return; ++} ++ ++ +/** Auto destroy SPLITs for servers gained in a netmerge -+ * @param[in] cptr Server that link to the network ++ * @param[in] sptr Server that has linked to the network + * @return Number of destroyed SPLITs + */ +int -+split_merge(struct Client *server) ++split_netmerge(struct Client *sptr) +{ + struct DLink *lp; + struct Split *split; + int count = 0; + -+ assert(NULL != server); ++ assert(NULL != sptr); + -+ Debug((DEBUG_DEBUG, "split_merge(\"%s\")", cli_name(server))); ++ Debug((DEBUG_DEBUG, "split_netmerge(\"%s\")", cli_name(sptr))); + + /* find the SPLIT for this server */ -+ if ((split = split_find(cli_name(server)))) { ++ if ((split = split_find(cli_name(sptr)))) { + split_free(split); + count++; + } + + /* go over its downlinks */ -+ for (lp = cli_serv(server)->down; lp; lp = lp->next) -+ count += split_merge(lp->value.cptr); ++ for (lp = cli_serv(sptr)->down; lp; lp = lp->next) ++ count += split_netmerge(lp->value.cptr); + return count; +} + + +/** Auto create SPLITs for servers lost in a netbreak -+ * @param[in] server Server that lost link to network ++ * @param[in] victim Server that lost link to network + * @param[in] reason Reason to add to SPLITs + * @return Number of created SPLITs + */ +int -+split_break(struct Client *server, const char *reason) ++split_netbreak(struct Client *victim, const char *reason) +{ + struct DLink *lp; + struct Split *split; + int count = 0; -+ time_t creation = CurrentTime, expire = CurrentTime + feature_int(FEAT_SPLIT_AUTO_EXPIRE), -+ lastmod = CurrentTime, lifetime = expire; ++ time_t creation = TStime(), expire = TStime() + feature_int(FEAT_SPLIT_AUTO_EXPIRE), ++ lastmod = TStime(), lifetime = expire; + unsigned int flags = SPLIT_ACTIVE; + -+ assert(NULL != server); ++ assert(NULL != victim); + -+ Debug((DEBUG_DEBUG, "split_break(\"%s\", \"%s\")", cli_name(server), reason)); ++ Debug((DEBUG_DEBUG, "split_netbreak(\"%s\", \"%s\")", cli_name(victim), reason)); + + /* bad auto expire value */ + if (feature_int(FEAT_SPLIT_AUTO_EXPIRE) <= 0) + return 0; + ++ /* TODO: what if we do have a SPLIT for this server? ++ * we remove splits in end of burst ++ * and if the netbreaks again before that ++ * free the SPLIT and create a new one? ++ * or simply update lastmod/lifetime/reason but leave the status? ++ */ + /* find the SPLIT for this server */ -+ if (!(split = split_find(cli_name(server)))) { -+ split_make(cli_name(server), reason, creation, expire, lastmod, lifetime, flags); ++ if (!(split = split_find(cli_name(victim)))) { ++ split_make(cli_name(victim), reason, creation, expire, lastmod, lifetime, flags); + count++; -+ } ++ } else ++ split->sp_flags &= SPLIT_BURST; /* clear the burst flag for it */ + + /* go over its downlinks */ -+ for (lp = cli_serv(server)->down; lp; lp = lp->next) -+ count += split_break(lp->value.cptr, reason); ++ for (lp = cli_serv(victim)->down; lp; lp = lp->next) ++ count += split_netbreak(lp->value.cptr, reason); + return count; +} + @@ -1625,8 +1668,8 @@ diff -r bc3532fbd97a ircd/split.c + struct Client *server; + struct Split *split; + struct Split *asplit; -+ time_t creation = CurrentTime, expire = CurrentTime + feature_int(FEAT_SPLIT_AUTO_EXPIRE), -+ lastmod = CurrentTime, lifetime = expire; ++ time_t creation = TStime(), expire = TStime() + feature_int(FEAT_SPLIT_AUTO_EXPIRE), ++ lastmod = TStime(), lifetime = expire; + unsigned int flags = SPLIT_ACTIVE; + char reason[BUFSIZE]; + @@ -1636,12 +1679,13 @@ diff -r bc3532fbd97a ircd/split.c + if (!feature_bool(FEAT_SPLIT)) + return; + ++ /* TODO: log this problem? */ + /* bad auto expire value */ + if (feature_int(FEAT_SPLIT_AUTO_EXPIRE) <= 0) + return; + + ircd_snprintf(0, reason, sizeof(reason), -+ "Generated upon loading conf file on %s", cli_name(&me)); ++ "Generated upon loading conf file on %C", &me); + + /* go over the conf contents */ + for (conf = GlobalConfList; conf; conf = conf->next) { @@ -1664,8 +1708,7 @@ diff -r bc3532fbd97a ircd/split.c + sendto_opmask_butone(0, SNO_NETWORK, "%C adding SPLIT for %s, expiring at %Tu: %s", + &me, conf->name, expire, reason); + -+ /* TODO: add SPLIT log stuff or use JUPE? */ -+ log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE, ++ log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%C adding SPLIT for %s, expiring at %Tu: %s", + &me, conf->name, expire, reason); + @@ -1690,16 +1733,18 @@ diff -r bc3532fbd97a ircd/split.c + char *param) +{ + struct Split *split; -+ struct Split *ssplit; + + /* send header so the client knows what we are showing */ + send_reply(sptr, SND_EXPLICIT | RPL_STATSHEADER, + "S Server Creation Expire Lastmod Lifetime Status :Reason"); + -+ for (split = GlobalSplitList; split; split = split->sp_next) ++ for (split = GlobalSplitList; split; split = split->sp_next) { ++ if (param && match(param, split->sp_server)) ++ continue; + send_reply(sptr, RPL_STATSSPLIT, split->sp_server, + split->sp_creation, split->sp_expire, split->sp_lastmod, split->sp_lifetime, + SplitIsActive(split) ? '+' : '-', split->sp_reason); ++ } +} + + @@ -1713,9 +1758,7 @@ diff -r bc3532fbd97a ircd/split.c + struct Split *split; + unsigned int sp = 0; + -+ /* TODO: check for expired entries? */ -+ for (split = GlobalSplitList; split; split = split->sp_next) -+ { ++ for (split = GlobalSplitList; split; split = split->sp_next) { + sp++; + *sp_size += sizeof(struct Split); + *sp_size += split->sp_server ? (strlen(split->sp_server) + 1) : 0;