+2005-04-16 Michael Poole <mdpoole@troilus.org>
+
+ * doc/example.conf (Kill): Document newly supported syntax.
+
+ * include/s_conf.h (DenyConf): Split realname mask into its own
+ field. Remove the unused DENY_FLAGS_{IP,REALNAME}.
+
+ * ircd/ircd_parser.y (Kill): Only require one of usermask,
+ hostmask, realmask to be set for a valid block.
+ (killitem): Add new production killusername.
+
+ * ircd/s_conf.c (conf_erase_deny_list): Free realmask field.
+ (find_kill): Rearrange slightly to clarify control flow.
+
+ * ircd/s_err.c (RPL_STATSKLINE): Stick usermask before hostmask,
+ so the old usermask field can be adopted for realname mask. Add
+ double quotes around the realmask field.
+
+ * ircd/s_stats.c (report_deny_list): Do so.
+ (stats_klines): Likewise.
+
2005-04-17 Perry Lorier <isomer@undernet.org>
* tools/convert-conf.py: Fix lots of conversion problems with
Kill { host = "*.au"; reason = "Please use a nearer server"; };
Kill { host = "*.edu"; reason = "Please use a nearer server"; };
+# You can also kill based on username.
+Kill { username = "sub7"; realname = "s*7*"; reason = "You are infected with a Trojan";
+
# The file can contain for example, a reason, a link to the
-# server rules and a contact address.
+# server rules and a contact address. Note the combination
+# of username and host in the host field.
Kill
{
host = "*luser@unixbox.flooder.co.uk";
/** Local K-line structure. */
struct DenyConf {
struct DenyConf* next; /**< Next DenyConf in #denyConfList. */
- char* hostmask; /**< Mask for realname, IP or hostname. */
+ char* hostmask; /**< Mask for IP or hostname. */
char* message; /**< Message to send to denied users. */
char* usermask; /**< Mask for client's username. */
+ char* realmask; /**< Mask for realname. */
struct irc_in_addr address; /**< Address for IP-based denies. */
unsigned int flags; /**< Interpretation flags for the above. */
unsigned char bits; /**< Number of bits for ipkills */
};
#define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
-#define DENY_FLAGS_IP 0x0002 /**< K-line by IP address */
-#define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */
/** Local server configuration. */
struct LocalConf {
dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
} '{' killitems '}'
{
- if (dconf->hostmask != NULL)
- {
- if (dconf->usermask == NULL)
- DupString(dconf->usermask, "*");
+ if (dconf->usermask || dconf->hostmask ||dconf->realmask) {
dconf->next = denyConfList;
denyConfList = dconf;
}
else
{
+ MyFree(dconf->usermask);
MyFree(dconf->hostmask);
+ MyFree(dconf->realmask);
MyFree(dconf->message);
MyFree(dconf);
parse_error("Bad kill block");
dconf = NULL;
} ';';
killitems: killitem killitems | killitem;
-killitem: killuhost | killreal | killreasonfile | killreason | error;
+killitem: killuhost | killreal | killusername | killreasonfile | killreason | error;
killuhost: HOST '=' QSTRING ';'
{
char *u, *h;
- dconf->flags &= ~DENY_FLAGS_REALNAME;
MyFree(dconf->hostmask);
MyFree(dconf->usermask);
if ((h = strchr($3, '@')) == NULL)
ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits);
};
+killusername: USERNAME '=' QSTRING ';'
+{
+ MyFree(dconf->usermask);
+ DupString(dconf->usermask, $3);
+};
+
killreal: REAL '=' QSTRING ';'
{
- dconf->flags &= ~DENY_FLAGS_IP;
- dconf->flags |= DENY_FLAGS_REALNAME;
- MyFree(dconf->hostmask);
- /* Leave usermask so you can specify user and real... */
- DupString(dconf->hostmask, $3);
+ MyFree(dconf->realmask);
+ DupString(dconf->realmask, $3);
};
killreason: REASON '=' QSTRING ';'
MyFree(p->hostmask);
MyFree(p->usermask);
MyFree(p->message);
+ MyFree(p->realmask);
MyFree(p);
}
denyConfList = 0;
* -- Isomer
*/
for (deny = denyConfList; deny; deny = deny->next) {
- if (0 != match(deny->usermask, name))
+ if (deny->usermask && match(deny->usermask, name))
+ continue;
+ if (deny->realmask && match(deny->realmask, realname))
+ continue;
+ if (deny->bits > 0) {
+ if (!ipmask_check(&cli_ip(cptr), &deny->address, deny->bits))
+ continue;
+ } else if (deny->hostmask && match(deny->hostmask, host))
continue;
- if (EmptyString(deny->hostmask))
- break;
-
- if (deny->flags & DENY_FLAGS_REALNAME) { /* K: by real name */
- if (0 == match(deny->hostmask, realname))
- break;
- } else if (deny->flags & DENY_FLAGS_IP) { /* k: by IP */
-#ifdef DEBUGMODE
- char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN];
- Debug((DEBUG_DEBUG, "ip: %s network: %s/%u",
- ircd_ntoa_r(tbuf1, &cli_ip(cptr)), ircd_ntoa_r(tbuf2, &deny->address), deny->bits));
-#endif
- if (ipmask_check(&cli_ip(cptr), &deny->address, deny->bits))
- break;
- }
- else if (0 == match(deny->hostmask, host))
- break;
- }
- if (deny) {
if (EmptyString(deny->message))
send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
":Connection from your host is refused on this server.");
else
send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", deny->message);
}
+ return -1;
}
- else if ((agline = gline_lookup(cptr, 0))) {
+
+ if ((agline = gline_lookup(cptr, 0))) {
/*
* find active glines
* added a check against the user's IP address to find_gline() -Kev
*/
send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", GlineReason(agline));
- }
-
- if (deny)
- return -1;
- if (agline)
return -2;
+ }
return 0;
}
/* 215 */
{ RPL_STATSILINE, "I %s %d %s%s %d %s", "215" },
/* 216 */
- { RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216" },
+ { RPL_STATSKLINE, "%c %s@%s \"%s\" \"%s\" 0 0", "216" },
/* 217 */
{ RPL_STATSPLINE, "P %d %d %s %s", "217" },
/* 218 */
{
const struct DenyConf* p = conf_get_deny_list();
for ( ; p; p = p->next)
- send_reply(to, RPL_STATSKLINE, (p->flags & DENY_FLAGS_IP) ? 'k' : 'K',
- p->hostmask, p->message, p->usermask);
+ send_reply(to, RPL_STATSKLINE, p->bits > 0 ? 'k' : 'K',
+ p->usermask ? p->usermask : "*",
+ p->hostmask ? p->hostmask : "*",
+ p->message ? p->message : "(none)",
+ p->realmask ? p->realmask : "*");
}
/** Report K/k-lines to a user.
(wilds && !mmatch(host, conf->hostmask) &&
(!user || !mmatch(user, conf->usermask))))
{
- send_reply(sptr, RPL_STATSKLINE,
- (conf->flags & DENY_FLAGS_IP) ? 'k' : 'K',
- conf->hostmask, conf->message, conf->usermask);
+ send_reply(sptr, RPL_STATSKLINE, conf->bits > 0 ? 'k' : 'K',
+ conf->usermask ? conf->usermask : "*",
+ conf->hostmask ? conf->hostmask : "*",
+ conf->message ? conf->message : "(none)",
+ conf->realmask ? conf->realmask : "*");
if (--count == 0)
return;
}