summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-01-02 08:20:59 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-01-02 08:20:59 +0000
commita819cb0cc0f54a042a088dfba9c1f6b817928641 (patch)
tree7931a9d81367c184ca2550a1819ef685e3e0c927 /include
parent3617d7978899f830d952d9bac70ed14bb0cc0fd6 (diff)
Rewrote the vhost code, and moved it to be part of nickalias instead of in its own list. This also fixes being able to steal other users vhosts with /hs on
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2724 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'include')
-rw-r--r--include/account.h1
-rw-r--r--include/extern.h21
-rw-r--r--include/modules.h19
-rw-r--r--include/services.h63
4 files changed, 60 insertions, 44 deletions
diff --git a/include/account.h b/include/account.h
index dc0d21c7d..0516b5fe9 100644
--- a/include/account.h
+++ b/include/account.h
@@ -105,6 +105,7 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag>
time_t time_registered; /* When the nick was registered */
time_t last_seen; /* When it was seen online for the last time */
NickCore *nc; /* I'm an alias of this */
+ HostInfo hostinfo;
};
class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag>
diff --git a/include/extern.h b/include/extern.h
index 09f12ba77..11ba59bd5 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -173,16 +173,12 @@ char *sockstrerror(int error);
/**** config.c ****/
E ServerConfig Config;
-
-E int do_on_id(User * u);
-E void delHostCore(const char *nick);
-E void hostserv(User * u, char *buf);
-
E int read_config(int reload);
-/**** converter.c ****/
-
-E int convert_ircservices_44();
+/* hostserv.c */
+E void do_on_id(User *u);
+E void hostserv(User *u, char *buf);
+E void HostServSyncVhosts(NickAlias *na);
/**** encrypt.c ****/
E void initEncryption();
@@ -200,15 +196,6 @@ E void encmodule_check_password(int (*func)(const char *plaintext, const char *p
/**** hostserv.c ****/
E void get_hostserv_stats(long *nrec, long *memuse);
E void hostserv_init();
-E void addHostCore(const char *nick, char *vIdent, char *vhost, const char *creator, int32 tmp_time);
-E char *getvIdent(char *nick);
-E char *getvHost(char *nick);
-E HostCore *hostCoreListHead();
-E HostCore *findHostCore(HostCore * head, const char *nick, bool *found);
-E HostCore *createHostCorelist(HostCore * next, const char *nick, char *vIdent, char *vHost, const char *creator, int32 tmp_time);
-E HostCore *insertHostCore(HostCore * head, HostCore * prev, const char *nick, char *vIdent, char *vHost, const char *creator, int32 tmp_time);
-E HostCore *deleteHostCore(HostCore * head, HostCore * prev);
-E void set_lastmask(User * u);
/**** init.c ****/
diff --git a/include/modules.h b/include/modules.h
index 129e2666d..bfd8b3928 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -989,20 +989,15 @@ class CoreExport Module
*/
virtual void OnNickEraseAccess(NickCore *nc, const std::string &entry) { }
- /** called when a HostCore is deleted
- * @param hc pointer to the HostCore
+ /** called when a vhost is deleted
+ * @param na The nickalias of the vhost
*/
- virtual void OnDeleteHostCore(HostCore *hc) { }
+ virtual void OnDeleteVhost(NickAlias *na) { }
- /** called on findHostCore
- * @param nick the name of the HostCore we are searching for
+ /** Called when a vhost is set
+ * @param na The nickalias of the vhost
*/
- virtual void OnFindHostCore(const std::string &nick) { }
-
- /** called when a new HostCore is inserted
- * @param hc pointer to the HostCore
- */
- virtual void OnInsertHostCore(HostCore *hc) { }
+ virtual void OnSetVhost(NickAlias *na) { }
/** Called when a mode is set on a channel
* @param c The channel
@@ -1090,7 +1085,7 @@ enum Implementation
I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBotPreLoad,
/* HostServ */
- I_OnHostServHelp, I_OnDeleteHostCore, I_OnFindHostCore, I_OnInsertHostCore,
+ I_OnHostServHelp, I_OnSetVhost, I_OnDeleteVhost,
/* MemoServ */
I_OnMemoServHelp,
diff --git a/include/services.h b/include/services.h
index 5c2a426ed..9393c9091 100644
--- a/include/services.h
+++ b/include/services.h
@@ -364,7 +364,6 @@ typedef struct userdata_ UserData;
typedef struct mailinfo_ MailInfo;
typedef struct akill_ Akill;
typedef struct sxline_ SXLine;
-typedef struct hostcore_ HostCore;
typedef struct exception_ Exception;
typedef struct session_ Session;
@@ -508,6 +507,53 @@ typedef struct {
/*************************************************************************/
+class HostInfo
+{
+ private:
+ std::string Ident;
+ std::string Host;
+ std::string Creator;
+ time_t Time;
+
+ public:
+ /** Set a vhost for the user
+ * @param ident The ident
+ * @param host The host
+ * @param creator Who created the vhost
+ * @param time When the vhost was craated
+ */
+ void SetVhost(const std::string &ident, const std::string &host, const std::string &creator, time_t time = time(NULL));
+
+ /** Remove a users vhost
+ **/
+ void RemoveVhost();
+
+ /** Check if the user has a vhost
+ * @return true or false
+ */
+ bool HasVhost() const;
+
+ /** Retrieve the vhost ident
+ * @return the ident
+ */
+ const std::string &GetIdent() const;
+
+ /** Retrieve the vhost host
+ * @return the host
+ */
+ const std::string &GetHost() const;
+
+ /** Retrieve the vhost creator
+ * @return the creator
+ */
+ const std::string &GetCreator() const;
+
+ /** Retrieve when the vhost was crated
+ * @return the time it was created
+ */
+ const time_t GetTime() const;
+};
+
// For NickServ
#include "account.h"
@@ -1052,20 +1098,6 @@ struct sxline_ {
/************************************************************************/
-/* Host serv structures */
-
-struct hostcore_ {
- HostCore *next;
- char *nick; /* Owner of the vHost */
- char *vIdent; /* vIdent for the user */
- char *vHost; /* Vhost for this user */
- char *creator; /* Oper Nick of the oper who set the vhost */
- time_t time; /* Date/Time vHost was set */
-};
-
-/*************************************************************************/
-
-
struct exception_ {
char *mask; /* Hosts to which this exception applies */
int limit; /* Session limit for exception */
@@ -1334,6 +1366,7 @@ class CoreExport Anope
* @param case_sensitive Whether or not the match is case sensitive, default false.
*/
static bool Match(const std::string &str, const std::string &mask, bool case_sensitive = false);
+ inline static bool Match(const ci::string &str, const ci::string &mask) { return Match(str.c_str(), mask.c_str(), false); }
};
/*************************************************************************/