* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2002-2005 ircd-ratbox development team
- * Copyright (C) 2005-2006 charybdis development team
+ * Copyright (C) 2005-2008 charybdis development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
#include "stdinc.h"
-#include "memory.h"
#include "ircd_defs.h"
#include "s_conf.h"
#include "hostmask.h"
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
}
+/* void find_exact_conf_by_address(const char*, int, const char *)
+ * Input:
+ * Output: ConfItem if found
+ * Side-effects: None
+ */
+struct ConfItem *
+find_exact_conf_by_address(const char *address, int type, const char *username)
+{
+ int masktype, bits;
+ unsigned long hv;
+ struct AddressRec *arec;
+ struct irc_sockaddr_storage addr;
+
+ if(address == NULL)
+ address = "/NOMATCH!/";
+ arec = rb_malloc(sizeof(struct AddressRec));
+ masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
+#ifdef IPV6
+ if(masktype == HM_IPV6)
+ {
+ /* We have to do this, since we do not re-hash for every bit -A1kmm. */
+ hv = hash_ipv6((struct sockaddr *)&addr, bits - bits % 16);
+ }
+ else
+#endif
+ if(masktype == HM_IPV4)
+ {
+ /* We have to do this, since we do not re-hash for every bit -A1kmm. */
+ hv = hash_ipv4((struct sockaddr *)&addr, bits - bits % 8);
+ }
+ else
+ {
+ hv = get_mask_hash(address);
+ }
+ for (arec = atable[hv]; arec; arec = arec->next)
+ {
+ if (arec->type == type &&
+ arec->masktype == masktype &&
+ (arec->username == NULL || username == NULL ? arec->username == username : !irccmp(arec->username, username)))
+ {
+ if (masktype == HM_HOST)
+ {
+ if (!irccmp(arec->Mask.hostname, address))
+ return arec->aconf;
+ }
+ else
+ {
+ if (arec->Mask.ipa.bits == bits &&
+ comp_with_mask_sock((struct sockaddr *)&arec->Mask.ipa.addr, (struct sockaddr *)&addr, bits))
+ return arec->aconf;
+ }
+ }
+ }
+ return NULL;
+}
+
/* void add_conf_by_address(const char*, int, const char *,
* struct ConfItem *aconf)
* Input:
if(address == NULL)
address = "/NOMATCH!/";
- arec = MyMalloc(sizeof(struct AddressRec));
+ arec = rb_malloc(sizeof(struct AddressRec));
masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits);
arec->Mask.ipa.bits = bits;
arec->masktype = masktype;
aconf->status |= CONF_ILLEGAL;
if(!aconf->clients)
free_conf(aconf);
- MyFree(arec);
+ rb_free(arec);
return;
}
arecl = arec;
arec->aconf->status |= CONF_ILLEGAL;
if(!arec->aconf->clients)
free_conf(arec->aconf);
- MyFree(arec);
+ rb_free(arec);
}
}
*store_next = NULL;
arec->aconf->status |= CONF_ILLEGAL;
if(!arec->aconf->clients)
free_conf(arec->aconf);
- MyFree(arec);
+ rb_free(arec);
}
}
*store_next = NULL;
prefix_ptr = prefix_of_host;
if(IsNoTilde(aconf))
*prefix_ptr++ = '-';
- if(IsLimitIp(aconf))
- *prefix_ptr++ = '!';
if(IsNeedIdentd(aconf))
*prefix_ptr++ = '+';
- if(IsPassIdentd(aconf))
- *prefix_ptr++ = '$';
- if(IsNoMatchIp(aconf))
- *prefix_ptr++ = '%';
if(IsConfDoSpoofIp(aconf))
*prefix_ptr++ = '=';
- if(MyOper(sptr) && IsConfExemptKline(aconf))
+ if(IsOper(sptr) && IsConfExemptFlood(aconf))
+ *prefix_ptr++ = '|';
+ if(IsOper(sptr) && IsConfExemptGline(aconf) && !IsConfExemptKline(aconf))
+ *prefix_ptr++ = '_';
+ if(IsOper(sptr) && IsConfExemptDNSBL(aconf) && !IsConfExemptKline(aconf))
+ *prefix_ptr++ = '$';
+ if(IsOper(sptr) && IsConfExemptKline(aconf))
*prefix_ptr++ = '^';
- if(MyOper(sptr) && IsConfExemptLimits(aconf))
+ if(IsOper(sptr) && IsConfExemptLimits(aconf))
*prefix_ptr++ = '>';
- if(MyOper(sptr) && IsConfIdlelined(aconf))
- *prefix_ptr++ = '<';
*prefix_ptr = '\0';
strncpy(prefix_ptr, name, USERLEN);
return (prefix_of_host);
{
aconf = arec->aconf;
- if(!MyOper(client_p) && IsConfDoSpoofIp(aconf))
+ if(!IsOper(client_p) && IsConfDoSpoofIp(aconf))
continue;
get_printable_conf(aconf, &name, &host, &pass, &user, &port,