]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/hash.h
full support for marks
[irc/evilnet/x3.git] / src / hash.h
index 2394bf13d8b98b002d053dd7d711918381b033bb..6b5f26ecbff1174401be4cc6b82a1745af19444e 100644 (file)
@@ -1,9 +1,9 @@
 /* hash.h - IRC network state database
  * Copyright 2000-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
- * srvx is free software; you can redistribute it and/or modify
+ * x3 is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
@@ -37,7 +37,7 @@
 #define MODE_BAN               0x00000200 /* +b BAN */
 #define MODE_LIMIT             0x00000400 /* +l LIMIT */
 #define MODE_DELAYJOINS         0x00000800 /* +D */
-#define MODE_REGONLY            0x00001000 /* ircu +r, Bahamut +R */
+#define MODE_REGONLY            0x00001000 /* ircu +r */
 #define MODE_NOCOLORS           0x00002000 /* +c */
 #define MODE_NOCTCPS            0x00004000 /* +C */
 #define MODE_REGISTERED         0x00008000 /* Bahamut +r */
 #define MODE_OPERSONLY          0x00080000 /* +O Opers only */
 #define MODE_NOQUITMSGS         0x00100000 /* +Q suppress messages from quit notices */
 #define MODE_NOAMSG             0x00200000 /* +T no multi-target messages */
-#define MODE_SSLONLY            0x00400000 /* +z ssl only */
+#define MODE_SSLONLY            0x00400000 /* +Z ssl only */
 #define MODE_HALFOP             0x00800000 /* +h USER */
 #define MODE_EXEMPT             0x01000000 /* +e exempt */
+#define MODE_HIDEMODE          0x02000000 /* +L hide modes */
+#define MODE_APASS             0x04000000 /* +A adminpass */
+#define MODE_UPASS             0x08000000 /* +U userpass */
 #define MODE_REMOVE             0x80000000
 
 #define FLAGS_OPER             0x0001 /* Operator +O */
 #define NICKLEN         30
 #define USERLEN         10
 #define HOSTLEN         63
-#define ACCOUNTLEN     15
+#define SOCKIPLEN       45
+#define ACCOUNTLEN      15
 #define REALLEN         50
 #define TOPICLEN        250
 #define CHANNELLEN      200
+#define MARKLEN         20
+#define MAXOPLEVEL      999
 
 #define MAXMODEPARAMS  6
-#define MAXBANS                45
+#define MAXBANS                128
 #define MAXEXEMPTS     45
 
 /* IDLEN is 6 because it takes 5.33 Base64 digits to store 32 bytes. */
 #define IDLEN           6
 
+/** Operator privileges. */
+enum Priv {
+  PRIV_CHAN_LIMIT,      /**< no channel limit on oper */
+  PRIV_MODE_LCHAN,      /**< oper can mode local chans */
+  PRIV_WALK_LCHAN,      /**< oper can walk through local modes */
+  PRIV_DEOP_LCHAN,      /**< no deop oper on local chans */
+  PRIV_SHOW_INVIS,      /**< show local invisible users */
+  PRIV_SHOW_ALL_INVIS,  /**< show all invisible users */
+  PRIV_UNLIMIT_QUERY,   /**< unlimit who queries */
+  PRIV_KILL,            /**< oper can KILL */
+  PRIV_LOCAL_KILL,      /**< oper can local KILL */
+  PRIV_REHASH,          /**< oper can REHASH */
+  PRIV_REMOTEREHASH,    /**< oper can remote REHASH */
+  PRIV_RESTART,         /**< oper can RESTART */
+  PRIV_DIE,             /**< oper can DIE */
+  PRIV_GLINE,           /**< oper can GLINE */
+  PRIV_LOCAL_GLINE,     /**< oper can local GLINE */
+  PRIV_SHUN,            /**< oper can SHUN */
+  PRIV_LOCAL_SHUN,      /**< oper can local SHUN */
+  PRIV_JUPE,            /**< oper can JUPE */
+  PRIV_LOCAL_JUPE,      /**< oper can local JUPE */
+  PRIV_OPMODE,          /**< oper can OP/CLEARMODE */
+  PRIV_LOCAL_OPMODE,    /**< oper can local OP/CLEARMODE */
+  PRIV_SET,             /**< oper can SET */
+  PRIV_WHOX,            /**< oper can use /who x */
+  PRIV_BADCHAN,         /**< oper can BADCHAN */
+  PRIV_LOCAL_BADCHAN,   /**< oper can local BADCHAN */
+  PRIV_SEE_CHAN,        /**< oper can see in secret chans */
+  PRIV_PROPAGATE,       /**< propagate oper status */
+  PRIV_DISPLAY,         /**< "Is an oper" displayed */
+  PRIV_SEE_OPERS,       /**< display hidden opers */
+  PRIV_WIDE_GLINE,      /**< oper can set wider G-lines */
+  PRIV_WIDE_SHUN,       /**< oper can set wider G-lines */
+  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_CHECK,           /**< oper can use CHECK */
+  PRIV_SEE_SECRET_CHAN, /**< oper can see +s channels in whois */
+  PRIV_LAST_PRIV        /**< number of privileges */
+};
+
+/** Number of bits */
+#define _PRIV_NBITS             (8 * sizeof(unsigned long))
+/** Element number for priv \a priv. */
+#define _PRIV_IDX(priv)         ((priv) / _PRIV_NBITS)
+/** Element bit for priv \a priv. */
+#define _PRIV_BIT(priv)         (1UL << ((priv) % _PRIV_NBITS))
+
+/** Operator privileges. */
+struct Privs {
+  unsigned long priv_mask[(PRIV_LAST_PRIV + _PRIV_NBITS - 1) / _PRIV_NBITS];
+};
+
 DECLARE_LIST(userList, struct userNode*);
 DECLARE_LIST(modeList, struct modeNode*);
 DECLARE_LIST(banList, struct banNode*);
