summaryrefslogtreecommitdiff
path: root/include/modules/hostserv.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-10-09 19:51:39 -0400
committerAdam <Adam@anope.org>2016-10-09 19:51:39 -0400
commite7dd7159b1e1ab5b3edabc44ece5338672f8fbb4 (patch)
tree9517f02ca1c29fa247f6914398f35a44052c22ff /include/modules/hostserv.h
parent8ceca4fd3f9cb82bc93801d5eb682d27b2ad2f54 (diff)
Make vhosts assignable to accounts, not nicks. Allow multiple vhosts per account.
Diffstat (limited to 'include/modules/hostserv.h')
-rw-r--r--include/modules/hostserv.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/modules/hostserv.h b/include/modules/hostserv.h
index 4e6661faa..6934c813e 100644
--- a/include/modules/hostserv.h
+++ b/include/modules/hostserv.h
@@ -45,6 +45,54 @@ namespace HostServ
virtual time_t GetCreated() anope_abstract;
virtual void SetCreated(time_t) anope_abstract;
+
+ virtual bool IsDefault() anope_abstract;
+ virtual void SetDefault(bool) anope_abstract;
+
+ inline Anope::string Mask()
+ {
+ Anope::string ident = GetIdent(), host = GetHost();
+ if (!ident.empty())
+ return ident + "@" + host;
+ else
+ return host;
+ }
};
+
+ /** Find the default vhost for an object, or the first
+ * if there is no default.
+ * @return The object's vhost
+ */
+ inline VHost *FindVHost(Serialize::Object *obj)
+ {
+ VHost *first = nullptr;
+
+ for (VHost *v : obj->GetRefs<VHost *>())
+ {
+ if (first == nullptr)
+ first = v;
+
+ if (v->IsDefault())
+ {
+ first = v;
+ break;
+ }
+ }
+
+ return first;
+ }
+
+ inline VHost *FindVHost(Serialize::Object *obj, const Anope::string &v)
+ {
+ for (VHost *vhost : obj->GetRefs<VHost *>())
+ {
+ if (vhost->Mask().equals_ci(v))
+ {
+ return vhost;
+ }
+ }
+
+ return nullptr;
+ }
}