]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
[svn] - keyword-subst from charybdis 2.2.
authornenolod <redacted>
Thu, 25 Jan 2007 07:08:21 +0000 (23:08 -0800)
committernenolod <redacted>
Thu, 25 Jan 2007 07:08:21 +0000 (23:08 -0800)
ChangeLog
doc/example.conf
doc/reference.conf
include/serno.h
include/substitution.h [new file with mode: 0644]
src/Makefile.in
src/s_conf.c
src/s_user.c
src/substitution.c [new file with mode: 0644]

index 89c124ac70cfd97fdf4fd0a1065ce870ac05400c..a950e7ef2d8b660dcf97ddedadfb22eab19b9428 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,72 @@
+nenolod     2007/01/25 07:00:49 UTC    (20070125-3157)
+  Log:
+  Removed merge tracking for "svnmerge" for 
+  http://svn.atheme.org/charybdis/branches/release-2.2
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:59:58 UTC    (20070125-3155)
+  Log:
+  Initialized merge tracking via "svnmerge" with revisions "1-1919" from 
+  http://svn.atheme.org/charybdis/branches/release-2.2
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:59:30 UTC    (20070125-3153)
+  Log:
+  Removed merge tracking for "svnmerge" for 
+  http://svn.atheme.org/charybdis/branches/release-2.2
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:58:41 UTC    (20070125-3151)
+  Log:
+  Initialized merge tracking via "svnmerge" with revisions "1-2190" from 
+  http://svn.atheme.org/charybdis/branches/release-2.2
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:57:47 UTC    (20070125-3149)
+  Log:
+  - bleah
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:50:46 UTC    (20070125-3147)
+  Log:
+  Initialized merge tracking via "svnmerge" with revisions "1-3146" from 
+  http://svn.atheme.org/charybdis/branches/release-2.2
+  
+
+  Changes:     Modified:
+  + -          trunk/  (Property Modified)
+
+
+nenolod     2007/01/25 06:45:04 UTC    (20070125-3145)
+  Log:
+  - version bump to 2.2.0
+  
+
+  Changes:     Modified:
+  +3 -1                trunk/NEWS (File Modified) 
+  +1 -1                trunk/configure.ac (File Modified) 
+
+
 nenolod     2007/01/25 06:40:21 UTC    (20070125-3143)
   Log:
   - the new plan:
index a0576c58bbba57519b2219eb882e4ef4342cc7e5..25d5979606a9e5d0feff51c18b8eb8fb789665b2 100755 (executable)
@@ -4,7 +4,7 @@
  * Copyright (C) 2002-2005 ircd-ratbox development team
  * Copyright (C) 2005-2006 charybdis development team
  *
- * $Id: example.conf 3131 2007-01-21 15:36:31Z jilles $
+ * $Id: example.conf 3159 2007-01-25 07:08:21Z nenolod $
  *
  * See reference.conf for more information.
  */
