Added name resolution code for linux.
This commit is contained in:
@@ -17,6 +17,8 @@ struct IPv4Address
|
||||
|
||||
auto operator<=>(const IPv4Address&) const noexcept = default;
|
||||
|
||||
[[nodiscard]] std::string toString() const;
|
||||
|
||||
[[nodiscard]]
|
||||
static Optional<IPv4Address> fromString(std::string_view stringView) noexcept;
|
||||
};
|
||||
@@ -27,11 +29,23 @@ struct IPv6Address
|
||||
|
||||
auto operator<=>(const IPv6Address&) const noexcept = default;
|
||||
|
||||
[[nodiscard]] std::string toString() const;
|
||||
|
||||
[[nodiscard]]
|
||||
static Optional<IPv6Address> fromString(std::string_view stringView) noexcept;
|
||||
};
|
||||
using ip_address_t = std::variant<IPv4Address, IPv6Address>;
|
||||
|
||||
[[nodiscard]]
|
||||
inline std::string ipAddressToString(const ip_address_t& address) noexcept
|
||||
{
|
||||
if (address.valueless_by_exception())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return std::visit([](const auto& addr) { return addr.toString(); }, address);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline Optional<ip_address_t> ipAddressFromString(std::string_view stringView) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user