X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=include%2Fclient.h;h=66f9f9d3fc1badb55c162a8fa60776dc9e41df40;hb=3e86180fb32d5eab15c761b75ba3d4520ef23bac;hp=b08f7cb0f47de119890679cc75d78fa9b269ad0c;hpb=8ee87dd0dddbf06fedbe255aa155da73cac60858;p=ircu2.10.12-pk.git diff --git a/include/client.h b/include/client.h index b08f7cb..66f9f9d 100644 --- a/include/client.h +++ b/include/client.h @@ -56,6 +56,7 @@ struct Whowas; struct hostent; struct Privs; struct AuthRequest; +struct SSLConnection; /* * Structures @@ -89,8 +90,8 @@ typedef unsigned long flagpage_t; /** Clear a flag in a flagset. */ #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag)) -/** String containig valid user modes, in no particular order. */ -#define infousermodes "dioswkgx" +/** String containing valid user modes, in no particular order. */ +#define infousermodes "diOoswkgx" /** Operator privileges. */ enum Priv @@ -125,6 +126,8 @@ enum Priv PRIV_LIST_CHAN, /**< oper can list secret channels */ PRIV_FORCE_OPMODE, /**< can hack modes on quarantined channels */ PRIV_FORCE_LOCAL_OPMODE, /**< can hack modes on quarantined local channels */ + PRIV_APASS_OPMODE, /**< can hack modes +A/-A/+U/-U */ + PRIV_UNLIMIT_FLOOD, /**< user won't get excess flooded */ PRIV_LAST_PRIV /**< number of privileges */ }; @@ -154,7 +157,6 @@ enum Flag FLAG_BURST, /**< Server is receiving a net.burst */ FLAG_BURST_ACK, /**< Server is waiting for eob ack */ FLAG_IPCHECK, /**< Added or updated IPregistry data */ - FLAG_IAUTHED, /**< Got IAUTH response for user */ FLAG_LOCOP, /**< Local operator -- SRB */ FLAG_SERVNOTICE, /**< server notices such as kill */ FLAG_OPER, /**< Operator */ @@ -166,6 +168,7 @@ enum Flag FLAG_DEBUG, /**< send global debug/anti-hack info */ FLAG_ACCOUNT, /**< account name has been set */ FLAG_HIDDENHOST, /**< user's host is hidden */ + FLAG_SSLCONN, /**< SSL Connection */ FLAG_LAST_FLAG, /**< number of flags */ FLAG_LOCAL_UMODES = FLAG_LOCOP, /**< First local mode flag */ FLAG_GLOBAL_UMODES = FLAG_OPER /**< First global mode flag */ @@ -176,6 +179,8 @@ DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV); /** Declare flagset type for user flags. */ DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG); +#include "capab.h" /* client capabilities */ + /** Represents a local connection. * This contains a lot of stuff irrelevant to server connections, but * those are so rare as to not be worth special-casing. @@ -195,7 +200,6 @@ struct Connection time_t con_nexttarget;/**< Next time a target change is allowed */ time_t con_lasttime; /**< Last time data read from socket */ time_t con_since; /**< Last time we accepted a command */ - unsigned int con_cookie; /**< Random number the user must PONG */ struct MsgQ con_sendQ; /**< Outgoing message queue */ struct DBuf con_recvQ; /**< Incoming data yet to be parsed */ unsigned int con_sendM; /**< Stats: protocol messages sent */ @@ -207,8 +211,6 @@ struct Connection struct SLink* con_confs; /**< Associated configuration records. */ HandlerType con_handler; /**< Message index into command table for parsing. */ - struct DNSReply* con_dns_reply; /**< DNS reply received during client - registration. */ struct ListingArgs* con_listing; /**< Current LIST status. */ unsigned int con_max_sendq; /**< cached max send queue for client */ unsigned int con_ping_freq; /**< cached ping freq */ @@ -228,8 +230,11 @@ struct Connection client */ struct Timer con_proc; /**< process latent messages from client */ - struct AuthRequest* con_auth; /**< auth request for client */ - struct IAuthRequest* con_iauth; /**< iauth request for client */ + struct Privs con_privs; /**< Oper privileges */ + struct CapSet con_capab; /**< Client capabilities (from us) */ + struct CapSet con_active; /**< Active capabilities (to us) */ + struct AuthRequest* con_auth; /**< Auth request for client */ + struct SSLConnection* con_ssl; /**< SSL connection for client */ }; /** Magic constant to identify valid Connection structures. */ @@ -254,9 +259,8 @@ struct Client { unsigned int cli_hopcount; /**< number of servers to this 0 = local */ struct irc_in_addr cli_ip; /**< Real IP of client */ short cli_status; /**< Client type */ - struct Privs cli_privs; /**< Oper privileges */ char cli_name[HOSTLEN + 1]; /**< Unique name of the client, nick or host */ - char cli_username[USERLEN + 1]; /**< username here now for auth stuff */ + char cli_username[USERLEN + 1]; /**< Username determined by ident lookup */ char cli_info[REALLEN + 1]; /**< Free form additional client information */ }; @@ -306,13 +310,19 @@ struct Client { /** Return non-zero if the client is local. */ #define cli_local(cli) (cli_from(cli) == cli) /** Get oper privileges for client. */ -#define cli_privs(cli) ((cli)->cli_privs) +#define cli_privs(cli) con_privs(cli_connect(cli)) +/** Get client capabilities for client */ +#define cli_capab(cli) con_capab(cli_connect(cli)) +/** Get active client capabilities for client */ +#define cli_active(cli) con_active(cli_connect(cli)) /** Get client name. */ #define cli_name(cli) ((cli)->cli_name) /** Get client username (ident). */ #define cli_username(cli) ((cli)->cli_username) /** Get client realname (information field). */ #define cli_info(cli) ((cli)->cli_info) +/** Get client account string. */ +#define cli_account(cli) (cli_user(cli) ? cli_user(cli)->account : "0") /** Get number of incoming bytes queued for client. */ #define cli_count(cli) con_count(cli_connect(cli)) @@ -328,8 +338,6 @@ struct Client { #define cli_nextnick(cli) con_nextnick(cli_connect(cli)) /** Get next time a target change is allowed for the client. */ #define cli_nexttarget(cli) con_nexttarget(cli_connect(cli)) -/** Get required PING/PONG cookie for client. */ -#define cli_cookie(cli) con_cookie(cli_connect(cli)) /** Get SendQ for client. */ #define cli_sendQ(cli) con_sendQ(cli_connect(cli)) /** Get RecvQ for client. */ @@ -348,8 +356,6 @@ struct Client { #define cli_confs(cli) con_confs(cli_connect(cli)) /** Get handler type for client. */ #define cli_handler(cli) con_handler(cli_connect(cli)) -/** Get DNS reply for client. */ -#define cli_dns_reply(cli) con_dns_reply(cli_connect(cli)) /** Get LIST status for client. */ #define cli_listing(cli) con_listing(cli_connect(cli)) /** Get cached max SendQ for client. */ @@ -374,8 +380,6 @@ struct Client { #define cli_proc(cli) con_proc(cli_connect(cli)) /** Get auth request for client. */ #define cli_auth(cli) con_auth(cli_connect(cli)) -/** Get iauth request for client. */ -#define cli_iauth(cli) con_iauth(cli_connect(cli)) /** Get sentalong marker for client. */ #define cli_sentalong(cli) con_sentalong(cli_connect(cli)) @@ -409,8 +413,6 @@ struct Client { #define con_lasttime(con) ((con)->con_lasttime) /** Get last time we accepted a command from the connection. */ #define con_since(con) ((con)->con_since) -/** Get PING/PONG confirmation cookie for connection. */ -#define con_cookie(con) ((con)->con_cookie) /** Get SendQ for connection. */ #define con_sendQ(con) ((con)->con_sendQ) /** Get RecvQ for connection. */ @@ -429,8 +431,6 @@ struct Client { #define con_confs(con) ((con)->con_confs) /** Get command handler for the connection. */ #define con_handler(con) ((con)->con_handler) -/** Get DNS reply for the connection. */ -#define con_dns_reply(con) ((con)->con_dns_reply) /** Get the LIST status for the connection. */ #define con_listing(con) ((con)->con_listing) /** Get the maximum permitted SendQ size for the connection. */ @@ -453,10 +453,16 @@ struct Client { #define con_socket(con) ((con)->con_socket) /** Get the Timer for processing more data from the connection. */ #define con_proc(con) ((con)->con_proc) +/** Get the oper privilege set for the connection. */ +#define con_privs(con) (&(con)->con_privs) +/** Get the peer's capabilities for the connection. */ +#define con_capab(con) (&(con)->con_capab) +/** Get the active capabilities for the connection. */ +#define con_active(con) (&(con)->con_active) /** Get the auth request for the connection. */ #define con_auth(con) ((con)->con_auth) -/** Get the iauth request for the connection. */ -#define con_iauth(con) ((con)->con_iauth) +/** Get the ssl connection for the connection. */ +#define con_ssl(con) ((con)->con_ssl) #define STAT_CONNECTING 0x001 /**< connecting to another server */ #define STAT_HANDSHAKE 0x002 /**< pass - server sent */ @@ -533,7 +539,7 @@ struct Client { #define HasFlag(cli, flag) FlagHas(&cli_flags(cli), flag) /** Return non-zero if the client is an IRC operator (global or local). */ -#define IsAnOper(x) (HasFlag(x, FLAG_OPER) || HasFlag(x, FLAG_LOCOP)) +#define IsAnOper(x) (IsOper(x) || IsLocOp(x)) /** Return non-zero if the client's connection is blocked. */ #define IsBlocked(x) HasFlag(x, FLAG_BLOCKED) /** Return non-zero if the client's connection is still being burst. */ @@ -551,16 +557,14 @@ struct Client { #define IsDeaf(x) HasFlag(x, FLAG_DEAF) /** Return non-zero if the client has been IP-checked for clones. */ #define IsIPChecked(x) HasFlag(x, FLAG_IPCHECK) -/** Return non-zero if the client has been okayed by iauth. */ -#define IsIAuthed(x) HasFlag(x, FLAG_IAUTHED) /** Return non-zero if we have received an ident response for the client. */ #define IsIdented(x) HasFlag(x, FLAG_GOTID) /** Return non-zero if the client has set mode +i (invisible). */ #define IsInvisible(x) HasFlag(x, FLAG_INVISIBLE) /** Return non-zero if the client caused a net.burst. */ #define IsJunction(x) HasFlag(x, FLAG_JUNCTION) -/** Return non-zero if the client has set mode +O (local operator). */ -#define IsLocOp(x) HasFlag(x, FLAG_LOCOP) +/** Return non-zero if the client has set mode +O (local operator) locally. */ +#define IsLocOp(x) (MyConnect(x) && HasFlag(x, FLAG_LOCOP)) /** Return non-zero if the client has set mode +o (global operator). */ #define IsOper(x) HasFlag(x, FLAG_OPER) /** Return non-zero if the client has an active UDP ping request. */ @@ -583,6 +587,8 @@ struct Client { #define IsAccount(x) HasFlag(x, FLAG_ACCOUNT) /** Return non-zero if the client has set mode +x (hidden host). */ #define IsHiddenHost(x) HasFlag(x, FLAG_HIDDENHOST) +/** Return non-zero if the client has set mode +S (SSL Connection). */ +#define IsSSLConn(x) HasFlag(x, FLAG_SSLCONN) /** Return non-zero if the client has an active PING request. */ #define IsPingSent(x) HasFlag(x, FLAG_PINGSENT) @@ -605,8 +611,6 @@ struct Client { #define SetGotId(x) SetFlag(x, FLAG_GOTID) /** Mark a client as being IP-checked. */ #define SetIPChecked(x) SetFlag(x, FLAG_IPCHECK) -/** Mark a client as being iauth-checked. */ -#define SetIAuthed(x) SetFlag(x, FLAG_IAUTHED) /** Mark a client as having mode +i (invisible). */ #define SetInvisible(x) SetFlag(x, FLAG_INVISIBLE) /** Mark a client as causing a net.join. */ @@ -631,6 +635,9 @@ struct Client { #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT) /** Mark a client as having mode +x (hidden host). */ #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST) +/** Mark a client as having mode +S (SSL Connection). */ +#define SetSSLConn(x) SetFlag(x, FLAG_SSLCONN) + /** Mark a client as having a pending PING. */ #define SetPingSent(x) SetFlag(x, FLAG_PINGSENT) @@ -664,8 +671,12 @@ struct Client { #define ClearServNotice(x) ClrFlag(x, FLAG_SERVNOTICE) /** Remove mode +x (hidden host) from the client. */ #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST) +/** Remove mode +S (SSL Connection) from the client. */ +#define ClearSSLConn(x) ClrFlag(x, FLAG_SSLCONN) /** Clear the client's pending PING flag. */ #define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT) +/** Clear the client's HUB flag. */ +#define ClearHub(x) ClrFlag(x, FLAG_HUB) /* free flags */ #define FREEFLAG_SOCKET 0x0001 /**< socket needs to be freed */ @@ -695,12 +706,13 @@ struct Client { #define SNO_CONNEXIT 0x4000 /**< client connect/exit (ugh) */ #define SNO_AUTO 0x8000 /**< AUTO G-Lines */ #define SNO_DEBUG 0x10000 /**< debugging messages (DEBUGMODE only) */ +#define SNO_AUTH 0x20000 /**< IAuth notices */ +/** Bitmask of all valid server notice bits. */ #ifdef DEBUGMODE -# define SNO_ALL 0x1ffff /**< Bitmask of all valid server - * notice bits. */ +# define SNO_ALL 0x3ffff #else -# define SNO_ALL 0xffff +# define SNO_ALL 0x2ffff #endif /** Server notice bits allowed to normal users. */ @@ -711,12 +723,21 @@ struct Client { /** Server notice bits enabled by default for IRC operators. */ #define SNO_OPERDEFAULT (SNO_DEFAULT|SNO_HACK2|SNO_HACK4|SNO_THROTTLE|SNO_OLDSNO) /** Server notice bits reserved to IRC operators. */ -#define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP) +#define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP|SNO_AUTH) /** Noisy server notice bits that cause other bits to be cleared during connect. */ #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH) /** Test whether a privilege has been granted to a client. */ -#define HasPriv(cli, priv) FlagHas(&cli_privs(cli), priv) +#define HasPriv(cli, priv) client_get_priv(cli, priv) +/** Grant a privilege to a client. */ +#define SetPriv(cli, priv) FlagSet(cli_privs(cli), priv) +/** Revoke a privilege from a client. */ +#define ClrPriv(cli, priv) FlagClr(cli_privs(cli), priv) + +/** Test whether a client has a capability */ +#define HasCap(cli, cap) CapHas(cli_capab(cli), (cap)) +/** Test whether a client has the capability active */ +#define CapActive(cli, cap) CapHas(cli_active(cli), (cap)) #define HIDE_IP 0 /**< Do not show IP address in get_client_name() */ #define SHOW_IP 1 /**< Show ident and IP address in get_client_name() */ @@ -730,5 +751,7 @@ extern void client_add_sendq(struct Connection* con, extern void client_set_privs(struct Client *client, struct ConfItem *oper); extern int client_report_privs(struct Client* to, struct Client* client); +extern int client_get_priv(struct Client* client, enum Priv priv); + #endif /* INCLUDED_client_h */