mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Add ip address whitelist processing to domain server
This commit is contained in:
parent
edb8d14507
commit
63cfbf55ca
2 changed files with 41 additions and 0 deletions
|
@ -158,6 +158,42 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
|
||||
|
||||
qDebug() << "domain-server is running";
|
||||
static const SubnetMask LOCALHOST_MASK { QHostAddress("127.0.0.1"), 32 };
|
||||
|
||||
this->_acIPAddressWhitelist = { LOCALHOST_MASK };
|
||||
|
||||
_settingsManager.getWhitelistAssignmentClientAddresses();
|
||||
auto whitelist = _settingsManager.valueOrDefaultValueForKeyPath("security.ac_address_whitelist").toStringList();
|
||||
for (auto& mask : whitelist) {
|
||||
auto maskParts = mask.trimmed().split("/");
|
||||
|
||||
if (maskParts.size() > 2) {
|
||||
qDebug() << "Ignoring ip in whitelist, malformed: " << mask;
|
||||
continue;
|
||||
}
|
||||
|
||||
// The default netmask is 32 if one has not been specified, which will
|
||||
// match only the ip provided.
|
||||
int netmask = 32;
|
||||
|
||||
if (maskParts.size() == 2) {
|
||||
bool ok;
|
||||
netmask = maskParts[1].toInt(&ok);
|
||||
if (!ok) {
|
||||
qDebug() << "Ignoring ip in whitelist, bad netmask: " << mask;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto ip = QHostAddress(maskParts[0]);
|
||||
|
||||
if (!ip.isNull()) {
|
||||
qDebug() << "Adding AC whitelist IP: " << mask << " -> " << (ip.toString() + "/" + QString::number(netmask));
|
||||
_acIPAddressWhitelist.push_back({ ip , netmask });
|
||||
} else {
|
||||
qDebug() << "Ignoring ip in whitelist, invalid ip: " << mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DomainServer::parseCommandLine() {
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
typedef QSharedPointer<Assignment> SharedAssignmentPointer;
|
||||
typedef QMultiHash<QUuid, WalletTransaction*> TransactionHash;
|
||||
|
||||
using SubnetMask = QPair<QHostAddress, int>;
|
||||
using SubnetMaskList = std::vector<QPair<QHostAddress, int>>;
|
||||
|
||||
class DomainServer : public QCoreApplication, public HTTPSRequestHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -156,6 +159,8 @@ private:
|
|||
|
||||
void setupGroupCacheRefresh();
|
||||
|
||||
SubnetMaskList _acIPAddressWhitelist;
|
||||
|
||||
DomainGatekeeper _gatekeeper;
|
||||
|
||||
HTTPManager _httpManager;
|
||||
|
|
Loading…
Reference in a new issue