X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=include%2Fs_conf.h;h=ea4f1c21706066755795585fd2702ac166c2f844;hb=e22c93b27e9f501b7869b310dff7df384e06f7e6;hp=5059efd973cca1af425f0947e4dbdc1985f4196b;hpb=76cd4fa92d8e9e6fa8630cfeacf6da5c4586c9da;p=ircu2.10.12-pk.git diff --git a/include/s_conf.h b/include/s_conf.h index 5059efd..ea4f1c2 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -1,7 +1,6 @@ -/* - * s_conf.h - * - * $Id$ +/** @file s_conf.h + * @brief ircd configuration file API. + * @version $Id$ */ #ifndef INCLUDED_s_conf_h #define INCLUDED_s_conf_h @@ -13,16 +12,11 @@ #include #define INCLUDED_sys_types_h #endif -#ifndef INCLUDED_netinet_in_h -#include /* struct in_addr */ -#define INCLUDED_netinet_in_h -#endif +#include "client.h" struct Client; struct SLink; -struct TRecord; -struct hostent; - +struct Message; /* * General defines @@ -32,124 +26,168 @@ struct hostent; * Macros */ -#define CONF_ILLEGAL 0x80000000 -#define CONF_MATCH 0x40000000 -#define CONF_CLIENT 0x0002 -#define CONF_SERVER 0x0004 -#define CONF_LOCOP 0x0010 -#define CONF_OPERATOR 0x0020 -#define CONF_ME 0x0040 -#define CONF_KILL 0x0080 -#define CONF_ADMIN 0x0100 -#define CONF_CLASS 0x0400 -#define CONF_LEAF 0x1000 -#define CONF_LISTEN_PORT 0x2000 -#define CONF_HUB 0x4000 -#define CONF_UWORLD 0x8000 -#define CONF_CRULEALL 0x00200000 -#define CONF_CRULEAUTO 0x00400000 -#define CONF_TLINES 0x00800000 -#define CONF_IPKILL 0x00010000 - -#define CONF_OPS (CONF_OPERATOR | CONF_LOCOP) -#define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPS | CONF_SERVER) -#define CONF_CRULE (CONF_CRULEALL | CONF_CRULEAUTO) -#define CONF_KLINE (CONF_KILL | CONF_IPKILL) +#define CONF_ILLEGAL 0x80000000 /**< Delete the ConfItem when no remaining clients. */ +#define CONF_CLIENT 0x0002 /**< ConfItem describes a Client block */ +#define CONF_SERVER 0x0004 /**< ConfItem describes a Connect block */ +#define CONF_OPERATOR 0x0020 /**< ConfItem describes an Operator block */ +#define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld server */ +#define CONF_AUTOCONNECT 0x0001 /**< Autoconnect to a server */ + +/** Indicates ConfItem types that count associated clients. */ +#define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER) + +/** Checks whether the CONF_ILLEGAL bit is set on \a x. */ #define IsIllegal(x) ((x)->status & CONF_ILLEGAL) /* * Structures */ -struct ConfItem { - unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ - unsigned int clients; /* Number of *LOCAL* clients using this */ - struct in_addr ipnum; /* ip number of host field */ - char bits; /* Number of bits for ipkills */ - char* host; - char* passwd; - char* name; - unsigned short int port; - time_t hold; /* Hold until this time (calendar time) */ - int dns_pending; /* a dns request is pending */ - struct ConfClass* confClass; /* Class of connection */ - struct ConfItem* next; +/** Configuration item to limit peer or client access. */ +struct ConfItem +{ + struct ConfItem *next; /**< Next ConfItem in #GlobalConfList */ + unsigned int status; /**< Set of CONF_* bits. */ + unsigned int clients; /**< Number of *LOCAL* clients using this */ + unsigned int maximum; /**< For CONF_SERVER, max hops. + For CONF_CLIENT, max connects per IP. */ + struct ConnectionClass *conn_class; /**< Class of connection */ + struct irc_sockaddr origin; /**< Local address for outbound connections */ + struct irc_sockaddr address; /**< IP and port */ + char *username; /**< For CONF_CLIENT and CONF_OPERATOR, username mask. */ + char *host; /**< Peer hostname */ + char *origin_name; /**< Text form of origin address */ + char *passwd; /**< Password field */ + char *name; /**< Name of peer */ + char *hub_limit; /**< Mask that limits servers allowed behind + this one. */ + time_t hold; /**< Earliest time to attempt an outbound + connect on this ConfItem. */ + int dns_pending; /**< A dns request is pending. */ + int flags; /**< Additional modifiers for item. */ + int addrbits; /**< Number of bits valid in ConfItem::address. */ + struct Privs privs; /**< Privileges for all users in this class. */ + /** Used to detect if a privilege has been set by this ConfItem. */ + struct Privs privs_dirty; }; -/* - * A line: A::: - */ +/** Channel quarantine structure. */ +struct qline +{ + struct qline *next; /**< Next qline in #GlobalQuarantineList. */ + char *chname; /**< Quarantined channel name. */ + char *reason; /**< Reason for quarantine. */ +}; + +/** Local K-line structure. */ +struct DenyConf { + struct DenyConf* next; /**< Next DenyConf in #denyConfList. */ + char* hostmask; /**< Mask for IP or hostname. */ + char* message; /**< Message to send to denied users. */ + char* usermask; /**< Mask for client's username. */ + char* realmask; /**< Mask for realname. */ + struct irc_in_addr address; /**< Address for IP-based denies. */ + unsigned int flags; /**< Interpretation flags for the above. */ + unsigned char bits; /**< Number of bits for ipkills */ +}; + +#define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */ + +/** Local server configuration. */ struct LocalConf { - char* server_alias; - char* vhost_address; - char* description; - char* numeric_id; - char* admin_line1; - char* admin_line2; - char* admin_line3; + char* name; /**< Name of server. */ + char* description; /**< Description of server. */ + unsigned int numeric; /**< Globally assigned server numnick. */ + char* location1; /**< First line of location information. */ + char* location2; /**< Second line of location information. */ + char* contact; /**< Admin contact information. */ }; -struct MotdItem { - char line[82]; - struct MotdItem *next; +enum { + CRULE_AUTO = 1, /**< CRule applies to automatic connections. */ + CRULE_ALL = 2, /**< CRule applies to oper-requested connections. */ + CRULE_MASK = 3 }; -struct TRecord { - char *hostmask; - struct MotdItem *tmotd; - struct tm tmotd_tm; - struct TRecord *next; +/** Connection rule configuration. */ +struct CRuleConf { + struct CRuleConf* next; /**< Next CRule in cruleConfList. */ + char* hostmask; /**< Mask of affected server names. */ + char* rule; /**< Text version of the rule. */ + int type; /**< One of CRULE_AUTO or CRULE_ALL. */ + struct CRuleNode* node; /**< Parsed form of the rule. */ }; +/** Authorization check result. */ enum AuthorizationCheckResult { - ACR_OK, - ACR_NO_AUTHORIZATION, - ACR_TOO_MANY_IN_CLASS, - ACR_TOO_MANY_FROM_IP, - ACR_ALREADY_AUTHORIZED, - ACR_BAD_SOCKET + ACR_OK, /**< User accepted. */ + ACR_NO_AUTHORIZATION, /**< No matching ConfItem for the user. */ + ACR_TOO_MANY_IN_CLASS, /**< Connection class was already full. */ + ACR_TOO_MANY_FROM_IP, /**< User's IP already has max connections. */ + ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */ + ACR_BAD_SOCKET /**< Client has bad file descriptor. */ +}; + +/** Target description for service commands. */ +struct nick_host { + struct nick_host *next; /**< Next nick_host struct in struct s_map. */ + int nicklen; /**< offset of @ part of server string */ + char nick[1]; /**< start of nick\@server string */ }; +#define SMAP_FAST 1 /**< Command does not have MFLG_SLOW. */ + +/** Target set for a service pseudo-command. */ +struct s_map { + struct s_map *next; /**< Next element in #GlobalServiceMapList. */ + struct Message *msg; /**< Message element formed for this mapping. */ + char *name; /**< Text name of the mapping. */ + char *command; /**< Command name to use. */ + char *prepend; /**< Extra text to prepend to user's text. */ + unsigned int flags; /**< Bitwise map of SMAP_* flags. */ + struct nick_host *services; /**< Linked list of possible targets. */ +}; + + /* * GLOBALS */ extern struct ConfItem* GlobalConfList; extern int GlobalConfCount; -extern struct tm motd_tm; -extern struct MotdItem* motd; -extern struct MotdItem* rmotd; -extern struct TRecord* tdata; +extern struct s_map* GlobalServiceMapList; +extern struct qline* GlobalQuarantineList; /* * Proto types */ -extern struct ConfItem* attach_confs_byhost(struct Client* cptr, - const char* host, int statmask); -extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, - int statmask); -extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, - int statmask); + +extern int init_conf(void); + +extern const struct LocalConf* conf_get_local(void); +extern const struct CRuleConf* conf_get_crule_list(void); +extern const struct DenyConf* conf_get_deny_list(void); + +extern const char* conf_eval_crule(const char* name, int mask); + +extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask); +extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask); +extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask); extern struct ConfItem* conf_find_server(const char* name); -const char* conf_eval_crule(struct ConfItem* conf); extern void det_confs_butmask(struct Client *cptr, int mask); -extern int detach_conf(struct Client *cptr, struct ConfItem *aconf); extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf); -extern struct ConfItem* find_admin(void); -extern struct ConfItem* find_me(void); -extern struct ConfItem* find_conf_exact(const char* name, - const char* user, - const char* host, int statmask); +extern struct ConfItem* find_conf_exact(const char* name, struct Client *cptr, int statmask); extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr); extern int conf_check_server(struct Client *cptr); -extern struct ConfItem* find_conf_name(const char* name, int statmask); extern int rehash(struct Client *cptr, int sig); -extern int conf_init(void); -extern void read_tlines(void); extern int find_kill(struct Client *cptr); -extern int find_restrict(struct Client *cptr); -extern int m_killcomment(struct Client *sptr, char *parv, char *filename); -extern struct MotdItem* read_motd(const char* motdfile); +extern const char *find_quarantine(const char* chname); +extern void lookup_confhost(struct ConfItem *aconf); +extern void conf_parse_userhost(struct ConfItem *aconf, char *host); +extern struct ConfItem *conf_debug_iline(const char *client); +extern void free_mapping(struct s_map *smap); + +extern void yyerror(const char *msg); #endif /* INCLUDED_s_conf_h */