8 #include <glog/logging.h>
11 using namespace std::literals::string_view_literals
;
13 auto is_private(std::string_view addr
) -> bool;
14 auto is_address(std::string_view addr
) -> bool;
15 auto is_address_literal(std::string_view addr
) -> bool;
16 auto to_address_literal(std::string_view addr
) -> std::string
;
17 auto reverse(std::string_view addr
) -> std::string
;
18 auto fcrdns(std::string_view addr
) -> std::vector
<std::string
>;
20 auto constexpr lit_pfx
{"["sv
};
21 auto constexpr lit_pfx_sz
{std::size(lit_pfx
)};
23 auto constexpr lit_sfx
{"]"sv
};
24 auto constexpr lit_sfx_sz
{std::size(lit_sfx
)};
26 auto constexpr lit_extra_sz
{lit_pfx_sz
+ lit_sfx_sz
};
28 auto constexpr loopback_literal
{"[127.0.0.1]"sv
};
30 constexpr auto as_address(std::string_view address_literal
) -> std::string_view
32 // CHECK(is_address_literal(address_literal));
33 return address_literal
.substr(lit_pfx_sz
,
34 address_literal
.length() - lit_extra_sz
);