OpenVPN 3 Core Library
Loading...
Searching...
No Matches
regex_static.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12// Static regexes for validation of IP addresses
13
14#pragma once
15
16#include <regex>
17
19
20namespace openvpn::IP {
21inline const std::regex re_v4(v4_regex(), std::regex_constants::ECMAScript | std::regex_constants::nosubs);
22inline const std::regex re_v6(v6_regex(), std::regex_constants::ECMAScript | std::regex_constants::nosubs);
23
24inline bool is_ipv4_address(const std::string &host)
25{
26 return std::regex_match(host, IP::re_v4);
27}
28
29inline bool is_ipv6_address(const std::string &host)
30{
31 return std::regex_match(host, IP::re_v6);
32}
33
34inline bool is_ip_address(const std::string &host)
35{
37}
38} // namespace openvpn::IP
std::string v6_regex()
Definition regex.hpp:27
bool is_ip_address(const std::string &host)
std::string v4_regex()
Definition regex.hpp:21
bool is_ipv4_address(const std::string &host)
bool is_ipv6_address(const std::string &host)
const std::regex re_v6(v6_regex(), std::regex_constants::ECMAScript|std::regex_constants::nosubs)
const std::regex re_v4(v4_regex(), std::regex_constants::ECMAScript|std::regex_constants::nosubs)
proxy_host_port host