2007-01-25 06:40:21 +00:00
|
|
|
/*
|
|
|
|
* charybdis: an advanced Internet Relay Chat Daemon(ircd).
|
|
|
|
* hostmask.h: A header for the hostmask code.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2004 ircd-ratbox development team
|
|
|
|
* Copyright (C) 2005-2006 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDE_hostmask_h
|
|
|
|
#define INCLUDE_hostmask_h 1
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HM_HOST,
|
2017-08-18 12:03:59 +00:00
|
|
|
HM_IPV4,
|
|
|
|
HM_IPV6,
|
2007-01-25 06:40:21 +00:00
|
|
|
};
|
|
|
|
|
2015-04-20 05:55:20 +00:00
|
|
|
int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
|
2007-01-25 06:40:21 +00:00
|
|
|
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
|
|
|
|
const char *orighost, struct sockaddr *,
|
2008-06-26 06:18:58 +00:00
|
|
|
int, int, const char *, const char *);
|
2007-11-28 22:59:49 +00:00
|
|
|
struct ConfItem *find_exact_conf_by_address(const char *address, int type,
|
|
|
|
const char *username);
|
2008-06-26 06:18:58 +00:00
|
|
|
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
|
2007-01-25 06:40:21 +00:00
|
|
|
void delete_one_address_conf(const char *, struct ConfItem *);
|
|
|
|
void clear_out_address_conf(void);
|
|
|
|
void clear_out_address_conf_bans(void);
|
|
|
|
void init_host_hash(void);
|
2014-03-03 04:25:47 +00:00
|
|
|
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
|
2007-01-25 06:40:21 +00:00
|
|
|
const char *, const char *, struct sockaddr *,
|
2008-06-26 06:18:58 +00:00
|
|
|
int, char *);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-02 15:37:50 +00:00
|
|
|
struct ConfItem *find_dline(struct sockaddr *, int);
|
|
|
|
|
2020-04-13 22:51:52 +00:00
|
|
|
#define find_kline(x) ((IsConfDoSpoofIp((x)->localClient->att_conf) && IsConfKlineSpoof((x)->localClient->att_conf)) ? \
|
|
|
|
find_conf_by_address((x)->orighost, NULL, NULL, NULL, CONF_KILL, AF_INET, (x)->username, NULL) : \
|
|
|
|
find_conf_by_address((x)->host, (x)->sockhost, (x)->orighost, \
|
2007-01-25 06:40:21 +00:00
|
|
|
(struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\
|
2016-03-20 06:55:31 +00:00
|
|
|
GET_SS_FAMILY(&(x)->localClient->ip), (x)->username, NULL))
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
void report_auth(struct Client *);
|
|
|
|
int match_ipv6(struct sockaddr *, struct sockaddr *, int);
|
|
|
|
int match_ipv4(struct sockaddr *, struct sockaddr *, int);
|
|
|
|
|
|
|
|
/* Hashtable stuff... */
|
|
|
|
#define ATABLE_SIZE 0x1000 /* 2^12 */
|
|
|
|
#define ATABLE_BITS (32-12)
|
|
|
|
|
|
|
|
extern struct AddressRec *atable[ATABLE_SIZE];
|
|
|
|
|
|
|
|
struct AddressRec
|
|
|
|
{
|
|
|
|
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
|
|
|
|
int masktype;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/* Pointer into ConfItem... -A1kmm */
|
2008-04-02 15:57:37 +00:00
|
|
|
struct rb_sockaddr_storage addr;
|
2007-01-25 06:40:21 +00:00
|
|
|
int bits;
|
|
|
|
}
|
|
|
|
ipa;
|
|
|
|
|
|
|
|
/* Pointer into ConfItem... -A1kmm */
|
|
|
|
const char *hostname;
|
|
|
|
}
|
|
|
|
Mask;
|
|
|
|
|
|
|
|
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
|
|
|
|
int type;
|
|
|
|
|
|
|
|
/* Higher precedences overrule lower ones... */
|
|
|
|
unsigned long precedence;
|
|
|
|
|
|
|
|
/* Only checked if !(type & 1)... */
|
|
|
|
const char *username;
|
2008-06-26 06:18:58 +00:00
|
|
|
/* Only checked if type == CONF_CLIENT */
|
|
|
|
const char *auth_user;
|
2007-01-25 06:40:21 +00:00
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
|
|
|
/* The next record in this hash bucket. */
|
|
|
|
struct AddressRec *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* INCLUDE_hostmask_h */
|