added basic ssl support to ircu
[ircu2.10.12-pk.git] / include / client.h
index 7110dd09e4a07e9252fdc3b837f418886c81a3e0..7ad4692816bdc1d57fcce84ad71a31ff46be392b 100644 (file)
@@ -56,6 +56,7 @@ struct Whowas;
 struct hostent;
 struct Privs;
 struct AuthRequest;
+struct SSLConnection;
 
 /*
  * Structures
@@ -90,7 +91,7 @@ typedef unsigned long flagpage_t;
 #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag))
 
 /** String containing valid user modes, in no particular order. */
-#define infousermodes "dioswkgx"
+#define infousermodes "diOoswkgx"
 
 /** Operator privileges. */
 enum Priv
@@ -126,6 +127,7 @@ enum Priv
     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 */
   };
 
@@ -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 */
@@ -231,6 +234,7 @@ struct Connection
   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. */
@@ -317,6 +321,8 @@ struct Client {
 #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))
@@ -455,6 +461,8 @@ struct Client {
 #define con_active(con)         (&(con)->con_active)
 /** Get the auth request for the connection. */
 #define con_auth(con)          ((con)->con_auth)
+/** 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 */
@@ -556,7 +564,7 @@ struct Client {
 /** 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) locally. */
-#define IsLocOp(x)              (MyUser(x) && HasFlag(x, FLAG_LOCOP))
+#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. */
@@ -579,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)
 
@@ -625,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)
 
@@ -658,6 +671,8 @@ 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. */
@@ -713,7 +728,7 @@ struct Client {
 #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)  FlagHas(client_get_privs(cli), priv)
 /** Grant a privilege to a client. */
 #define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
 /** Revoke a privilege from a client. */
@@ -736,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_privs(struct Client* client);
+
 #endif /* INCLUDED_client_h */