/* * Copyright © 2005 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * Protocol handlers, both generic and the actual declarations themselves. * * $Id: phandler.h,v 1.5 2007/09/02 23:14:42 pippijn Exp $ */ #ifndef PHANDLER_H #define PHANDLER_H #include namespace protocol { struct ircd_t { char const * const ircdname; char const * const tldprefix; bool uses_uid; bool uses_rcommand; bool uses_owner; bool uses_protect; bool uses_halfops; bool uses_p10; /* Parser hackhack. */ bool uses_vhost; /* Do we use vHosts? */ unsigned const oper_only_modes; unsigned const owner_mode; unsigned const protect_mode; unsigned const halfops_mode; char const * const owner_mchar; char const * const protect_mchar; char const * const halfops_mchar; unsigned const type; unsigned const perm_mode; /* Modes to not disappear when empty */ char const * const ban_like_modes; /* e.g. "beI" */ char const except_mchar; char const invex_mchar; int const flags; }; /* values for type */ /* -- what the HELL are these used for? A grep reveals nothing.. --w00t * -- they are used to provide a hint to third-party module coders about what * ircd they are working with. --nenolod */ #define PROTOCOL_ASUKA 1 #define PROTOCOL_BAHAMUT 2 #define PROTOCOL_CHARYBDIS 3 #define PROTOCOL_DREAMFORGE 4 #define PROTOCOL_HYPERION 5 #define PROTOCOL_INSPIRCD 6 #define PROTOCOL_IRCNET 7 #define PROTOCOL_MONKEY 8 /* obsolete */ #define PROTOCOL_PLEXUS 9 #define PROTOCOL_PTLINK 10 #define PROTOCOL_RATBOX 11 #define PROTOCOL_SCYLLA 12 #define PROTOCOL_SHADOWIRCD 13 #define PROTOCOL_SORCERY 14 #define PROTOCOL_ULTIMATE3 15 #define PROTOCOL_UNDERNET 16 #define PROTOCOL_UNREAL 17 #define PROTOCOL_SOLIDIRCD 18 #define PROTOCOL_NEFARIOUS 19 #define PROTOCOL_OFFICEIRC 20 #define PROTOCOL_OTHER 255 /* values for flags */ #define IRCD_CIDR_BANS 1 /* forced nick change types */ #define FNC_REGAIN 0 /* give a registered user their nick back */ #define FNC_FORCE 1 /* force a user off their nick (kill if unsupported) */ struct handler { /* pmodule.C */ static bool loaded; handler () { loaded = true; } virtual ~handler () { loaded = false; } /* server login, usually sends PASS, CAPAB, SERVER and SVINFO * you can still change ircd->uses_uid at this point * set me.bursting = true * return 1 if sts() failed (by returning 1), otherwise 0 */ virtual unsigned int server_login (void); /* introduce a client on the services server */ virtual void introduce_nick (user_t *u); /* send an invite for a given user to a channel * the source may not be on the channel */ virtual void invite_sts (user_t *source, user_t *target, channel_t *channel); /* quit a client on the services server with the given message */ virtual void quit_sts (user_t *u, char const * const reason); /* send wallops * use something that only opers can see if easily possible */ virtual void wallops_sts (char const * const text); /* join a channel with a client on the services server * the client should be introduced opped * isnew indicates the channel modes (and bans XXX) should be bursted * note that the channelts can still be old in this case (e.g. kills) * modes is a convenience argument giving the simple modes with parameters * do not rely upon chanuser_find(c,u) */ virtual void join_sts (channel_t *c, user_t *u, bool isnew, char const * const modes); /* lower the TS of a channel, joining it with the given client on the * services server (opped), replacing the current simple modes with the * ones stored in the channel_t and clearing all other statuses * if bans are timestamped on this ircd, call chanban_clear() * if the topic is timestamped on this ircd, clear it */ virtual void chan_lowerts (channel_t *c, user_t *u); /* kick a user from a channel * from is a client on the services server which may or may not be * on the channel */ virtual void kick (char const * const from, char const * const channel, char const * const to, char const * const reason); /* change ircd metadata */ virtual void mdchange (char const * const target, char const * const key, char const * const value); /* send a privmsg * here it's ok to assume the source is able to send */ virtual void privmsg (char const * const from, char const * const target, char const * const fmt, ...); /* send a notice to a user * from can be a client on the services server or the services server * itself (NULL) */ virtual void notice_user_sts (user_t *from, user_t *target, char const * const text); /* send a global notice to all users on servers matching the mask * from is a client on the services server * mask is either "*" or it has a non-wildcard TLD */ virtual void notice_global_sts (user_t *from, char const * const mask, char const * const text); /* send a notice to a channel * from can be a client on the services server or the services server * itself (NULL) * if the source cannot send because it is not on the channel, send the * notice from the server or join for a moment */ virtual void notice_channel_sts (user_t *from, channel_t *target, char const * const text); /* send a notice to ops in a channel * source may or may not be on channel * generic_wallchops() sends an individual notice to each channel operator */ virtual void wallchops (user_t *source, channel_t *target, char const * const message); /* send a numeric from must be me.name or ME */ virtual void numeric_sts (char const * const from, int numeric, char const * const target, char const * const fmt, ...); /* kill a user * from can be a client on the services server or the services server * itself (me.name or ME) * it is recommended to change an invalid source to ME */ virtual void skill (char const * const from, char const * const nick, char const * const fmt, ...); /* part a channel with a client on the services server */ virtual void part_sts (channel_t *c, user_t *u); /* add a kline on the servers matching the given mask * duration is in seconds, 0 for a permanent kline * if the ircd requires klines to be sent from users, use opersvs */ virtual void kline_sts (char const * const server, char const * const user, char const * const host, long duration, char const * const reason); /* remove a kline on the servers matching the given mask * if the ircd requires unklines to be sent from users, use opersvs */ virtual void unkline_sts (char const * const server, char const * const user, char const * const host); /* make chanserv set a topic on a channel * setter and ts should be used if the ircd supports topics to be set * with a given topicsetter and topicts; ts is not a channelts * prevts is the topicts of the old topic or 0 if there was no topic, * useful in optimizing which form of topic change to use * if the given topicts was not set and topicts is used on the ircd, * set c->topicts to the value used */ virtual void topic_sts (channel_t *c, char const * const setter, time_t ts, time_t prevts, char const * const topic); /* set modes on a channel by the given sender; sender must be a client * on the services server; sender may or may not be on channel */ virtual void mode_sts (char const * const sender, channel_t *target, char const * const modes); /* ping the uplink * first check if me.connected is true and bail if not */ virtual void ping_sts (void); /* mark user 'origin' as logged in as 'user' * wantedhost is currently not used * first check if me.connected is true and bail if not */ virtual void ircd_on_login (char const * const origin, char const * const user, char const * const wantedhost); /* mark user 'origin' as logged out * first check if me.connected is true and bail if not * return false if successful or logins are not supported * return true if the user was killed to force logout (P10) */ virtual bool ircd_on_logout (char const * const origin, char const * const user, char const * const wantedhost); /* introduce a fake server * it is ok to use opersvs to squit the old server * if SQUIT uses kill semantics (e.g. charybdis), server_delete() the server * and continue * if SQUIT uses unconnect semantics (e.g. bahamut), set SF_JUPE_PENDING on * the server and return; you will be called again when the server is really * deleted */ virtual void jupe (char const * const server, char const * const reason); /* set a dynamic spoof on a user * if the ircd does not notify the user of this, do * notice(source, target, "Setting your host to \2%s\2.", host); */ virtual void sethost_sts (char const * const source, char const * const target, char const * const host); /* force a nickchange for a user * possible values for type: * FNC_REGAIN: give a registered user their nick back * FNC_FORCE: force a user off their nick (kill if unsupported) */ virtual void fnc_sts (user_t *source, user_t *u, char const * const newnick, int type); /* temporarily make a nick unavailable to users * source is the responsible service * duration is in seconds, 0 to remove the effect of a previous call * account is an account that may still use the nick, or NULL */ virtual void holdnick_sts (user_t *source, int duration, char const * const nick, myuser_t *account); /* change nick, user, host and/or services login name for a user * target may also be a not yet fully introduced UID (for SASL) */ virtual void svslogin_sts (char const * const target, char const * const nick, char const * const user, char const * const host, char const * const login); /* send sasl message */ virtual void sasl_sts (char const * const target, char const mode, char const * const data); /* find next channel ban (or other ban-like mode) matching user */ virtual node_t *next_matching_ban (channel_t *c, user_t *u, int type, node_t *first); /* find next host channel access matching user */ virtual node_t *next_matching_host_chanacs (mychan_t *mc, user_t *u, node_t *first); }; } // namespace protocol #define FACREG_TYPE protocol::handler #define FACREG_TYPE_NAME "protocol handler" #define FACREG_TYPE_IS_ABSTRACT #include E protocol::handler *phandler; E protocol::ircd_t *ircd; E cmode_t *mode_list; E extmode *ignore_mode_list; E cmode_t *status_mode_list; E cmode_t *prefix_mode_list; #endif