@@ -286,7 +286,7 @@ serverhide {
 
 /* These are the blacklist settings.
  * You can have multiple combinations of host and rejection reasons.
- * They are used in pairs of one host/rejection reason.
+ * They are used in pairs of one host/rejection reason, or multiple hosts/rejection reason.
  *
  * These settings should be adequate for most networks, and are (presently)
  * required for use on AthemeNet.
@@ -294,16 +294,25 @@ serverhide {
  * Word to the wise: Do not use blacklists like SPEWS for blocking IRC
  * connections.
  *
+ * As of charybdis 2.2, you can do some keyword substitution on the rejection
+ * reason. The available keyword substitutions are:
+ *
+ *   ${ip}           - the user's IP
+ *   ${host}         - the user's canonical hostname
+ *   ${dnsbl-host}   - the dnsbl hostname the lookup was done against
+ *   ${nick}         - the user's nickname
+ *   ${network-name} - the name of the network
+ *
  * Note: AHBL (the providers of the below BLs) request that they be
  * contacted, via email, at admins@2mbit.com before using these BLs.
  * See <http://www.ahbl.org/services.php> for more information.
  */
 #blacklist {
 #      host = "ircbl.ahbl.org";
-#      reject_reason = "You have a host listed in the ircbl.ahbl.org blacklist.";
+#      reject_reason = "${nick}, your IP (${ip}) is listed in ${dnsbl-host} for having an open proxy. In order to protect ${network-name} from abuse, we are not allowing connections with open proxies to connect.";
 #
 #      host = "tor.ahbl.org";
-#      reject_reason = "You are connecting from a TOR exit node.";
+#      reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from tor-based abuse, we are not allowing TOR exit nodes to connect to our network.";
 #};
 
 alias "NickServ" {
index 6fcb82e2f20a79e9139f918f8613f2953c7665b2..4b43faef792143c652fb448ad49ee9ea91ac12a1 100755 (executable)
@@ -6,7 +6,7 @@
  *
  * Written by ejb, wcampbel, db, leeh and others
  *
- * $Id: reference.conf 3131 2007-01-21 15:36:31Z jilles $
+ * $Id: reference.conf 3159 2007-01-25 07:08:21Z nenolod $
  */
 
 /* IMPORTANT NOTES:
@@ -675,7 +675,7 @@ serverhide {
 
 /* These are the blacklist settings.
  * You can have multiple combinations of host and rejection reasons.
- * They are used in pairs of one host/rejection reason.
+ * They are used in pairs of one host/rejection reason, or multiple hosts/rejection reason.
  *
  * These settings should be adequate for most networks, and are (presently)
  * required for use on AthemeNet.
@@ -683,16 +683,25 @@ serverhide {
  * Word to the wise: Do not use blacklists like SPEWS for blocking IRC
  * connections.
  *
+ * As of charybdis 2.2, you can do some keyword substitution on the rejection
+ * reason. The available keyword substitutions are:
+ *
+ *   ${ip}           - the user's IP
+ *   ${host}         - the user's canonical hostname
+ *   ${dnsbl-host}   - the dnsbl hostname the lookup was done against
+ *   ${nick}         - the user's nickname
+ *   ${network-name} - the name of the network
+ *
  * Note: AHBL (the providers of the below BLs) request that they be
  * contacted, via email, at admins@2mbit.com before using these BLs.
  * See <http://www.ahbl.org/services.php> for more information.
  */
 #blacklist {
 #      host = "ircbl.ahbl.org";
-#      reject_reason = "You have a host listed in the ircbl.ahbl.org blacklist.";
+#      reject_reason = "${nick}, your IP (${ip}) is listed in ${dnsbl-host} for having an open proxy. In order to protect ${network-name} from abuse, we are not allowing connections with open proxies to connect.";
 #
 #      host = "tor.ahbl.org";
-#      reject_reason = "You are connecting from a TOR exit node.";
+#      reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from tor-based abuse, we are not allowing TOR exit nodes to connect to our network.";
 #};
 
 /*
index cf6eb51c906e684ce6d7bcf355752df325c9b3fb..eea15871c195683603a44e2191ca68e736c6a021 100644 (file)
@@ -1 +1 @@
-#define SERNO "20070125-3143"
+#define SERNO "20070125-3157"
diff --git a/include/substitution.h b/include/substitution.h
new file mode 100644 (file)
index 0000000..1a36433
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * charybdis: an advanced ircd
+ * markup.h: parses markup into human-readable strings
+ *
+ * Copyright (c) 2006-2007 William Pitcock <nenolod@nenolod.net>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include "stdinc.h"
+#include "tools.h"
+
+#ifndef SUBSTITUTION_H
+#define SUBSTITUTION_H
+
+extern void substitution_append_var(dlink_list *varlist, const char *name, const char *value);
+extern void substitution_free(dlink_list *varlist);
+extern char *substitution_parse(const char *fmt, dlink_list *varlist);
+
+#endif
index 0306d032bafc679655fedf1e8b8ac6b6d0ec4182..29c47377adac08524b7330e107a9d8db68afb314 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Makefile.in for ircd/src
 #
-# $Id: Makefile.in 1887 2006-08-29 13:42:56Z jilles $
+# $Id: Makefile.in 3159 2007-01-25 07:08:21Z nenolod $
 #
 CC             = @CC@
 INSTALL                = @INSTALL@
@@ -96,6 +96,7 @@ BASE_SRCS =                     \
   scache.c                      \
   send.c                        \
   snomask.c                    \
+  substitution.c               \
   supported.c                  \
   whowas.c                     \
   $(FNVHASH_S)
index 6ca336abe5a5bfa35e9cc581c272ab0574a2da3d..ca5e414a7501b3cdd9f97a78d35a9c0b7ca88f25 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: s_conf.c 3131 2007-01-21 15:36:31Z jilles $
+ *  $Id: s_conf.c 3159 2007-01-25 07:08:21Z nenolod $
  */
 
 #include "stdinc.h"
@@ -379,7 +379,7 @@ verify_access(struct Client *client_p, const char *username)
                if(ConfigFileEntry.kline_with_reason)
                {
                        sendto_one(client_p,
-                                       ":%s NOTICE %s :*** Banned %s",
+                                       form_str(ERR_YOUREBANNEDCREEP),
                                        me.name, client_p->name, aconf->passwd);
                }
                return (BANNED_CLIENT);
@@ -390,7 +390,7 @@ verify_access(struct Client *client_p, const char *username)
 
                if(ConfigFileEntry.kline_with_reason)
                        sendto_one(client_p,
-                                       ":%s NOTICE %s :*** Banned %s",
+                                       form_str(ERR_YOUREBANNEDCREEP),
                                        me.name, client_p->name, aconf->passwd);
 
                return (BANNED_CLIENT);
index 531278ea5eb74292b8bad13fa5465909bd72af52..9007818de86e9096e43f4b5312da8f5181f1b10c 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: s_user.c 3131 2007-01-21 15:36:31Z jilles $
+ *  $Id: s_user.c 3159 2007-01-25 07:08:21Z nenolod $
  */
 
 #include "stdinc.h"
@@ -56,6 +56,7 @@
 #include "monitor.h"
 #include "snomask.h"
 #include "blacklist.h"
+#include "substitution.h"
 
 static void report_and_set_user_flags(struct Client *, struct ConfItem *);
 void user_welcome(struct Client *source_p);
@@ -452,10 +453,22 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                                        source_p->sockhost, source_p->preClient->dnsbl_listed->host);
                else
                {
+                       dlink_list varlist;
+
+                       substitution_append_var(&varlist, "nick", source_p->name);
+                       substitution_append_var(&varlist, "ip", source_p->sockhost);
+                       substitution_append_var(&varlist, "host", source_p->host);
+                       substitution_append_var(&varlist, "dnsbl-host", source_p->preClient->dnsbl_listed->host);
+                       substitution_append_var(&varlist, "network-name", ServerInfo.network_name);
+
                        ServerStats->is_ref++;
+
                        sendto_one(source_p, form_str(ERR_YOUREBANNEDCREEP),
                                        me.name, source_p->name,
-                                       source_p->preClient->dnsbl_listed->reject_reason);
+                                       substitution_parse(source_p->preClient->dnsbl_listed->reject_reason, &varlist));
+
+                       substitution_free(&varlist);
+
                        sendto_one_notice(source_p, ":*** Your IP address %s is listed in %s",
                                        source_p->sockhost, source_p->preClient->dnsbl_listed->host);
                        source_p->preClient->dnsbl_listed->hits++;
diff --git a/src/substitution.c b/src/substitution.c
new file mode 100644 (file)
index 0000000..d0bff4c
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * charybdis: an advanced ircd
+ * substitution.c: parses substitution-keyword expansions
+ *
+ * Copyright (c) 2006-2007 William Pitcock <nenolod@nenolod.net>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include "stdinc.h"
+#include "tools.h"
+#include "balloc.h"
+#include "s_user.h"
+#include "irc_string.h"
+
+/*
+ * Simple mappings for $foo -> 'bar'.
+ * Everything is a string, so typing doesn't really matter too
+ * horribly much right now.
+ */
+struct substitution_variable
+{
+       char *name;
+       char *value;
+};
+
+/*
+ * substitution_append_var
+ *
+ * Inputs       - A variable list (dlink_list), name -> value for mapping to make
+ * Output       - none
+ * Side Effects - Adds a name->value mapping to a list.
+ */
+void substitution_append_var(dlink_list *varlist, const char *name, const char *value)
+{
+       struct substitution_variable *tmp = MyMalloc(sizeof(struct substitution_variable));
+
+       DupString(tmp->name, name);
+       DupString(tmp->value, value);
+
+       dlinkAddAlloc(tmp, varlist);
+}
+
+/*
+ * substitution_free
+ *
+ * Inputs       - A dlink_list of markup variables to free.
+ * Outputs      - none
+ * Side Effects - Empties a list of markup variables.
+ */
+void substitution_free(dlink_list *varlist)
+{
+       dlink_node *nptr, *nptr2;
+
+       DLINK_FOREACH_SAFE(nptr, nptr2, varlist->head)
+       {
+               struct substitution_variable *tmp = (struct substitution_variable *) nptr->data;
+
+               dlinkDelete(nptr, varlist);
+               MyFree(tmp->name);
+               MyFree(tmp->value);
+               MyFree(tmp);
+       }
+}
+
+/*
+ * substitution_parse
+ *
+ * Inputs       - A markup string, dlink-list of markup values
+ * Output       - A string which has been markup-replaced.
+ * Side Effects - Strings larger than BUFSIZE are terminated.
+ */
+char *substitution_parse(const char *fmt, dlink_list *varlist)
+{
+       static char buf[BUFSIZE];
+       const char *ptr;
+       char *bptr = buf;
+
+       for (ptr = fmt; *ptr != '\0' && bptr - buf < BUFSIZE; ptr++)
+               if (*ptr != '$')
+                       *bptr++ = *ptr;
+               else if (*(ptr + 1) == '{')
+               {
+                       static char varname[BUFSIZE];
+                       char *vptr = varname;
+                       const char *pptr;
+                       dlink_node *nptr;
+
+                       *vptr = '\0';
+
+                       /* break out ${var} */
+                       for (pptr = ptr + 2; *pptr != '\0'; pptr++)
+                       {
+                               if (*pptr != '}')
+                                       *vptr++ = *pptr;
+                               else
+                               {
+                                       *vptr++ = '\0';
+                                       break;
+                               }
+                       }
+
+                       s_assert(*varname != '\0');
+                       s_assert(*pptr != '\0');
+
+                       /* advance ptr by length of variable */
+                       ptr += (pptr - ptr);
+
+                       DLINK_FOREACH(nptr, varlist->head)
+                       {
+                               struct substitution_variable *val = (struct substitution_variable *) nptr->data;
+
+                               if (!strcasecmp(varname, val->name))
+                               {
+                                       strlcpy(bptr, val->value, BUFSIZE - (bptr - buf));
+                                       bptr += strlen(val->value);
+                                       break;
+                               }
+                       }
+               }
+
+       *bptr = '\0';
+       return buf;
+}