![]() |
MySQL 9.2.0
Source Code Documentation
|
Get hostname for an IP address. More...
#include "sql/hostname_cache.h"
#include "my_config.h"
#include "map_helpers.h"
#include "mutex_lock.h"
#include "my_psi_config.h"
#include "my_systime.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "thr_mutex.h"
#include <netdb.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <list>
#include <memory>
#include <new>
#include <string>
#include <unordered_map>
#include <utility>
#include "m_string.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_sys.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/psi_memory_key.h"
#include "violite.h"
#include <arpa/inet.h>
Functions | |
void | hostname_cache_refresh () |
uint | hostname_cache_size () |
void | hostname_cache_resize (uint size) |
bool | hostname_cache_init (uint size) |
void | hostname_cache_free () |
void | hostname_cache_lock () |
void | hostname_cache_unlock () |
list< unique_ptr< Host_entry > >::iterator | hostname_cache_begin () |
list< unique_ptr< Host_entry > >::iterator | hostname_cache_end () |
static Host_entry * | hostname_cache_search (const char *ip_string) |
static void | add_hostname_impl (const char *ip_string, const char *hostname, bool validated, Host_errors *errors, ulonglong now) |
static void | add_hostname (const char *ip_string, const char *hostname, bool validated, Host_errors *errors) |
void | inc_host_errors (const char *ip_string, Host_errors *errors) |
void | reset_host_connect_errors (const char *ip_string) |
static bool | is_ip_loopback (const struct sockaddr *ip) |
static bool | is_hostname_valid (const char *hostname) |
int | ip_to_hostname (struct sockaddr_storage *ip_storage, const char *ip_string, char **hostname, uint *connect_errors) |
Resolve IP-address to host name. More... | |
Variables | |
PSI_mutex_key | key_hash_filo_lock |
static size_t | hostname_cache_max_size |
static list< unique_ptr< Host_entry > > * | hostname_cache_lru |
static malloc_unordered_map< string, list< unique_ptr< Host_entry > >::iterator > * | hostname_cache_by_ip |
static mysql_mutex_t | hostname_cache_mutex |
static bool | hostname_cache_mutex_inited = false |
Get hostname for an IP address.
Hostnames are checked with reverse name lookup and checked that they doesn't resemble an IP address.
|
static |
|
static |
list< unique_ptr< Host_entry > >::iterator hostname_cache_begin | ( | ) |
list< unique_ptr< Host_entry > >::iterator hostname_cache_end | ( | ) |
void hostname_cache_free | ( | ) |
bool hostname_cache_init | ( | uint | size | ) |
void hostname_cache_lock | ( | ) |
void hostname_cache_refresh | ( | void | ) |
void hostname_cache_resize | ( | uint | size | ) |
|
inlinestatic |
uint hostname_cache_size | ( | ) |
void hostname_cache_unlock | ( | ) |
void inc_host_errors | ( | const char * | ip_string, |
Host_errors * | errors | ||
) |
int ip_to_hostname | ( | struct sockaddr_storage * | ip_storage, |
const char * | ip_string, | ||
char ** | hostname, | ||
uint * | connect_errors | ||
) |
Resolve IP-address to host name.
This function does the following things:
NOTE: connect_errors are counted (are supported) only for the clients where IP-address can be resolved and FCrDNS check is passed.
[in] | ip_storage | IP address (sockaddr). Must be set. |
[in] | ip_string | IP address (string). Must be set. |
[out] | hostname | Hostname if IP-address is valid. |
[out] | connect_errors | Represents number of connection errors. |
0 | Success |
RC_BLOCKED_HOST | The host is blocked. |
RC_LONG_HOSTNAME | The hostname is longer than HOSTNAME_LENGTH. |
The function does not set/report MySQL server error in case of failure. It's caller's responsibility to handle failures of this function properly.
|
inlinestatic |
|
inlinestatic |
void reset_host_connect_errors | ( | const char * | ip_string | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
extern |