6 #ifndef INCLUDED_s_conf_h
7 #define INCLUDED_s_conf_h
8 #ifndef INCLUDED_time_h
9 #include <time.h> /* struct tm */
10 #define INCLUDED_time_h
12 #ifndef INCLUDED_sys_types_h
13 #include <sys/types.h>
14 #define INCLUDED_sys_types_h
26 /*-----------------------------------------------------------------------------
30 #define CONF_ILLEGAL 0x80000000 /**< Delete the ConfItem when no remaining clients. */
31 #define CONF_CLIENT 0x0002 /**< ConfItem describes a Client block */
32 #define CONF_SERVER 0x0004 /**< ConfItem describes a Connect block */
33 #define CONF_OPERATOR 0x0020 /**< ConfItem describes an Operator block */
34 #define CONF_LEAF 0x1000 /**< ConfItem describes a Server leaf */
35 #define CONF_HUB 0x4000 /**< ConfItem describes a Server hub */
36 #define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld server */
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 struct ConnectionClass *conn_class; /**< Class of connection */
55 struct irc_sockaddr origin; /**< local address for outbound connections */
56 struct irc_sockaddr address; /**< ip and port */
57 char *host; /**< peer hostname */
58 char *origin_name; /**< text form of origin address */
59 char *passwd; /**< password field */
60 char *name; /**< name of peer */
61 time_t hold; /**< Earliest time to attempt an outbound connect on this ConfItem. */
62 int dns_pending; /**< a dns request is pending */
63 unsigned char bits; /**< Number of bits for ipkills. */
64 struct Privs privs; /**< Priviledges for opers. */
65 /** Used to detect if a privilege has been set by this ConfItem. */
66 struct Privs privs_dirty;
69 /** Channel quarantine structure. */
72 struct qline *next; /**< Next qline in #GlobalQuarantineList. */
73 char *chname; /**< Quarantined channel name. */
74 char *reason; /**< Reason for quarantine. */
77 /** Local K-line structure. */
79 struct DenyConf* next; /**< Next DenyConf in #denyConfList. */
80 char* hostmask; /**< Mask for realname, IP or hostname. */
81 char* message; /**< Message to send to denied users. */
82 char* usermask; /**< Mask for client's username. */
83 struct irc_in_addr address; /**< Address for IP-based denies. */
84 unsigned int flags; /**< Interpretation flags for the above. */
85 unsigned char bits; /**< Number of bits for ipkills */
88 #define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */
89 #define DENY_FLAGS_IP 0x0002 /**< K-line by IP address */
90 #define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */
92 /** Local server configuration. */
94 char* name; /**< Name of server. */
95 char* description; /**< Description of server. */
96 unsigned int numeric; /**< Globally assigned server numnick. */
97 char* location1; /**< First line of location information. */
98 char* location2; /**< Second line of location information. */
99 char* contact; /**< Admin contact information. */
103 CRULE_AUTO = 1, /**< CRule applies to automatic connections. */
104 CRULE_ALL = 2, /**< CRule applies to oper-requested connections. */
108 /** Connection rule configuration. */
110 struct CRuleConf* next; /**< Next CRule in cruleConfList. */
111 char* hostmask; /**< Mask of affected server names. */
112 char* rule; /**< Text version of the rule. */
113 int type; /**< One of CRULE_AUTO or CRULE_ALL. */
114 struct CRuleNode* node; /**< Parsed form of the rule. */
117 /** Authorization check result. */
118 enum AuthorizationCheckResult {
119 ACR_OK, /**< User accepted. */
120 ACR_NO_AUTHORIZATION, /**< No matching ConfItem for the user. */
121 ACR_TOO_MANY_IN_CLASS, /**< Connection class was already full. */
122 ACR_TOO_MANY_FROM_IP, /**< User's IP already has max connections. */
123 ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */
124 ACR_BAD_SOCKET /**< Client has bad file descriptor. */
127 /** Target description for service commands. */
129 struct nick_host *next; /**< Next nick_host struct in struct s_map. */
130 int nicklen; /**< offset of @ part of server string */
131 char nick[1]; /**< start of nick@server string */
134 /** Target set for a service pseudo-command. */
136 struct s_map *next; /**< Next element in #GlobalServiceMapList. */
137 struct Message *msg; /**< Message element formed for this mapping. */
138 char *name; /**< Text name of the mapping. */
139 char *command; /**< Command name to use. */
140 char *prepend; /**< Extra text to prepend to user's text. */
141 struct nick_host *services; /**< Linked list of possible targets. */
148 extern struct ConfItem* GlobalConfList;
149 extern int GlobalConfCount;
150 extern struct s_map* GlobalServiceMapList;
151 extern struct qline* GlobalQuarantineList;
157 extern int init_conf(void);
159 extern const struct LocalConf* conf_get_local(void);
160 extern const struct CRuleConf* conf_get_crule_list(void);
161 extern const struct DenyConf* conf_get_deny_list(void);
163 extern const char* conf_eval_crule(const char* name, int mask);
165 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
166 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
167 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
168 extern struct ConfItem* conf_find_server(const char* name);
170 extern void det_confs_butmask(struct Client *cptr, int mask);
171 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
172 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
173 const char* host, int statmask);
174 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
175 extern int conf_check_server(struct Client *cptr);
176 extern struct ConfItem* find_conf_name(const char* name, int statmask);
177 extern int rehash(struct Client *cptr, int sig);
178 extern void read_tlines(void);
179 extern int find_kill(struct Client *cptr);
180 extern int find_restrict(struct Client *cptr);
181 extern const char *find_quarantine(const char* chname);
182 extern void lookup_confhost(struct ConfItem *aconf);
184 extern void yyerror(const char *msg);
186 #endif /* INCLUDED_s_conf_h */