|
|
|
|
@ -779,6 +779,30 @@ char* utun_bridge_get_member_links_json(uint64_t node_id) {
|
|
|
|
|
"%s{\"fm\":%d,\"ad\":\"%s\",\"po\":%d,\"st\":%d,\"ls\":%d}", |
|
|
|
|
sep, fm, ip, (int)po, lk->link_state, lk->link_status); |
|
|
|
|
} |
|
|
|
|
if (conn->transport_link) { |
|
|
|
|
struct stcp_link* tcp = (struct stcp_link*)conn->transport_link; |
|
|
|
|
const struct sockaddr_storage* sa = stcp_link_get_remote_addr(tcp); |
|
|
|
|
if (sa && pos < (int)sizeof(buf) - 100) { |
|
|
|
|
char ip[INET6_ADDRSTRLEN] = ""; |
|
|
|
|
int fm = 0; uint16_t po = 0; |
|
|
|
|
if (sa->ss_family == AF_INET) { |
|
|
|
|
struct sockaddr_in* sin = (struct sockaddr_in*)sa; |
|
|
|
|
inet_ntop(AF_INET, &sin->sin_addr, ip, sizeof(ip)); |
|
|
|
|
fm = 4; po = ntohs(sin->sin_port); |
|
|
|
|
} else if (sa->ss_family == AF_INET6) { |
|
|
|
|
struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa; |
|
|
|
|
inet_ntop(AF_INET6, &sin6->sin6_addr, ip, sizeof(ip)); |
|
|
|
|
fm = 6; po = ntohs(sin6->sin6_port); |
|
|
|
|
} |
|
|
|
|
if (ip[0]) { |
|
|
|
|
int ready = stcp_link_is_ready(tcp); |
|
|
|
|
const char* sep = first ? "" : ","; |
|
|
|
|
pos += snprintf(buf + pos, sizeof(buf) - (size_t)pos, |
|
|
|
|
"%s{\"fm\":%d,\"ad\":\"%s\",\"po\":%d,\"st\":%d,\"ls\":%d}", |
|
|
|
|
sep, fm, ip, (int)po, ready ? 3 : 1, ready ? 1 : 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
pos += snprintf(buf + pos, sizeof(buf) - (size_t)pos, "]}"); |
|
|
|
|
return u_strdup(buf); |
|
|
|
|
} |
|
|
|
|
|