]>
jfr.im git - irc/quakenet/snircd.git/blob - include/s_conf.h
2 * @brief ircd configuration file API.
3 * @version $Id: s_conf.h,v 1.34 2005/08/21 13:46:07 entrope Exp $
5 #ifndef INCLUDED_s_conf_h
6 #define INCLUDED_s_conf_h
7 #ifndef INCLUDED_time_h
8 #include <time.h> /* struct tm */
9 #define INCLUDED_time_h
11 #ifndef INCLUDED_sys_types_h
12 #include <sys/types.h>
13 #define INCLUDED_sys_types_h
25 /*-----------------------------------------------------------------------------
29 #define CONF_ILLEGAL 0x80000000 /**< Delete the ConfItem when no remaining clients. */
30 #define CONF_CLIENT 0x0002 /**< ConfItem describes a Client block */
31 #define CONF_SERVER 0x0004 /**< ConfItem describes a Connect block */
32 #define CONF_OPERATOR 0x0020 /**< ConfItem describes an Operator block */
33 #define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld server */
35 #define CONF_AUTOCONNECT 0x0001 /**< Autoconnect to a server */
37 /** Indicates ConfItem types that count associated clients. */
38 #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
40 /** Checks whether the CONF_ILLEGAL bit is set on \a x. */
41 #define IsIllegal(x) ((x)->status & CONF_ILLEGAL)
47 /** Configuration item to limit peer or client access. */
50 struct ConfItem
*next
; /**< Next ConfItem in #GlobalConfList */
51 unsigned int status
; /**< Set of CONF_* bits. */
52 unsigned int clients
; /**< Number of *LOCAL* clients using this */
53 unsigned int maximum
; /**< For CONF_SERVER, max hops.
54 For CONF_CLIENT, max connects per IP. */
55 struct ConnectionClass
*conn_class
; /**< Class of connection */
56 struct irc_sockaddr origin
; /**< Local address for outbound connections */
57 struct irc_sockaddr address
; /**< IP and port */
58 char *username
; /**< For CONF_CLIENT and CONF_OPERATOR, username mask. */
59 char *host
; /**< Peer hostname */
60 char *origin_name
; /**< Text form of origin address */
61 char *passwd
; /**< Password field */
62 char *name
; /**< Name of peer */
63 char *hub_limit
; /**< Mask that limits servers allowed behind
65 time_t hold
; /**< Earliest time to attempt an outbound
66 connect on this ConfItem. */
67 int dns_pending
; /**< A dns request is pending. */
68 int flags
; /**< Additional modifiers for item. */
69 int addrbits
; /**< Number of bits valid in ConfItem::address. */
70 struct Privs privs
; /**< Privileges for opers. */
71 /** Used to detect if a privilege has been set by this ConfItem. */
72 struct Privs privs_dirty
;
75 /** Channel quarantine structure. */
78 struct qline
*next
; /**< Next qline in #GlobalQuarantineList. */
79 char *chname
; /**< Quarantined channel name. */
80 char *reason
; /**< Reason for quarantine. */
83 /** Local K-line structure. */
85 struct DenyConf
* next
; /**< Next DenyConf in #denyConfList. */
86 char* hostmask
; /**< Mask for IP or hostname. */
87 char* message
; /**< Message to send to denied users. */
88 char* usermask
; /**< Mask for client's username. */
89 char* realmask
; /**< Mask for realname. */
90 struct irc_in_addr address
; /**< Address for IP-based denies. */
91 unsigned int flags
; /**< Interpretation flags for the above. */
92 unsigned char bits
; /**< Number of bits for ipkills */
95 #define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
97 /** Local server configuration. */
99 char* name
; /**< Name of server. */
100 char* description
; /**< Description of server. */
101 unsigned int numeric
; /**< Globally assigned server numnick. */
102 char* location1
; /**< First line of location information. */
103 char* location2
; /**< Second line of location information. */
104 char* contact
; /**< Admin contact information. */
108 CRULE_AUTO
= 1, /**< CRule applies to automatic connections. */
109 CRULE_ALL
= 2, /**< CRule applies to oper-requested connections. */
113 /** Connection rule configuration. */
115 struct CRuleConf
* next
; /**< Next CRule in cruleConfList. */
116 char* hostmask
; /**< Mask of affected server names. */
117 char* rule
; /**< Text version of the rule. */
118 int type
; /**< One of CRULE_AUTO or CRULE_ALL. */
119 struct CRuleNode
* node
; /**< Parsed form of the rule. */
122 /** Authorization check result. */
123 enum AuthorizationCheckResult
{
124 ACR_OK
, /**< User accepted. */
125 ACR_NO_AUTHORIZATION
, /**< No matching ConfItem for the user. */
126 ACR_TOO_MANY_IN_CLASS
, /**< Connection class was already full. */
127 ACR_TOO_MANY_FROM_IP
, /**< User's IP already has max connections. */
128 ACR_ALREADY_AUTHORIZED
, /**< User already had an attached ConfItem. */
129 ACR_BAD_SOCKET
/**< Client has bad file descriptor. */
132 /** Target description for service commands. */
134 struct nick_host
*next
; /**< Next nick_host struct in struct s_map. */
135 int nicklen
; /**< offset of @ part of server string */
136 char nick
[1]; /**< start of nick\@server string */
139 #define SMAP_FAST 1 /**< Command does not have MFLG_SLOW. */
141 /** Target set for a service pseudo-command. */
143 struct s_map
*next
; /**< Next element in #GlobalServiceMapList. */
144 struct Message
*msg
; /**< Message element formed for this mapping. */
145 char *name
; /**< Text name of the mapping. */
146 char *command
; /**< Command name to use. */
147 char *prepend
; /**< Extra text to prepend to user's text. */
148 unsigned int flags
; /**< Bitwise map of SMAP_* flags. */
149 struct nick_host
*services
; /**< Linked list of possible targets. */
156 extern struct ConfItem
* GlobalConfList
;
157 extern int GlobalConfCount
;
158 extern struct s_map
* GlobalServiceMapList
;
159 extern struct qline
* GlobalQuarantineList
;
165 extern int init_conf(void);
167 extern const struct LocalConf
* conf_get_local(void);
168 extern const struct CRuleConf
* conf_get_crule_list(void);
169 extern const struct DenyConf
* conf_get_deny_list(void);
171 extern const char* conf_eval_crule(const char* name
, int mask
);
173 extern struct ConfItem
* attach_confs_byhost(struct Client
* cptr
, const char* host
, int statmask
);
174 extern struct ConfItem
* find_conf_byhost(struct SLink
* lp
, const char* host
, int statmask
);
175 extern struct ConfItem
* find_conf_byname(struct SLink
* lp
, const char *name
, int statmask
);
176 extern struct ConfItem
* conf_find_server(const char* name
);
178 extern void det_confs_butmask(struct Client
*cptr
, int mask
);
179 extern enum AuthorizationCheckResult
attach_conf(struct Client
*cptr
, struct ConfItem
*aconf
);
180 extern struct ConfItem
* find_conf_exact(const char* name
, struct Client
*cptr
, int statmask
);
181 extern enum AuthorizationCheckResult
conf_check_client(struct Client
*cptr
);
182 extern int conf_check_server(struct Client
*cptr
);
183 extern int rehash(struct Client
*cptr
, int sig
);
184 extern int find_kill(struct Client
*cptr
, int glinecheck
);
185 extern const char *find_quarantine(const char* chname
);
186 extern void lookup_confhost(struct ConfItem
*aconf
);
187 extern void conf_parse_userhost(struct ConfItem
*aconf
, char *host
);
188 extern struct ConfItem
*conf_debug_iline(const char *client
);
189 extern void free_mapping(struct s_map
*smap
);
191 extern void yyerror(const char *msg
);
193 #endif /* INCLUDED_s_conf_h */