MySQL 8.0.29
Source Code Documentation
hostname_validator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2021, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED
26#define MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED
27
28#include "harness_export.h"
29
30#include <string>
31
32namespace mysql_harness {
33
34bool HARNESS_EXPORT is_valid_ip_address(const std::string &address);
35
36/**
37 * check if address is a hostname.
38 *
39 * hostname is verified according to RFC 1123.
40 *
41 * - fully qualified domain names like "mysql.com." are not valid hostnames
42 * (trailing dot)
43 * - service names like "_mysql.example.com" are not valid hostnames (leading
44 * underscore)
45 *
46 * @param address name of a host
47 *
48 * @retval false hostname is invalid
49 * @retval true hostname is valid
50 */
51bool HARNESS_EXPORT is_valid_hostname(const std::string &address);
52
53/**
54 * check if address is a domainname.
55 *
56 * domainnames according to RFC 2181:
57 *
58 * - max size 255 chars
59 * - labels are separated by dots
60 * - each label is min 1, max 63 chars.
61 *
62 * That means
63 *
64 * - IPv4 addresses
65 * - IPv6 addresses
66 * - hostnames
67 *
68 * are domainnames.
69 *
70 * @param address address to check
71 *
72 * @retval true address is a domainname
73 * @retval false address is not a domainname
74 */
75bool HARNESS_EXPORT is_valid_domainname(const std::string &address);
76
77} // namespace mysql_harness
78
79#endif // #define MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED
Definition: common.h:41
bool HARNESS_EXPORT is_valid_ip_address(const std::string &address)
Definition: hostname_validator.cc:33
bool HARNESS_EXPORT is_valid_hostname(const std::string &address)
check if address is a hostname.
Definition: hostname_validator.cc:49
bool HARNESS_EXPORT is_valid_domainname(const std::string &address)
check if address is a domainname.
Definition: hostname_validator.cc:64