2 * @brief ircd configuration file API.
3 * @version $Id: s_conf.h 1462 2005-08-21 13:46:08Z entrope $
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 */
36 #define CONF_SECURE 0x0002 /**< Secure connection */
38 /** Indicates ConfItem types that count associated clients. */
39 #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
41 /** Checks whether the CONF_ILLEGAL bit is set on \a x. */
42 #define IsIllegal(x) ((x)->status & CONF_ILLEGAL)
48 /** Configuration item to limit peer or client access. */
51 struct ConfItem *next; /**< Next ConfItem in #GlobalConfList */
52 unsigned int status; /**< Set of CONF_* bits. */
53 unsigned int clients; /**< Number of *LOCAL* clients using this */
54 unsigned int maximum; /**< For CONF_SERVER, max hops.
55 For CONF_CLIENT, max connects per IP. */
56 struct ConnectionClass *conn_class; /**< Class of connection */
57 struct irc_sockaddr origin; /**< Local address for outbound connections */
58 struct irc_sockaddr address; /**< IP and port */
59 char *username; /**< For CONF_CLIENT and CONF_OPERATOR, username mask. */
60 char *host; /**< Peer hostname */
61 char *origin_name; /**< Text form of origin address */
62 char *passwd; /**< Password field */
63 char *name; /**< Name of peer */
64 char *hub_limit; /**< Mask that limits servers allowed behind
66 time_t hold; /**< Earliest time to attempt an outbound
67 connect on this ConfItem. */
68 int dns_pending; /**< A dns request is pending. */
69 int flags; /**< Additional modifiers for item. */
70 int addrbits; /**< Number of bits valid in ConfItem::address. */
71 struct Privs privs; /**< Privileges for opers. */
72 /** Used to detect if a privilege has been set by this ConfItem. */
73 struct Privs privs_dirty;
76 /** Channel quarantine structure. */
79 struct qline *next; /**< Next qline in #GlobalQuarantineList. */
80 char *chname; /**< Quarantined channel name. */
81 char *reason; /**< Reason for quarantine. */
84 /** Local K-line structure. */
86 struct DenyConf* next; /**< Next DenyConf in #denyConfList. */
87 char* hostmask; /**< Mask for IP or hostname. */
88 char* message; /**< Message to send to denied users. */
89 char* usermask; /**< Mask for client's username. */
90 char* realmask; /**< Mask for realname. */
91 struct irc_in_addr address; /**< Address for IP-based denies. */
92 unsigned int flags; /**< Interpretation flags for the above. */
93 unsigned char bits; /**< Number of bits for ipkills */
96 #define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
98 /** Local server configuration. */
100 char* name; /**< Name of server. */
101 char* description; /**< Description of server. */
102 unsigned int numeric; /**< Globally assigned server numnick. */
103 char* location1; /**< First line of location information. */
104 char* location2; /**< Second line of location information. */
105 char* contact; /**< Admin contact information. */
109 CRULE_AUTO = 1, /**< CRule applies to automatic connections. */
110 CRULE_ALL = 2, /**< CRule applies to oper-requested connections. */
114 /** Connection rule configuration. */
116 struct CRuleConf* next; /**< Next CRule in cruleConfList. */
117 char* hostmask; /**< Mask of affected server names. */
118 char* rule; /**< Text version of the rule. */
119 int type; /**< One of CRULE_AUTO or CRULE_ALL. */
120 struct CRuleNode* node; /**< Parsed form of the rule. */
123 /** Authorization check result. */
124 enum AuthorizationCheckResult {
125 ACR_OK, /**< User accepted. */
126 ACR_NO_AUTHORIZATION, /**< No matching ConfItem for the user. */
127 ACR_TOO_MANY_IN_CLASS, /**< Connection class was already full. */
128 ACR_TOO_MANY_FROM_IP, /**< User's IP already has max connections. */
129 ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */
130 ACR_BAD_SOCKET /**< Client has bad file descriptor. */
133 /** Target description for service commands. */
135 struct nick_host *next; /**< Next nick_host struct in struct s_map. */
136 int nicklen; /**< offset of @ part of server string */
137 char nick[1]; /**< start of nick\@server string */
140 #define SMAP_FAST 1 /**< Command does not have MFLG_SLOW. */
142 /** Target set for a service pseudo-command. */
144 struct s_map *next; /**< Next element in #GlobalServiceMapList. */
145 struct Message *msg; /**< Message element formed for this mapping. */
146 char *name; /**< Text name of the mapping. */
147 char *command; /**< Command name to use. */
148 char *prepend; /**< Extra text to prepend to user's text. */
149 unsigned int flags; /**< Bitwise map of SMAP_* flags. */
150 struct nick_host *services; /**< Linked list of possible targets. */
153 /** WebIRC config types. */
154 #define WEBIRC_PASS 0 /**< Password the webirc has to send. */
155 #define WEBIRC_HOST 1 /**< Host/IP mask which must match to the webirc socket. */
156 #define WEBIRC_SPOOF 2 /**< Host/IP mask which must match the spoofed ip. */
158 /** WebIRC config node */
163 struct webirc_node *next, *prev;
166 /** WebIRC config list */
167 struct webirc_block {
168 char name[NICKLEN + 1]; /**< name of the block */
169 struct webirc_node *list; /**< list of entries: circular double linked list;
170 NULL if empty; list itself is the first node
171 sorted by type (ascending) */
172 struct webirc_block *next, *prev;
179 extern struct ConfItem* GlobalConfList;
180 extern int GlobalConfCount;
181 extern struct s_map* GlobalServiceMapList;
182 extern struct qline* GlobalQuarantineList;
183 extern char * GlobalForwards[256];
185 /* WebIRC config list.
186 * - circular double linked list
187 * - NULL if no node present
188 * - the list itself is the first node
190 extern struct webirc_block *GlobalWebIRCConf;
196 extern int init_conf(void);
198 extern const struct LocalConf* conf_get_local(void);
199 extern const struct CRuleConf* conf_get_crule_list(void);
200 extern const struct DenyConf* conf_get_deny_list(void);
202 extern struct webirc_block *webirc_block();
203 extern void webirc_establish(struct webirc_block *block);
204 extern void webirc_set(struct webirc_block *block, unsigned int type, const char *content, unsigned int len, unsigned int neg);
205 extern void webirc_list_clear(struct webirc_block *block);
206 extern void webirc_clear();
208 extern const char* conf_eval_crule(const char* name, int mask);
210 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
211 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
212 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
213 extern struct ConfItem* conf_find_server(const char* name);
215 extern void det_confs_butmask(struct Client *cptr, int mask);
216 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
217 extern struct ConfItem* find_conf_exact(const char* name, struct Client *cptr, int statmask);
218 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
219 extern int conf_check_server(struct Client *cptr);
220 extern int rehash(struct Client *cptr, int sig);
221 extern int find_kill(struct Client *cptr);
222 extern const char *find_quarantine(const char* chname);
223 extern void lookup_confhost(struct ConfItem *aconf);
224 extern void conf_parse_userhost(struct ConfItem *aconf, char *host);
225 extern struct ConfItem *conf_debug_iline(const char *client);
226 extern void free_mapping(struct s_map *smap);
228 extern void yyerror(const char *msg);
230 #endif /* INCLUDED_s_conf_h */