summaryrefslogtreecommitdiffstats
blob: 8ca40622ab153573863b239495950f21ca78c9f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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));
}

}