summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/StaticDomainNameResolver.cpp')
-rw-r--r--Swiften/Network/StaticDomainNameResolver.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/Swiften/Network/StaticDomainNameResolver.cpp b/Swiften/Network/StaticDomainNameResolver.cpp
new file mode 100644
index 0000000..8ca4062
--- /dev/null
+++ b/Swiften/Network/StaticDomainNameResolver.cpp
@@ -0,0 +1,28 @@
+#include "Swiften/Network/StaticDomainNameResolver.h"
+#include "Swiften/Network/DomainNameResolveException.h"
+#include "Swiften/Base/String.h"
+
+namespace Swift {
+
+StaticDomainNameResolver::StaticDomainNameResolver() {
+}
+
+std::vector<HostAddressPort> StaticDomainNameResolver::resolve(const String& queriedDomain) {
+ std::vector<HostAddressPort> result;
+
+ for(DomainCollection::const_iterator i = domains.begin(); i != domains.end(); ++i) {
+ if (i->first == queriedDomain) {
+ result.push_back(i->second);
+ }
+ }
+ if (result.empty()) {
+ throw DomainNameResolveException();
+ }
+ return result;
+}
+
+void StaticDomainNameResolver::addDomain(const String& domain, const HostAddressPort& addressPort) {
+ domains.push_back(std::make_pair(domain, addressPort));
+}
+
+}