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

Function genClientAddrString

src/networking.cpp:2837–2846  ·  view source on GitHub ↗

A Redis "Address String" is a colon separated ip:port pair. * For IPv4 it's in the form x.y.z.k:port, example: "127.0.0.1:1234". * For IPv6 addresses we use [] around the IP part, like in "[::1]:1234". * For Unix sockets we use path:0, like in "/tmp/redis:0". * * An Address String always fits inside a buffer of NET_ADDR_STR_LEN bytes, * including the null term. * * On failure the function

Source from the content-addressed store, hash-verified

2835 * you want to relax error checking or need to display something anyway (see
2836 * anetFdToString implementation for more info). */
2837void genClientAddrString(client *client, char *addr,
2838 size_t addr_len, int fd_to_str_type) {
2839 if (client->flags & CLIENT_UNIX_SOCKET) {
2840 /* Unix socket client. */
2841 snprintf(addr,addr_len,"%s:0",g_pserver->unixsocket);
2842 } else {
2843 /* TCP client. */
2844 connFormatFdAddr(client->conn,addr,addr_len,fd_to_str_type);
2845 }
2846}
2847
2848/* This function returns the client peer id, by creating and caching it
2849 * if client->peerid is NULL, otherwise returning the cached value.

Callers 2

getClientPeerIdFunction · 0.85
getClientSocknameFunction · 0.85

Calls 1

connFormatFdAddrFunction · 0.85

Tested by

no test coverage detected