12#ifndef OPENVPN_COMMON_HOSTPORT_H
13#define OPENVPN_COMMON_HOSTPORT_H
31 return parse_number_validate<unsigned int>(
port, 5, 1, 65535, value);
34inline void validate_port(
const std::string &
port,
const std::string &title,
unsigned int *value =
nullptr)
46inline unsigned short parse_port(
const std::string &
port,
const std::string &title)
50 return static_cast<unsigned short>(
ret);
56 return (c >=
'a' && c <=
'z')
57 || (c >=
'A' && c <=
'Z')
58 || (c >=
'0' && c <=
'9')
66 if (!
host.length() ||
host.length() > 256)
68 for (
const auto &c :
host)
78 return c >= 0x21 && c <= 0x7E;
83 if (!
host.length() ||
host.length() > 256)
85 for (
const auto &c :
host)
102 const std::string &default_port,
103 const bool allow_unix,
104 unsigned int *port_save =
nullptr)
108 const size_t fpos =
str.find_first_of(
':');
109 const size_t lpos =
str.find_last_of(
':');
110 const size_t cb =
str.find_last_of(
']');
111 if (lpos != std::string::npos
112 && (cb == std::string::npos || cb + 1 == lpos)
113 && (cb != std::string::npos || fpos == lpos))
119 else if (!default_port.empty())
132 if (allow_unix &&
port ==
"unix")
#define OPENVPN_EXCEPTION(C)
#define OPENVPN_THROW(exc, stuff)
void validate_host(const std::string &host, const std::string &title)
void validate_port(const std::string &port, const std::string &title, unsigned int *value=nullptr)
bool is_valid_port(const unsigned int port)
bool is_valid_unix_sock(const std::string &host)
bool split_host_port(const std::string &str, std::string &host, std::string &port, const std::string &default_port, const bool allow_unix, unsigned int *port_save=nullptr)
bool is_valid_host_char(const char c)
unsigned short parse_port(const std::string &port, const std::string &title)
bool is_valid_host(const std::string &host)
bool is_valid_unix_sock_char(const unsigned char c)
STRING utf8_printable(const STRING &str, size_t max_len_flags)
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'