* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * $Id: config.h,v 1.3 2002/01/13 07:15:10 a1kmm Exp $
+ * $Id: config.h,v 1.4 2002/04/19 10:56:14 a1kmm Exp $
*/
#ifndef INCLUDED_config_h
#define SLPATH BINPATH "]SERVLINK.EXE" /* servlink executable */
#define CPATH ETCPATH "]IRCD.CONF" /* config file */
#define KPATH ETCPATH "]KLINE.CONF" /* kline file */
+#define GCPATH ETCPATH "]GLINE.CONF" /* gline file */
#define DLPATH ETCPATH "]DLINE.CONF" /* dline file */
#define GPATH LOGPATH "]GLINE.LOG" /* gline logfile */
#define RPATH ETCPATH "]IRCD.RSA" /* RSA private key file */
#define SLPATH BINPATH "/servlink" /* servlink executable */
#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */
#define KPATH ETCPATH "/kline.conf" /* kline file */
+#define GCPATH ETCPATH "/gline.conf" /* gline file */
#define DLPATH ETCPATH "/dline.conf" /* dline file */
#define GPATH LOGPATH "/gline.log" /* gline logfile */
#define RPATH ETCPATH "/ircd.rsa" /* ircd rsa private keyfile */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * $Id: hostmask.h,v 1.2 2002/01/06 07:18:12 a1kmm Exp $
+ * $Id: hostmask.h,v 1.3 2002/04/19 10:56:14 a1kmm Exp $
*/
enum
void report_Klines(struct Client*, int temp, int mask);
void report_auth(struct Client*);
+const char *format_netmask(struct irc_inaddr *in, int bits, int type);
#ifdef IPV6
int match_ipv6(struct irc_inaddr*, struct irc_inaddr*, int);
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: s_conf.h,v 1.3 2002/01/06 07:18:13 a1kmm Exp $
+ * $Id: s_conf.h,v 1.4 2002/04/19 10:56:14 a1kmm Exp $
*/
#ifndef INCLUDED_s_conf_h
#define CONF_FLAGS_LAZY_LINK 0x00010000
#define CONF_FLAGS_ENCRYPTED 0x00020000
#define CONF_FLAGS_COMPRESSED 0x00040000
-#define CONF_FLAGS_TEMPORARY 0x00080000
-#define CONF_FLAGS_CRYPTLINK 0x00100000
+#define CONF_FLAGS_CRYPTLINK 0x00080000
+
+/* ban conf flags... */
+#define BAN_FLAGS_TEMPORARY 0x00000001
+#define BAN_FLAGS_GLINE 0x00000002
+
/* Macros for struct ConfItem */
#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP)
char *configfile;
char *klinefile;
char *dlinefile;
+ char *glineconffile;
char *glinefile;
typedef enum {
CONF_TYPE,
KLINE_TYPE,
- DLINE_TYPE
+ DLINE_TYPE,
+ GLINE_TYPE
} KlineType;
-extern void WriteKlineOrDline( KlineType, struct Client *,
- char *user, char *host, const char *reason,
- const char *oper_reason,
- const char *current_date, time_t cur_time );
-extern void add_temp_kline(struct ConfItem *);
-extern void report_temp_klines(struct Client *);
-extern void show_temp_klines(struct Client *, dlink_list *);
-extern void cleanup_tklines(void *notused);
+extern void write_ban(KlineType, struct Client *, char *user, char *host,
+ const char *reason, const char *oper_reason,
+ const char *current_date, time_t cur_time);
+extern void add_temp_kline(struct ConfItem *);
+extern void report_temp_klines(struct Client *);
+extern void show_temp_klines(struct Client *, dlink_list *);
+extern void cleanup_tklines(void *notused);
extern const char *get_conf_name(KlineType);
extern int rehash (int);
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: m_gline.c,v 1.5 2002/02/26 04:55:46 a1kmm Exp $
+ * $Id: m_gline.c,v 1.6 2002/04/19 10:56:16 a1kmm Exp $
*/
#include <assert.h>
#include "list.h"
/* internal functions */
-static void set_local_gline(const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
- const char *user,
+static void set_local_gline(struct Client *oper, const char *user,
const char *host, const char *reason);
static void log_gline_request(const char *, const char *, const char *,
static void check_majority_gline(struct Client *source_p,
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
+ struct Client *oper,
const char *user, const char *host,
const char *reason);
mod_del_cmd(gline_msgtab);
}
-char *_version = "$Revision: 1.5 $";
+char *_version = "$Revision: 1.6 $";
#endif
/*
* mo_gline()
user = parv[1]; /* here is user part */
*(host++) = '\0'; /* and now here is host */
}
+ else if (strchr(parv[1], '.') == NULL)
+ {
+ /* no ., no @, its a username... */
+ host = "*";
+ user = parv[1];
+ }
else
{
- user = "*"; /* no @ found, assume its *@somehost */
+ /* No @ but we have a . so its a host. */
+ user = "*";
host = parv[1];
}
- if (!*host) /* duh. no host found, assume its '*' host */
- host = "*";
-
- strncpy_irc(tempuser, user, USERLEN + 1); /* allow for '*' */
- tempuser[USERLEN + 1] = '\0';
- strncpy_irc(temphost, host, HOSTLEN);
- temphost[HOSTLEN] = '\0';
+ /* USERLEN + 1 to allow for '*' + full length username. */
+ strlcpy(tempuser, user, sizeof(tempuser));
+ strlcpy(temphost, host, sizeof(temphost));
user = tempuser;
host = temphost;
}
/* If at least 3 opers agree this user should be G lined then do it */
- check_majority_gline(source_p,
- source_p->name,
- (const char *)source_p->username,
- source_p->host, me.name, user, host, reason);
+ check_majority_gline(source_p, source_p, user, host, reason);
/* 4 param version for hyb-7 servers */
sendto_server(NULL, source_p, NULL, CAP_GLN | CAP_UID, NOCAPS,
* and its faked, as the oper isnt sending the gline..
* check they're real --fl_ */
/* we need acptr for LL introduction anyway -davidt */
- if ((acptr = find_server(oper_server)))
- {
- if ((acptr = find_client(oper_nick)) == NULL)
- return;
- }
- else
+ if ((acptr = find_server(oper_server)) == NULL ||
+ (acptr = find_client(oper_nick)) == NULL ||
+ strcasecmp(oper_server, acptr->servptr->name))
return;
if (invalid_gline(acptr, user, host, (char *)reason))
return;
- /* send in hyb-7 to compatable servers */
- sendto_server(client_p, acptr, NULL, CAP_GLN, NOCAPS, LL_ICLIENT,
- ":%s GLINE %s %s :%s", oper_nick, user, host, reason);
- /* hyb-6 version to the rest */
- sendto_server(client_p, NULL, NULL, NOCAPS, CAP_GLN, NOFLAGS,
- ":%s GLINE %s %s %s %s %s %s :%s",
- oper_server, oper_nick, oper_user, oper_host,
- oper_server, user, host, reason);
-
if (ConfigFileEntry.glines)
{
/* I dont like the idea of checking for x non-wildcard chars in a
if (check_wild_gline(user, host))
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s is requesting a gline without %d non-wildcard characters for [%s@%s] [%s]",
+ "%s!%s@%s on %s is requesting a gline without %u "
+ "non-wildcard characters for [%s@%s] [%s]",
oper_nick, oper_user, oper_host, oper_server,
ConfigFileEntry.min_nonwildcard, user, host,
reason);
+ sendto_one(client_p, ":%s NOTICE %s :Your GLINE of %s@%s[%s] does not "
+ "have %u non-wildcard characters. It will not take effect "
+ "behind %s. Please repeat with a more specific GLINE if "
+ "abuse continues.", me.name, oper_nick, user, host,
+ reason, ConfigFileEntry.min_nonwildcard, me.name);
return;
}
oper_host, oper_server, user, host, reason);
/* If at least 3 opers agree this user should be G lined then do it */
- check_majority_gline(source_p,
- oper_nick,
- oper_user,
- oper_host, oper_server, user, host, reason);
+ check_majority_gline(source_p, acptr, user, host, reason);
}
+ /* send in hyb-7 to compatable servers */
+ sendto_server(client_p, acptr, NULL, CAP_GLN, NOCAPS, LL_ICLIENT,
+ ":%s GLINE %s %s :%s", oper_nick, user, host, reason);
+ /* hyb-6 version to the rest */
+ sendto_server(client_p, NULL, NULL, NOCAPS, CAP_GLN, NOFLAGS,
+ ":%s GLINE %s %s %s %s %s %s :%s",
+ oper_server, oper_nick, oper_user, oper_host,
+ oper_server, user, host, reason);
}
/*
*/
static void
check_majority_gline(struct Client *source_p,
- const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
+ struct Client *oper,
const char *user, const char *host, const char *reason)
{
- if (majority_gline(source_p, oper_nick, oper_user, oper_host,
- oper_server, user, host, reason))
+ if (majority_gline(source_p, oper->name, oper->username, oper->host,
+ oper->servptr->name, user, host, reason))
{
- set_local_gline(oper_nick, oper_user, oper_host, oper_server,
- user, host, reason);
+ set_local_gline(oper, user, host, reason);
cleanup_glines();
}
}
* side effects -
*/
static void
-set_local_gline(const char *oper_nick,
- const char *oper_user,
- const char *oper_host,
- const char *oper_server,
+set_local_gline(struct Client *oper,
const char *user, const char *host, const char *reason)
{
char buffer[IRCD_BUFSIZE];
ircsprintf(buffer, "%s (%s)", reason, current_date);
DupString(aconf->passwd, buffer);
- DupString(aconf->name, (char *)user);
- DupString(aconf->host, (char *)host);
+ DupString(aconf->user, user);
+ DupString(aconf->host, host);
aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
- add_gline(aconf);
-
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]",
- oper_nick,
- oper_user, oper_host, oper_server, user, host, reason);
+ add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
+ write_ban(GLINE_TYPE, oper, aconf->user, aconf->host, aconf->passwd, "",
+ current_date, CurrentTime);
+
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s!%s@%s{%s} on %s has triggered "
+ "gline for [%s@%s] [%s]", oper->name, oper->username,
+ oper->host, get_oper_name(oper), oper->servptr->name,
+ user, host, reason);
check_klines();
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: m_kline.c,v 1.5 2002/02/26 04:55:46 a1kmm Exp $
+ * $Id: m_kline.c,v 1.6 2002/04/19 10:56:16 a1kmm Exp $
*/
#include "tools.h"
mod_del_cmd(kline_msgtab);
}
-char *_version = "$Revision: 1.5 $";
+char *_version = "$Revision: 1.6 $";
#endif
/* Local function prototypes */
const char *current_date, time_t cur_time)
{
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
- WriteKlineOrDline(KLINE_TYPE, source_p, aconf->user, aconf->host,
- reason, oper_reason, current_date, cur_time);
+ write_ban(KLINE_TYPE, source_p, aconf->user, aconf->host,
+ reason, oper_reason, current_date, cur_time);
/* Now, activate kline against current online clients */
check_klines();
}
struct Client *target_p;
#endif
struct irc_inaddr daddr;
- char cidr_form_host[HOSTLEN + 1];
struct ConfItem *aconf;
int bits, t;
char dlbuffer[1024];
}
dlhost = parv[1];
- strncpy_irc(cidr_form_host, dlhost, HOSTLEN);
- cidr_form_host[HOSTLEN] = '\0';
if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
{
-#ifdef IPV6
- sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
- me.name, parv[0]);
- return;
-#else
if (!(target_p = find_chasing(source_p, parv[1], NULL)))
return;
-
if (!target_p->user)
return;
- t = HM_IPV4;
if (IsServer(target_p))
{
sendto_one(source_p,
if (IsExemptKline(target_p))
{
sendto_one(source_p,
- ":%s NOTICE %s :%s is E-lined", me.name, parv[0],
+ ":%s NOTICE %s :%s is exempt from K-lines", me.name, parv[0],
target_p->name);
return;
}
-
- /*
- * XXX - this is always a fixed length output, we can get away
- * with strcpy here
- *
- * strncpy_irc(cidr_form_host, inetntoa((char *)&target_p->ip), 32);
- * cidr_form_host[32] = '\0';
+#ifdef IPV6
+ t = (target_p->aftype == AF_INET6) ? HM_IPV6 : HM_IPV4;
+ /* There has been some discussion amongst the coders on how wide the
+ * IPv6 mask should be, but the problem we came up with is that
+ * although many individuals have a personal /64, this could also
+ * serve several ISPs, and could hold thousands of billions of
+ * users. So I am following the v4 convention of being 8 bits less
+ * than full mask(i.e. /120)
*/
- strcpy(cidr_form_host, inetntoa((char *)&target_p->localClient->ip));
-
- if ((p = strchr(cidr_form_host, '.')) == NULL)
- return;
- /* 192. <- p */
-
- p++;
- if ((p = strchr(p, '.')) == NULL)
- return;
- /* 192.168. <- p */
-
- p++;
- if ((p = strchr(p, '.')) == NULL)
- return;
- /* 192.168.0. <- p */
-
- p++;
- *p++ = '0';
- *p++ = '/';
- *p++ = '2';
- *p++ = '4';
- *p++ = '\0';
- dlhost = cidr_form_host;
-
- bits = 0xFFFFFF00L;
-/* XXX: Fix me for IPV6 */
+ bits = (t == HM_IPV6) ? 120 : 24;
+#else
+ t = HM_IPV4;
+ bits = 24;
#endif
+ dlhost = format_netmask(&target_p->localClient->ip, bits, t);
}
}
else
{
+#ifdef IPV6
+ if (bits < (t == HM_IPV6) ? 64 : 24)
+#else
if (bits < 24)
+#endif
{
sendto_one(source_p,
":%s NOTICE %s :Dline bitmasks less than 24 are for admins only.",
/*
* Write dline to configuration file
*/
- WriteKlineOrDline(DLINE_TYPE, source_p, NULL, dlhost, reason,
- oper_reason, current_date, cur_time);
+ write_ban(DLINE_TYPE, source_p, NULL, dlhost, reason,
+ oper_reason, current_date, cur_time);
check_klines();
} /* m_dline() */
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * $Id: m_testline.c,v 1.4 2002/01/13 07:15:19 a1kmm Exp $
+ * $Id: m_testline.c,v 1.5 2002/04/19 10:56:17 a1kmm Exp $
*/
#include "handlers.h"
mod_del_cmd(testline_msgtab);
}
-char *_version = "$Revision: 1.4 $";
+char *_version = "$Revision: 1.5 $";
#endif
/*
* mo_testline
sendto_one(source_p,
":%s NOTICE %s :%c-line name [%s] host [%s] pass [%s]",
me.name, parv[0],
- (aconf->flags & CONF_FLAGS_TEMPORARY) ? 'k' : 'K',
+ (aconf->flags & BAN_FLAGS_TEMPORARY) ? 'k' : 'K',
user, host, pass);
}
else if (aconf->status & CONF_CLIENT)
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: balloc.c,v 1.5 2002/01/06 09:20:35 a1kmm Exp $
+ * $Id: balloc.c,v 1.6 2002/04/19 10:56:19 a1kmm Exp $
*/
/* A note on the algorithm:
#ifdef HAVE_MMAP /* We've got mmap() that is good */
#include <sys/mman.h>
+#if defined(MMAP_ANONYMOUS) && !defined(MMAP_ANON)
+#define MMAP_ANON MMAP_ANONYMOUS
+#endif
+
/*
* static inline void free_block(void *ptr, size_t size)
*
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: client.c,v 1.5 2002/02/26 04:55:54 a1kmm Exp $
+ * $Id: client.c,v 1.6 2002/04/19 10:56:20 a1kmm Exp $
*/
#include "tools.h"
if (IsPerson(client_p))
{
- if (ConfigFileEntry.glines &&
- (aconf = find_gkill(client_p, client_p->username)))
+ if ((aconf = find_kill(client_p)))
{
- if (IsExemptKline(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "GLINE over-ruled for %s, client is kline_exempt",
- get_client_name(client_p, HIDE_IP));
- continue;
- }
-
- if (IsExemptGline(client_p))
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "GLINE over-ruled for %s, client is gline_exempt",
- get_client_name(client_p, HIDE_IP));
- continue;
- }
-
- sendto_realops_flags(FLAGS_ALL, L_ALL, "GLINE active for %s",
- get_client_name(client_p, HIDE_IP));
-
- if (ConfigFileEntry.kline_with_connection_closed &&
- ConfigFileEntry.kline_with_reason)
- {
- reason = "Connection closed";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name,
- aconf->passwd ? aconf->passwd : "G-lined");
- }
+ char *type;
+ if (aconf->flags & BAN_FLAGS_GLINE)
+ type = "GLINE";
+ else if (aconf->flags & BAN_FLAGS_TEMPORARY)
+ type = "TKLINE";
else
- {
- if (ConfigFileEntry.kline_with_connection_closed)
- reason = "Connection closed";
- else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
- reason = aconf->passwd;
- else
- reason = "G-lined";
-
- sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name, reason);
- }
-
- (void)exit_client(client_p, client_p, &me, reason);
- /* and go examine next fd/client_p */
- continue;
- }
- else if ((aconf = find_kill(client_p)))
- {
+ type = "KLINE";
/* if there is a returned struct ConfItem.. then kill it */
if (IsExemptKline(client_p))
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
- "KLINE over-ruled for %s, client is kline_exempt",
- get_client_name(client_p, HIDE_IP));
+ "%s over-ruled for %s, client is kline_exempt",
+ type, get_client_name(client_p, HIDE_IP));
continue;
}
- sendto_realops_flags(FLAGS_ALL, L_ALL, "KLINE active for %s",
- get_client_name(client_p, HIDE_IP));
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s active for %s",
+ type, get_client_name(client_p, HIDE_IP));
if (ConfigFileEntry.kline_with_connection_closed &&
ConfigFileEntry.kline_with_reason)
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
me.name, client_p->name,
- aconf->passwd ? aconf->passwd : "K-lined");
+ aconf->passwd ? aconf->passwd : type);
}
else
{
else if (ConfigFileEntry.kline_with_reason && aconf->passwd)
reason = aconf->passwd;
else
- reason = "K-lined";
+ reason = "Banned";
sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
me.name, client_p->name, reason);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * $Id: hostmask.c,v 1.3 2002/01/06 07:18:48 a1kmm Exp $
+ * $Id: hostmask.c,v 1.4 2002/04/19 10:56:20 a1kmm Exp $
*/
#include <stdlib.h>
return HM_HOST;
}
+#define RecordHex(ptr,num)\
+{\
+ int p1 = (num & 0xF0) >> 4, p2 = num & 0xF;\
+ *ptr++ = p1 >= 0xA ? (p1 + 'A' - 0xA) : (p1 + '0')\
+ *ptr++ = p2 >= 0xA ? (p2 + 'A' - 0xA) : (p2 + '0')\
+}
+
+#define RecordDec(ptr,num)\
+{\
+ int d1 = num / 100, d2 = num / 10 % 10, d3 = num % 10;\
+ if (d1 > 0)\
+ *ptr++ = d1 + '0';\
+ if (d2 > 0)\
+ *ptr++ = d2 + '0';\
+ if (d3 > 0)\
+ *ptr++ = d3 + '0';\
+}
+
+/* Lets us display an address as CIDR. */
+/* Input: addr - an IPV4/6 address.
+ * bits - number of bits in the mask.
+ * type - HM_IPV4 or HM_IPV6
+ * Output: A pointer to a static buffer containing the formated string.
+ * Side-effects: Clobbers the pointer returned by previous calls to
+ * this function.
+ */
+const char*
+format_netmask(struct irc_inaddr *addr, int bits, int type)
+{
+ static char buffer[3 * 7 + 2 + 1 + 3 + 1];
+ char *p = buffer;
+#ifdef IPV6
+ if (type == HM_IPV6)
+ {
+ int bl = bits, i = 0;
+ if (bits > 128 || bits < 0)
+ {
+ bits = 128;
+ bl = 128;
+ }
+ while (bl >= 16)
+ {
+ RecordHex(p, addr->sins.sin6.s6_addr16[i++]);
+ if (i < 8)
+ *p++ = ':';
+ }
+ if (i < 8 && bl != 0)
+ {
+ /* Mask off the remaining bits... */
+ unsigned long n = addr->sins.sin6.s6_addr16[i++];
+ n &= ~ (1 << bl) - 1;
+ RecordHex(p, n);
+ if (i < 8)
+ *p++ = ':';
+ }
+ /* Fill in the remainder with zeros... */
+ while (i < 8)
+ {
+ *p++ = '0';
+ *p++ = '0';
+ if (++i < 8)
+ *p++ = ':';
+ }
+ if (bits < 128)
+ {
+ *p++ = '/';
+ RecordDec(p, bits);
+ }
+ *p++ = 0;
+ return buffer;
+ }
+ else
+ {
+#endif
+ int bl = bits, i = 0;
+ if (bits > 32 || bits < 0)
+ {
+ bits = 32;
+ bl = 32;
+ }
+ while (bl >= 8)
+ {
+ RecordDec(p, (addr->sins.sin.s_addr & (3<<i)) << 8 >> i++);
+ if (i < 4)
+ *p++ = '.';
+ }
+ if (i < 8 && bl != 0)
+ {
+ /* Mask off the remaining bits... */
+ unsigned long n = (addr->sins.sin.s_addr & (3<<i)) << 8 >> i++;
+ n &= ~ (1 << bl) - 1;
+ RecordDec(p, n);
+ if (i < 4)
+ *p++ = '.';
+ }
+ /* Fill in the remainder with zeros... */
+ while (i < 4)
+ {
+ *p++ = '0';
+ if (++i < 8)
+ *p++ = '.';
+ }
+ if (bits < 128)
+ {
+ *p++ = '/';
+ RecordDec(p, bits);
+ }
+ *p++ = 0;
+ return buffer;
+#ifdef IPV6
+ }
+ /* Not reached. */
+ return NULL;
+#endif
+}
+
/* The address matching stuff... */
/* int match_ipv6(struct irc_inaddr *, struct irc_inaddr *, int)
* Input: An IP address, an IP mask, the number of bits in the mask.
arecn = arec->next;
/* We keep the temporary K-lines and destroy the
* permanent ones, just to be confusing :) -A1kmm */
- if (arec->aconf->flags & CONF_FLAGS_TEMPORARY)
+ if (arec->aconf->flags & BAN_FLAGS_TEMPORARY)
{
*store_next = arec;
store_next = &arec->next;
}
else
{
- arec->aconf->flags |= CONF_ILLEGAL;
+ arec->aconf->status |= CONF_ILLEGAL;
if (!arec->aconf->clients)
free_conf(arec->aconf);
MyFree(arec);
for (arec = atable[i]; arec; arec = arec->next)
if (arec->type == CONF_KILL)
{
- if ((tkline && !((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY))
+ if ((tkline && !((aconf = arec->aconf)->flags & BAN_FLAGS_TEMPORARY))
|| (!tkline
- && ((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)))
+ && ((aconf = arec->aconf)->flags & BAN_FLAGS_TEMPORARY)))
continue;
get_printable_conf(aconf, &name, &host, &pass, &user, &port,
&classname);
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * $Id: ircd.c,v 1.6 2002/02/26 04:55:55 a1kmm Exp $
+ * $Id: ircd.c,v 1.7 2002/04/19 10:56:20 a1kmm Exp $
*/
#include <sys/types.h>
ConfigFileEntry.configfile = CPATH; /* Server configuration file */
ConfigFileEntry.klinefile = KPATH; /* Server kline file */
ConfigFileEntry.dlinefile = DLPATH; /* dline file */
+ ConfigFileEntry.glineconffile = GCPATH; /* gline conf file */
ConfigFileEntry.glinefile = GPATH; /* gline log file */
myargv = argv;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: p_irc.c,v 1.2 2002/02/26 04:55:55 a1kmm Exp $
+ * $Id: p_irc.c,v 1.3 2002/04/19 10:56:20 a1kmm Exp $
*/
#include "client.h"
/* Some special protocols are declared here... */
struct Protocol p_unregistered =
{
- NULL, /* Parent. */
- &irc_unregistered, /* Outgoing: Unregistered. */
- NULL, /* Outgoing: Registered. */
- &irc_not_oper, /* Outgoing: Not an IRC operator. */
- &irc_error, /* Incoming/Outgoing: error. */
- NULL, /* Outgoing: No such command. */
- &irc_toofew_params, /* Outgoing: Too few parameters. */
- NULL, /* Outgoing: Burst channel. */
+ m_unregistered: &irc_unregistered,
+ m_not_oper: &irc_not_oper,
+ m_error: &irc_error,
+ toofew_params: &irc_toofew_params
};
struct Protocol p_user =
{
- NULL, /* Parent. */
- NULL, /* Outgoing: Unregistered. */
- &irc_registered, /* Outgoing: Registered. */
- &irc_not_oper, /* Outgoing: Not an IRC operator. */
- NULL, /* Incoming/Outgoing: error. */
- &irc_illegal_command,/* Outgoing: No such command. */
- &irc_toofew_params, /* Outgoing: Too few parameters. */
- &usr_burst_channel, /* Outgoing: Burst channel. */
+ m_registered: &irc_registered,
+ m_not_oper: &irc_not_oper,
+ illegal_command: &irc_illegal_command,
+ toofew_params: &irc_toofew_params,
+ burst_channel: &usr_burst_channel
};
struct Protocol p_operuser =
{
- &p_user, /* Parent. */
- NULL, /* Outgoing: Unregistered. */
- &irc_registered, /* Outgoing: Registered. */
- NULL, /* Outgoing: Not an IRC operator. */
- NULL, /* Incoming/Outgoing: error. */
- &irc_illegal_command,/* Outgoing: No such command. */
- &irc_toofew_params, /* Outgoing: Too few parameters. */
- &usr_burst_channel, /* Outgoing: Burst channel. */
+ parent: &p_user,
+ m_registered: &irc_registered,
+ illegal_command: &irc_illegal_command,
+ toofew_params: &irc_toofew_params,
+ burst_channel: &usr_burst_channel
};
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: p_ts.c,v 1.1 2002/01/13 07:15:39 a1kmm Exp $
+ * $Id: p_ts.c,v 1.2 2002/04/19 10:56:20 a1kmm Exp $
*/
#include "s_protocol.h"
struct Protocol p_ts5 =
{
- NULL, /* parent */
- NULL, /* Unregistered. */
- NULL, /* Registered. */
- NULL, /* Not operator. */
- tsm_error, /* Error. */
- NULL, /* No such command. */
- NULL /* Not enough parameters. */
+ m_error: tsm_error,
+ /* burst_channel: ts_burst_channel */
};
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: s_conf.c,v 1.5 2002/02/26 04:55:55 a1kmm Exp $
+ * $Id: s_conf.c,v 1.6 2002/04/19 10:56:20 a1kmm Exp $
*/
#include <sys/types.h>
dlink_node *kill_node;
kill_node = make_dlink_node();
dlinkAdd(aconf, kill_node, &temporary_klines);
- aconf->flags |= CONF_FLAGS_TEMPORARY;
+ aconf->flags |= BAN_FLAGS_TEMPORARY;
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
}
if (kill_ptr->hold <= CurrentTime)
{
/* Alert opers that a TKline expired - Hwy */
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "Temporary K-line for [%s@%s] expired",
+ sendto_realops_flags(FLAGS_ALL, L_ALL, "%s-line for [%s@%s] expired",
+ (kill_ptr->flags & BAN_FLAGS_GLINE) ? "G"
+ : "Temporary K",
(kill_ptr->user) ? kill_ptr->user : "*",
(kill_ptr->host) ? kill_ptr->host : "*");
}
/*
- * WriteKlineOrDline
+ * write_ban
*
- * inputs - kline or dline type flag
- * - client pointer to report to
- * - user name of target
- * - host name of target
- * - reason for target
- * - time_t cur_time
- * output - NONE
- * side effects - This function takes care of
- * finding right kline or dline conf file, writing
- * the right lines to this file,
- * notifying the oper that their kline/dline is in place
- * notifying the opers on the server about the k/d line
- * forwarding the kline onto the next U lined server
- *
+ * inputs: type - type of ban
+ * source_p - client pointer to report to
+ * user - user name of target
+ * host - host name of target
+ * reason - reason for target
+ * oper_reason- reason only admins can see
+ * cur_time - time ban was placed
+ * output: none
+ * side effects: This function takes care of
+ * finding right kline or dline conf file, writing
+ * the right lines to this file,
+ * notifying the oper that their kline/dline is in place
+ * notifying the opers on the server about the k/d line
+ * forwarding the kline onto the next U lined server
*/
void
-WriteKlineOrDline(KlineType type,
- struct Client *source_p,
- char *user,
- char *host,
- const char *reason,
- const char *oper_reason,
- const char *current_date, time_t cur_time)
+write_ban(KlineType type,
+ struct Client *source_p,
+ char *user,
+ char *host,
+ const char *reason,
+ const char *oper_reason,
+ const char *current_date, time_t cur_time)
{
char buffer[1024];
FBFILE *out;
filename = get_conf_name(type);
- if (type == DLINE_TYPE)
- {
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s added D-Line for [%s] [%s]",
- get_oper_name(source_p), host, reason);
- sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
- me.name, source_p->name, host, filename);
-
- }
- else
+ if (oper_reason == NULL)
+ oper_reason = "";
+ switch (type)
{
- sendto_realops_flags(FLAGS_ALL, L_ALL,
- "%s added K-Line for [%s@%s] [%s]",
- get_oper_name(source_p), user, host, reason);
- sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
- me.name, source_p->name, user, host);
+ case DLINE_TYPE:
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s added D-Line for [%s] [%s]",
+ get_oper_name(source_p), host, reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s] to %s",
+ me.name, source_p->name, host, filename);
+ ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
+ user, host, reason, oper_reason, current_date,
+ get_oper_name(source_p), (long)cur_time);
+ break;
+ case KLINE_TYPE:
+ sendto_realops_flags(FLAGS_ALL, L_ALL,
+ "%s added K-Line for [%s@%s] [%s]",
+ get_oper_name(source_p), user, host, reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
+ me.name, source_p->name, user, host);
+ default:
+ ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n", host,
+ reason, oper_reason, current_date, get_oper_name(source_p),
+ (long)cur_time);
+ break;
}
+ /* Now actually write it... */
if ((out = fbopen(filename, "a")) == NULL)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
"*** Problem opening %s ", filename);
return;
}
-
- if (oper_reason == NULL)
- oper_reason = "";
-
- if (type == KLINE_TYPE)
- ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
- user,
- host,
- reason,
- oper_reason,
- current_date, get_oper_name(source_p), (long)cur_time);
- else
- ircsprintf(buffer, "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
- host,
- reason,
- oper_reason,
- current_date, get_oper_name(source_p), (long)cur_time);
-
-
if (fbputs(buffer, out) == -1)
{
sendto_realops_flags(FLAGS_ALL, L_ALL,
fbclose(out);
return;
}
-
fbclose(out);
if (type == KLINE_TYPE)
ilog(L_TRACE, "%s added K-Line for [%s@%s] [%s]",
source_p->name, user, host, reason);
- else
+ else if (type == DLINE_TYPE)
ilog(L_TRACE, "%s added D-Line for [%s] [%s]",
get_oper_name(source_p), host, reason);
+ /* glines have their own logging. */
}
/* get_conf_name
get_conf_name(KlineType type)
{
if (type == CONF_TYPE)
- {
- return (ConfigFileEntry.configfile);
- }
+ return ConfigFileEntry.configfile;
else if (type == KLINE_TYPE)
- {
- return (ConfigFileEntry.klinefile);
- }
-
- return (ConfigFileEntry.dlinefile);
+ return ConfigFileEntry.klinefile;
+ else if (type == GLINE_TYPE)
+ return ConfigFileEntry.glineconffile;
+ return ConfigFileEntry.dlinefile;
}
/*