2 * @brief ircd configuration file API.
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_LEAF 0x1000 /**< ConfItem describes a Server leaf */
34 #define CONF_HUB 0x4000 /**< ConfItem describes a Server hub */
35 #define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld 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 struct ConnectionClass *conn_class; /**< Class of connection */
54 struct irc_sockaddr origin; /**< local address for outbound connections */
55 struct irc_sockaddr address; /**< ip and port */
56 char *host; /**< peer hostname */
57 char *origin_name; /**< text form of origin address */
58 char *passwd; /**< password field */
59 char *name; /**< name of peer */
60 time_t hold; /**< Earliest time to attempt an outbound connect on this ConfItem. */
61 int dns_pending; /**< a dns request is pending */
62 unsigned char bits; /**< Number of bits for ipkills. */
63 struct Privs privs; /**< Priviledges for opers. */
64 /** Used to detect if a privilege has been set by this ConfItem. */
65 struct Privs privs_dirty;
68 /** Channel quarantine structure. */
71 struct qline *next; /**< Next qline in #GlobalQuarantineList. */
72 char *chname; /**< Quarantined channel name. */
73 char *reason; /**< Reason for quarantine. */
76 /** Local K-line structure. */
78 struct DenyConf* next; /**< Next DenyConf in #denyConfList. */
79 char* hostmask; /**< Mask for realname, IP or hostname. */
80 char* message; /**< Message to send to denied users. */
81 char* usermask; /**< Mask for client's username. */
82 struct irc_in_addr address; /**< Address for IP-based denies. */
83 unsigned int flags; /**< Interpretation flags for the above. */
84 unsigned char bits; /**< Number of bits for ipkills */
87 #define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
88 #define DENY_FLAGS_IP 0x0002 /**< K-line by IP address */
89 #define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */
91 /** Local server configuration. */
93 char* name; /**< Name of server. */
94 char* description; /**< Description of server. */
95 unsigned int numeric; /**< Globally assigned server numnick. */
96 char* location1; /**< First line of location information. */
97 char* location2; /**< Second line of location information. */
98 char* contact; /**< Admin contact information. */
102 CRULE_AUTO = 1, /**< CRule applies to automatic connections. */
103 CRULE_ALL = 2, /**< CRule applies to oper-requested connections. */
107 /** Connection rule configuration. */
109 struct CRuleConf* next; /**< Next CRule in cruleConfList. */
110 char* hostmask; /**< Mask of affected server names. */
111 char* rule; /**< Text version of the rule. */
112 int type; /**< One of CRULE_AUTO or CRULE_ALL. */
113 struct CRuleNode* node; /**< Parsed form of the rule. */
116 /** Authorization check result. */
117 enum AuthorizationCheckResult {
118 ACR_OK, /**< User accepted. */
119 ACR_NO_AUTHORIZATION, /**< No matching ConfItem for the user. */
120 ACR_TOO_MANY_IN_CLASS, /**< Connection class was already full. */
121 ACR_TOO_MANY_FROM_IP, /**< User's IP already has max connections. */
122 ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */
123 ACR_BAD_SOCKET /**< Client has bad file descriptor. */
126 /** Target description for service commands. */
128 struct nick_host *next; /**< Next nick_host struct in struct s_map. */
129 int nicklen; /**< offset of @ part of server string */
130 char nick[1]; /**< start of nick\@server string */
133 /** Target set for a service pseudo-command. */
135 struct s_map *next; /**< Next element in #GlobalServiceMapList. */
136 struct Message *msg; /**< Message element formed for this mapping. */
137 char *name; /**< Text name of the mapping. */
138 char *command; /**< Command name to use. */
139 char *prepend; /**< Extra text to prepend to user's text. */
140 struct nick_host *services; /**< Linked list of possible targets. */
147 extern struct ConfItem* GlobalConfList;
148 extern int GlobalConfCount;
149 extern struct s_map* GlobalServiceMapList;
150 extern struct qline* GlobalQuarantineList;
156 extern int init_conf(void);
158 extern const struct LocalConf* conf_get_local(void);
159 extern const struct CRuleConf* conf_get_crule_list(void);
160 extern const struct DenyConf* conf_get_deny_list(void);
162 extern const char* conf_eval_crule(const char* name, int mask);
164 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
165 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
166 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
167 extern struct ConfItem* conf_find_server(const char* name);
169 extern void det_confs_butmask(struct Client *cptr, int mask);
170 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
171 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
172 const char* host, int statmask);
173 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
174 extern int conf_check_server(struct Client *cptr);
175 extern struct ConfItem* find_conf_name(const char* name, int statmask);
176 extern int rehash(struct Client *cptr, int sig);
177 extern void read_tlines(void);
178 extern int find_kill(struct Client *cptr);
179 extern int find_restrict(struct Client *cptr);
180 extern const char *find_quarantine(const char* chname);
181 extern void lookup_confhost(struct ConfItem *aconf);
183 extern void yyerror(const char *msg);
185 #endif /* INCLUDED_s_conf_h */