mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
Delete StorageOfAllowedURL.cpp
This commit is contained in:
parent
8d675ad2b4
commit
7f73af0cc9
@ -1,62 +0,0 @@
|
|||||||
#include <re2/re2.h>
|
|
||||||
#include <Common/StorageOfAllowedURL.h>
|
|
||||||
#include <Poco/URI.h>
|
|
||||||
#include <Formats/FormatFactory.h>
|
|
||||||
#include <Poco/Util/AbstractConfiguration.h>
|
|
||||||
#include <Common/StringUtils/StringUtils.h>
|
|
||||||
#include <Common/Exception.h>
|
|
||||||
#include <IO/WriteHelpers.h>
|
|
||||||
|
|
||||||
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<std::string> 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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user