@@ -123,20 +182,41 @@ struct userNode {
     char info[REALLEN + 1];       /* Free form additional client information */
     char hostname[HOSTLEN + 1];   /* DNS name or IP address */
     char fakehost[HOSTLEN + 1];   /* Assigned fake host */
+    char crypthost[HOSTLEN + 30]; /* Crypted hostname */
+    char cryptip[SOCKIPLEN + 30]; /* Crypted IP */
 #ifdef WITH_PROTOCOL_P10
     char numeric[COMBO_NUMERIC_LEN+1];
     unsigned int num_local : 18;
 #endif
+    unsigned int loc;             /* Is user connecting via LOC? */
+    unsigned int no_notice;       /* Does the users client not see notices? */
     unsigned int dead : 1;        /* Is user waiting to be recycled? */
-    struct in_addr ip;            /* User's IP address */
+    irc_in_addr_t ip;             /* User's IP address */
     long modes;                   /* user flags +isw etc... */
 
     // sethost - reed/apples
     char sethost[USERLEN + HOSTLEN + 2]; /* 1 for '\0' and 1 for @ = 2 */
 
+    /* GeoIP Data */
+    char *country_name;
+
+    /* GeoIP City Data */
+    char *country_code;
+    char *city;
+    char *region;
+    char *postal_code;
+    float latitude;
+    float longitude;
+    int dma_code;
+    int area_code;
+    
+    char *mark;                   /* only filled if they are marked */
+    char *version_reply;          /* only filled in if a version query was triggered */
+
     time_t timestamp;             /* Time of last nick change */
     struct server *uplink;        /* Server that user is connected to */
     struct modeList channels;     /* Vector of channels user is in */
+    struct Privs   privs;
 
     /* from nickserv */
     struct handle_info *handle_info;
@@ -144,10 +224,27 @@ struct userNode {
     struct policer auth_policer;
 };
 
+#define privs(cli)             ((cli)->privs)
+#define PrivSet(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] |= \
+                                 _PRIV_BIT(priv))
+#define PrivClr(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] &= \
+                                 ~(_PRIV_BIT(priv)))
+#define PrivHas(pset, priv)     ((pset)->priv_mask[_PRIV_IDX(priv)] & \
+                                 _PRIV_BIT(priv))
+
+#define PRIV_ADD 1
+#define PRIV_DEL 0
+
+#define GrantPriv(cli, priv)    (PrivSet(&(privs(cli)), priv))
+#define RevokePriv(cli, priv)   (PrivClr(&(privs(cli)), priv))
+#define HasPriv(cli, priv)      (PrivHas(&(privs(cli)), priv))
+
 struct chanNode {
     chan_mode_t modes;
     unsigned int limit, locks;
     char key[KEYLEN + 1];
+    char upass[KEYLEN + 1];
+    char apass[KEYLEN + 1];
     time_t timestamp; /* creation time */
   
     char topic[TOPICLEN + 1];
@@ -182,6 +279,7 @@ struct modeNode {
     struct chanNode *channel;
     struct userNode *user;
     long modes;
+    short oplevel;
     time_t idle_since;
 };
 
@@ -208,6 +306,42 @@ struct server {
     struct serverList children;
 };
 
+struct waitingConnection {
+    char *server;
+    char *target;
+};
+
+struct routingPlan {
+    dict_t servers;
+};
+
+struct routingPlanServer {
+    char *uplink;
+    char *secondaryuplink;
+    unsigned int port;
+    int karma;
+    int offline;
+};
+
+/* Ported from X2 */
+struct routeList {
+    char* server;              /* Name of the server */
+    unsigned int   port;       /* connection port */
+    char *uplink;              /* Server its linked to (towards us) */
+    char *secondaryuplink; 
+    int outsideness;           /* 0 means leaf, 1 second layer, etc. my uplink is highest */
+    struct routeList *next;
+};
+
+/* Ported from X2 */
+struct route {
+    int count;                 /* how many servers we have */
+    int maxdepth;              /* biggest outsideness value */
+    int centered;              /* set to TRUE when changerouteUplinks is run */
+    struct routeList *servers;
+};
+
+
 extern struct server *self;
 extern dict_t channels;
 extern dict_t clients;
@@ -239,6 +373,7 @@ void reg_account_func(account_func_t handler);
 void call_account_func(struct userNode *user, const char *stamp);
 void StampUser(struct userNode *user, const char *stamp, time_t timestamp);
 void assign_fakehost(struct userNode *user, const char *host, int announce);
+void set_geoip_info(struct userNode *user);
 
 typedef void (*new_channel_func_t) (struct chanNode *chan);
 void reg_new_channel_func(new_channel_func_t handler);
@@ -268,7 +403,8 @@ int ChannelExemptExists(struct chanNode *channel, const char *exempt);
 
 typedef int (*topic_func_t)(struct userNode *who, struct chanNode *chan, const char *old_topic);
 void reg_topic_func(topic_func_t handler);
-void SetChannelTopic(struct chanNode *channel, struct userNode *user, const char *topic, int announce);
+void SetChannelTopic(struct chanNode *channel, struct userNode *service, struct userNode *user, const char *topic, int announce);
+struct userNode *IsInChannel(struct chanNode *channel, struct userNode *user);
 
 void init_structs(void);