/* 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.
#include "dict.h"
#include "policer.h"
-#define MODE_CHANOP 0x0001 /* +o USER */
-#define MODE_VOICE 0x0002 /* +v USER */
-#define MODE_PRIVATE 0x0004 /* +p */
-#define MODE_SECRET 0x0008 /* +s */
-#define MODE_MODERATED 0x0010 /* +m */
-#define MODE_TOPICLIMIT 0x0020 /* +t */
-#define MODE_INVITEONLY 0x0040 /* +i */
-#define MODE_NOPRIVMSGS 0x0080 /* +n */
-#define MODE_KEY 0x0100 /* +k KEY */
-#define MODE_BAN 0x0200 /* +b BAN */
-#define MODE_LIMIT 0x0400 /* +l LIMIT */
-#define MODE_DELAYJOINS 0x0800 /* +D */
-#define MODE_REGONLY 0x1000 /* ircu +r, Bahamut +R */
-#define MODE_NOCOLORS 0x2000 /* +c */
-#define MODE_NOCTCPS 0x4000 /* +C */
-#define MODE_REGISTERED 0x8000 /* Bahamut +r */
+#define MODE_CHANOP 0x00000001 /* +o USER */
+#define MODE_VOICE 0x00000002 /* +v USER */
+#define MODE_PRIVATE 0x00000004 /* +p */
+#define MODE_SECRET 0x00000008 /* +s */
+#define MODE_MODERATED 0x00000010 /* +m */
+#define MODE_TOPICLIMIT 0x00000020 /* +t */
+#define MODE_INVITEONLY 0x00000040 /* +i */
+#define MODE_NOPRIVMSGS 0x00000080 /* +n */
+#define MODE_KEY 0x00000100 /* +k KEY */
+#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_NOCOLORS 0x00002000 /* +c */
+#define MODE_NOCTCPS 0x00004000 /* +C */
+#define MODE_REGISTERED 0x00008000 /* Bahamut +r */
+#define MODE_STRIPCOLOR 0x00010000 /* +S Strip mirc color codes */
+#define MODE_MODUNREG 0x00020000 /* +M mod unregister */
+#define MODE_NONOTICE 0x00040000 /* +N no notices */
+#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_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 FLAGS_DEAF 0x0020 /* deaf +d */
#define FLAGS_SERVICE 0x0040 /* cannot be kicked, killed or deoped +k */
#define FLAGS_GLOBAL 0x0080 /* receives global messages +g */
-#define FLAGS_HELPER 0x0100 /* (network?) helper +h */
+
+// sethost - reed/apples
+// #define FLAGS_HELPER 0x0100 /* (network?) helper +h */
+#define FLAGS_SETHOST 0x0100 /* sethost +h */
+
#define FLAGS_PERSISTENT 0x0200 /* for reserved nicks, this isn't just one-shot */
#define FLAGS_GAGGED 0x0400 /* for gagged users */
#define FLAGS_AWAY 0x0800 /* for away users */
#define IsGlobal(x) ((x)->modes & FLAGS_GLOBAL)
#define IsWallOp(x) ((x)->modes & FLAGS_WALLOP)
#define IsServNotice(x) ((x)->modes & FLAGS_SERVNOTICE)
-#define IsHelperIrcu(x) ((x)->modes & FLAGS_HELPER)
+
+// sethost - reed/apples
+// #define IsHelperIrcu(x) ((x)->modes & FLAGS_HELPER)
+#define IsSetHost(x) ((x)->modes & FLAGS_SETHOST)
+
#define IsGagged(x) ((x)->modes & FLAGS_GAGGED)
#define IsPersistent(x) ((x)->modes & FLAGS_PERSISTENT)
#define IsAway(x) ((x)->modes & FLAGS_AWAY)
#define NICKLEN 30
#define USERLEN 10
#define HOSTLEN 63
+#define SOCKIPLEN 45
+#define ACCOUNTLEN 15
#define REALLEN 50
#define TOPICLEN 250
#define CHANNELLEN 200
+#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
DECLARE_LIST(userList, struct userNode*);
DECLARE_LIST(modeList, struct modeNode*);
DECLARE_LIST(banList, struct banNode*);
+DECLARE_LIST(exemptList, struct exemptNode*);
DECLARE_LIST(channelList, struct chanNode*);
DECLARE_LIST(serverList, struct server*);
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 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 */
+
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 */
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];
struct modeList members;
struct banList banlist;
+ struct exemptList exemptlist;
struct policer join_policer;
unsigned int join_flooded : 1;
unsigned int bad_channel : 1;
time_t set; /* time ban was set */
};
+struct exemptNode {
+ char exempt[NICKLEN + USERLEN + HOSTLEN + 3]; /* 1 for '\0', 1 for ! and 1 for @ = 3 */
+ char who[NICKLEN + 1]; /* who set exempt */
+ time_t set; /* time exempt was set */
+};
+
struct modeNode {
struct chanNode *channel;
struct userNode *user;
long modes;
+ short oplevel;
time_t idle_since;
};
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;
typedef void (*account_func_t) (struct userNode *user, const char *stamp);
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);
+void StampUser(struct userNode *user, const char *stamp, time_t timestamp);
void assign_fakehost(struct userNode *user, const char *host, int announce);
typedef void (*new_channel_func_t) (struct chanNode *chan);
typedef void (*del_channel_func_t) (struct chanNode *chan);
void reg_del_channel_func(del_channel_func_t handler);
-struct chanNode* AddChannel(const char *name, time_t time_, const char *modes, char *banlist);
+struct chanNode* AddChannel(const char *name, time_t time_, const char *modes, char *banlist, char *exemptlist);
void LockChannel(struct chanNode *channel);
void UnlockChannel(struct chanNode *channel);
void ChannelUserKicked(struct userNode* kicker, struct userNode* victim, struct chanNode* channel);
int ChannelBanExists(struct chanNode *channel, const char *ban);
+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);