24#ifndef HOSTNAME_CACHE_INCLUDED
25#define HOSTNAME_CACHE_INCLUDED
37#ifdef HAVE_NETINET_IN_H
38#include <netinet/in.h>
114#define HOST_ENTRY_KEY_SIZE INET6_ADDRSTRLEN
160#define RC_BLOCKED_HOST 1
161#define RC_LONG_HOSTNAME 2
162int ip_to_hostname(
struct sockaddr_storage *ip_storage,
const char *ip_string,
163 char **hostname, uint *connect_errors);
An entry in the hostname hash table cache.
Definition: hostname_cache.h:126
bool m_host_validated
The hostname is validated and used for authorization.
Definition: hostname_cache.h:145
uint m_hostname_length
Length in bytes of m_hostname.
Definition: hostname_cache.h:143
ulonglong m_last_error_seen
Definition: hostname_cache.h:149
Host_errors m_errors
Error statistics.
Definition: hostname_cache.h:151
ulonglong m_first_error_seen
Definition: hostname_cache.h:148
char ip_key[HOST_ENTRY_KEY_SIZE]
Client IP address.
Definition: hostname_cache.h:136
ulonglong m_first_seen
Definition: hostname_cache.h:146
char m_hostname[HOSTNAME_LENGTH+1]
One of the host names for the IP address.
Definition: hostname_cache.h:141
ulonglong m_last_seen
Definition: hostname_cache.h:147
void set_error_timestamps(ulonglong now)
Definition: hostname_cache.h:153
int ip_to_hostname(struct sockaddr_storage *ip_storage, const char *ip_string, char **hostname, uint *connect_errors)
Resolve IP-address to host name.
Definition: hostname_cache.cc:444
std::list< std::unique_ptr< Host_entry > >::iterator hostname_cache_begin()
Definition: hostname_cache.cc:229
void reset_host_connect_errors(const char *ip_string)
Definition: hostname_cache.cc:367
void inc_host_errors(const char *ip_string, Host_errors *errors)
Definition: hostname_cache.cc:345
void hostname_cache_free()
Definition: hostname_cache.cc:207
bool hostname_cache_init(uint size)
Definition: hostname_cache.cc:193
#define HOST_ENTRY_KEY_SIZE
Size of IP address string in the hash cache.
Definition: hostname_cache.h:114
std::list< std::unique_ptr< Host_entry > >::iterator hostname_cache_end()
Definition: hostname_cache.cc:234
void hostname_cache_refresh(void)
Definition: hostname_cache.cc:171
uint hostname_cache_size()
Definition: hostname_cache.cc:179
void hostname_cache_resize(uint size)
Definition: hostname_cache.cc:184
void hostname_cache_unlock()
Definition: hostname_cache.cc:224
void hostname_cache_lock()
Definition: hostname_cache.cc:219
Common definition used by mysys, performance schema and server & client.
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:43
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Common definition between mysql server & client.
size_t size(const char *const c)
Definition: base64.h:46
Definition: hostname_cache.h:41
ulong m_host_blocked
Number of host blocked errors.
Definition: hostname_cache.h:53
ulong m_authentication
Number of errors from authentication.
Definition: hostname_cache.h:79
void clear_connect_errors()
Definition: hostname_cache.h:110
ulong m_handshake
Number of errors from authentication plugins.
Definition: hostname_cache.h:73
ulong m_max_user_connection_per_hour
Number of errors from max user connection per hour.
Definition: hostname_cache.h:85
bool has_error() const
Definition: hostname_cache.h:93
ulong m_default_database
Number of errors from the default database.
Definition: hostname_cache.h:87
void reset()
Definition: hostname_cache.cc:116
void sum_connect_errors()
Definition: hostname_cache.h:105
ulong m_nameinfo_transient
Number of transient errors from getnameinfo().
Definition: hostname_cache.h:55
void aggregate(const Host_errors *errors)
Definition: hostname_cache.cc:140
ulong m_init_connect
Number of errors from init_connect.
Definition: hostname_cache.h:89
ulong m_connect
Number of connect errors.
Definition: hostname_cache.h:50
ulong m_nameinfo_permanent
Number of permanent errors from getnameinfo().
Definition: hostname_cache.h:57
ulong m_FCrDNS
Number of errors from Forward-Confirmed reverse DNS checks.
Definition: hostname_cache.h:65
Host_errors()
Definition: hostname_cache.cc:91
ulong m_max_user_connection
Number of errors from max user connection.
Definition: hostname_cache.h:83
ulong m_no_auth_plugin
Number of errors from missing auth plugin.
Definition: hostname_cache.h:69
ulong m_proxy_user
Number of errors from proxy user.
Definition: hostname_cache.h:75
ulong m_proxy_user_acl
Number of errors from proxy user acl.
Definition: hostname_cache.h:77
ulong m_host_acl
Number of errors from host grants.
Definition: hostname_cache.h:67
ulong m_local
Number of errors from the server itself.
Definition: hostname_cache.h:91
ulong m_addrinfo_permanent
Number of permanent errors from getaddrinfo().
Definition: hostname_cache.h:63
ulong m_addrinfo_transient
Number of transient errors from getaddrinfo().
Definition: hostname_cache.h:61
ulong m_ssl
Number of errors from ssl.
Definition: hostname_cache.h:81
ulong m_format
Number of errors from is_hostname_valid().
Definition: hostname_cache.h:59
ulong m_auth_plugin
Number of errors from auth plugin.
Definition: hostname_cache.h:71