summaryrefslogtreecommitdiff
path: root/modules/hostserv/main
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 /modules/hostserv/main
parent8ceca4fd3f9cb82bc93801d5eb682d27b2ad2f54 (diff)
Make vhosts assignable to accounts, not nicks. Allow multiple vhosts per account.
Diffstat (limited to 'modules/hostserv/main')
-rw-r--r--modules/hostserv/main/hostserv.cpp14
-rw-r--r--modules/hostserv/main/vhost.cpp14
-rw-r--r--modules/hostserv/main/vhost.h4
-rw-r--r--modules/hostserv/main/vhosttype.cpp1
-rw-r--r--modules/hostserv/main/vhosttype.h1
5 files changed, 23 insertions, 11 deletions
diff --git a/modules/hostserv/main/hostserv.cpp b/modules/hostserv/main/hostserv.cpp
index ab1617a85..b0c3d04f2 100644
--- a/modules/hostserv/main/hostserv.cpp
+++ b/modules/hostserv/main/hostserv.cpp
@@ -66,14 +66,7 @@ class HostServCore : public Module
if (!IRCD->CanSetVHost)
return;
- NickServ::Nick *na = NickServ::FindNick(u->nick);
- HostServ::VHost *vhost = nullptr;
-
- if (na && na->GetAccount() == u->Account())
- vhost = na->GetVHost();
-
- if (vhost == nullptr)
- vhost = NickServ::FindNick(u->Account()->GetDisplay())->GetVHost();
+ HostServ::VHost *vhost = HostServ::FindVHost(u->Account());
if (vhost == nullptr)
return;
@@ -123,7 +116,10 @@ class HostServCore : public Module
if (u && u->Account() == na->GetAccount())
{
- HostServ::VHost *vhost = na->GetVHost();
+ HostServ::VHost *vhost = HostServ::FindVHost(u->Account());
+
+ if (vhost == nullptr)
+ return;
IRCD->SendVhost(u, vhost->GetIdent(), vhost->GetHost());
diff --git a/modules/hostserv/main/vhost.cpp b/modules/hostserv/main/vhost.cpp
index f7878d53c..635e3a5b4 100644
--- a/modules/hostserv/main/vhost.cpp
+++ b/modules/hostserv/main/vhost.cpp
@@ -1,7 +1,7 @@
/*
* Anope IRC Services
*
- * Copyright (C) 2015-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2016 Anope Team <team@anope.org>
*
* This file is part of Anope. Anope is free software; you can
* redistribute it and/or modify it under the terms of the GNU
@@ -67,4 +67,14 @@ time_t VHostImpl::GetCreated()
void VHostImpl::SetCreated(time_t created)
{
Set(&VHostType::created, created);
-} \ No newline at end of file
+}
+
+bool VHostImpl::IsDefault()
+{
+ return Get(&VHostType::default_);
+}
+
+void VHostImpl::SetDefault(bool default_)
+{
+ Set(&VHostType::default_, default_);
+}
diff --git a/modules/hostserv/main/vhost.h b/modules/hostserv/main/vhost.h
index e0b751899..90ac9140f 100644
--- a/modules/hostserv/main/vhost.h
+++ b/modules/hostserv/main/vhost.h
@@ -30,6 +30,7 @@ class VHostImpl : public HostServ::VHost
Anope::string vhost;
Anope::string creator;
time_t created = 0;
+ bool default_ = false;
public:
using HostServ::VHost::VHost;
@@ -48,5 +49,8 @@ class VHostImpl : public HostServ::VHost
time_t GetCreated() override;
void SetCreated(time_t) override;
+
+ bool IsDefault() override;
+ void SetDefault(bool) override;
};
diff --git a/modules/hostserv/main/vhosttype.cpp b/modules/hostserv/main/vhosttype.cpp
index 3eae8eec3..ee73840bf 100644
--- a/modules/hostserv/main/vhosttype.cpp
+++ b/modules/hostserv/main/vhosttype.cpp
@@ -26,6 +26,7 @@ VHostType::VHostType(Module *me) : Serialize::Type<VHostImpl>(me)
, vhost(this, "vhost", &VHostImpl::vhost)
, creator(this, "creator", &VHostImpl::creator)
, created(this, "created", &VHostImpl::created)
+ , default_(this, "default", &VHostImpl::default_)
{
}
diff --git a/modules/hostserv/main/vhosttype.h b/modules/hostserv/main/vhosttype.h
index 8306cae27..3be60f518 100644
--- a/modules/hostserv/main/vhosttype.h
+++ b/modules/hostserv/main/vhosttype.h
@@ -27,6 +27,7 @@ class VHostType : public Serialize::Type<VHostImpl>
Serialize::Field<VHostImpl, Anope::string> vhost;
Serialize::Field<VHostImpl, Anope::string> creator;
Serialize::Field<VHostImpl, time_t> created;
+ Serialize::Field<VHostImpl, bool> default_;
VHostType(Module *);
};