MCPcopy Create free account
hub / github.com/F-Stack/f-stack / genClientAddrString

Function genClientAddrString

app/redis-6.2.6/src/networking.c:2258–2267  ·  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

2256 * you want to relax error checking or need to display something anyway (see
2257 * anetFdToString implementation for more info). */
2258void genClientAddrString(client *client, char *addr,
2259 size_t addr_len, int fd_to_str_type) {
2260 if (client->flags & CLIENT_UNIX_SOCKET) {
2261 /* Unix socket client. */
2262 snprintf(addr,addr_len,"%s:0",server.unixsocket);
2263 } else {
2264 /* TCP client. */
2265 connFormatFdAddr(client->conn,addr,addr_len,fd_to_str_type);
2266 }
2267}
2268
2269/* This function returns the client peer id, by creating and caching it
2270 * if client->peerid is NULL, otherwise returning the cached value.

Callers 2

getClientPeerIdFunction · 0.85
getClientSocknameFunction · 0.85

Calls 2

snprintfFunction · 0.85
connFormatFdAddrFunction · 0.85

Tested by

no test coverage detected