MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / nodeIp2String

Function nodeIp2String

src/cluster.cpp:1588–1595  ·  view source on GitHub ↗

IP -> string conversion. 'buf' is supposed to at least be 46 bytes. * If 'announced_ip' length is non-zero, it is used instead of extracting * the IP from the socket peer address. */

Source from the content-addressed store, hash-verified

1586 * If 'announced_ip' length is non-zero, it is used instead of extracting
1587 * the IP from the socket peer address. */
1588void nodeIp2String(char *buf, clusterLink *link, char *announced_ip) {
1589 if (announced_ip[0] != '\0') {
1590 memcpy(buf,announced_ip,NET_IP_STR_LEN);
1591 buf[NET_IP_STR_LEN-1] = '\0'; /* We are not sure the input is sane. */
1592 } else {
1593 connPeerToString(link->conn, buf, NET_IP_STR_LEN, NULL);
1594 }
1595}
1596
1597/* Update the node address to the IP address that can be extracted
1598 * from link->fd, or if hdr->myip is non empty, to the address the node

Callers 2

clusterProcessPacketFunction · 0.85

Calls 1

connPeerToStringFunction · 0.85

Tested by

no test coverage detected