* Helper to get the formatting string of an address for a given family. * @param family The family to get the address format for. * @param with_family Whether to add the familty to the address (e.g. IPv4). * @return The format string for the address. */
| 79 | * @return The format string for the address. |
| 80 | */ |
| 81 | static std::string_view GetAddressFormatString(uint16_t family, bool with_family) |
| 82 | { |
| 83 | switch (family) { |
| 84 | case AF_INET: return with_family ? "{}:{} (IPv4)" : "{}:{}"; |
| 85 | case AF_INET6: return with_family ? "[{}]:{} (IPv6)" : "[{}]:{}"; |
| 86 | default: return with_family ? "{}:{} (IPv?)" : "{}:{}"; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Get the address as a string, e.g. 127.0.0.1:12345. |