| 258 | REGISTER_TYPE_TO_STRING(wireaddr_internal, fmt_wireaddr_internal); |
| 259 | |
| 260 | char *fmt_wireaddr_without_port(const tal_t * ctx, const struct wireaddr *a) |
| 261 | { |
| 262 | char *ret, *hex; |
| 263 | char addrstr[INET6_ADDRSTRLEN]; |
| 264 | |
| 265 | switch (a->type) { |
| 266 | case ADDR_TYPE_IPV4: |
| 267 | if (!inet_ntop(AF_INET, a->addr, addrstr, INET_ADDRSTRLEN)) |
| 268 | return "Unprintable-ipv4-address"; |
| 269 | return tal_fmt(ctx, "%s", addrstr); |
| 270 | case ADDR_TYPE_IPV6: |
| 271 | if (!inet_ntop(AF_INET6, a->addr, addrstr, INET6_ADDRSTRLEN)) |
| 272 | return "Unprintable-ipv6-address"; |
| 273 | return tal_fmt(ctx, "[%s]", addrstr); |
| 274 | case ADDR_TYPE_TOR_V2_REMOVED: |
| 275 | case ADDR_TYPE_TOR_V3: |
| 276 | return tal_fmt(ctx, "%s.onion", |
| 277 | b32_encode(tmpctx, a->addr, a->addrlen)); |
| 278 | case ADDR_TYPE_DNS: |
| 279 | return tal_fmt(ctx, "%s", a->addr); |
| 280 | case ADDR_TYPE_WEBSOCKET: |
| 281 | return tal_strdup(ctx, "websocket"); |
| 282 | } |
| 283 | |
| 284 | hex = tal_hexstr(ctx, a->addr, a->addrlen); |
| 285 | ret = tal_fmt(ctx, "Unknown type %u %s", a->type, hex); |
| 286 | tal_free(hex); |
| 287 | return ret; |
| 288 | } |
| 289 | |
| 290 | char *fmt_wireaddr(const tal_t *ctx, const struct wireaddr *a) |
| 291 | { |
no test coverage detected