From 7f73af0cc979072b65f7ff986037437f727ca6f0 Mon Sep 17 00:00:00 2001 From: Mikhail Korotov <55493615+millb@users.noreply.github.com> Date: Thu, 10 Oct 2019 16:13:33 +0300 Subject: [PATCH] Delete StorageOfAllowedURL.cpp --- dbms/src/Common/StorageOfAllowedURL.cpp | 62 ------------------------- 1 file changed, 62 deletions(-) delete mode 100644 dbms/src/Common/StorageOfAllowedURL.cpp diff --git a/dbms/src/Common/StorageOfAllowedURL.cpp b/dbms/src/Common/StorageOfAllowedURL.cpp deleted file mode 100644 index 4d57b67dcf2..00000000000 --- a/dbms/src/Common/StorageOfAllowedURL.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DB -{ -namespace ErrorCodes -{ - extern const int UNACCEPTABLE_URL; -} - -void StorageOfAllowedURL::checkURL(const Poco::URI & uri) -{ - if (!checkString(uri.getHost()) && - !checkString(uri.getHost() + ":" + toString(uri.getPort()))) - throw Exception("URL \"" + uri.toString() + "\" is not allowed in config.xml", ErrorCodes::UNACCEPTABLE_URL); -} - -void StorageOfAllowedURL::checkHostAndPort(const std::string & host, const std::string & port) -{ - if (!checkString(host) && - !checkString(host + ":" + port)) - throw Exception("URL \"" + host + ":" + port + "\" is not allowed in config.xml", ErrorCodes::UNACCEPTABLE_URL); -} - -void StorageOfAllowedURL::setValuesFromConfig(const Poco::Util::AbstractConfiguration & config) -{ - if (config.has("remote_url_allow_hosts")) - { - std::vector keys; - config.keys("remote_url_allow_hosts", keys); - for (auto key : keys) - { - if (startsWith(key, "host_regexp")) - regexp_hosts.push_back(config.getString("remote_url_allow_hosts." + key)); - else if (startsWith(key, "host")) - primary_hosts.insert(config.getString("remote_url_allow_hosts." + key)); - } - } -} - -bool StorageOfAllowedURL::checkString(const std::string &host) -{ - if (!primary_hosts.empty() || !regexp_hosts.empty()) - { - if (primary_hosts.find(host) == primary_hosts.end()) - { - for (size_t i = 0; i < regexp_hosts.size(); ++i) - if (re2::RE2::FullMatch(host, regexp_hosts[i])) - return true; - return false; - } - return true; - } - return true; -} -}