| 1 | #pragma once |
| 2 | |
| 3 | #include <common/Types.h> |
| 4 | #include <Poco/Net/IPAddress.h> |
| 5 | |
| 6 | |
| 7 | namespace Poco |
| 8 | { |
| 9 | namespace Net |
| 10 | { |
| 11 | class SocketAddress; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | namespace DB |
| 16 | { |
| 17 | /** Lets you check if the address is similar to `localhost`. |
| 18 | * The purpose of this check is usually to make an assumption, |
| 19 | * that when we go to this address via the Internet, we'll get to ourselves. |
| 20 | * Please note that this check is not accurate: |
| 21 | * - the address is simply compared to the addresses of the network interfaces; |
| 22 | * - only the first address is taken for each network interface; |
| 23 | * - the routing rules that affect which network interface we go to the specified address are not checked. |
| 24 | */ |
| 25 | bool isLocalAddress(const Poco::Net::SocketAddress & address, UInt16 clickhouse_port); |
| 26 | bool isLocalAddress(const Poco::Net::SocketAddress & address); |
| 27 | bool isLocalAddress(const Poco::Net::IPAddress & address); |
| 28 | |
| 29 | /// Returns number of different bytes in hostnames, used for load balancing |
| 30 | size_t getHostNameDifference(const std::string & local_hostname, const std::string & host); |
| 31 | } |
| 32 | |