• zhenwei pi's avatar
    Introduce connAddr · bff7ecc7
    zhenwei pi authored
    
    
    Originally, connPeerToString is designed to get the address info from
    socket only(for both TCP & TLS), and the API 'connPeerToString' is
    oriented to operate a FD like:
    int connPeerToString(connection *conn, char *ip, size_t ip_len, int *port) {
        return anetFdToString(conn ? conn->fd : -1, ip, ip_len, port, FD_TO_PEER_NAME);
    }
    
    Introduce connAddr and implement .addr method for socket and TLS,
    thus the API 'connAddr' and 'connFormatAddr' become oriented to a
    connection like:
    static inline int connAddr(connection *conn, char *ip, size_t ip_len, int *port, int remote) {
        if (conn && conn->type->addr) {
            return conn->type->addr(conn, ip, ip_len, port, remote);
        }
    
        return -1;
    }
    
    Also remove 'FD_TO_PEER_NAME' & 'FD_TO_SOCK_NAME', use a boolean type
    'remote' to get local/remote address of a connection.
    
    With these changes, it's possible to support the other connection
    types which does not use socket(Ex, RDMA).
    
    Thanks to Oran for suggestions!
    Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
    bff7ecc7
redis-cli.c 340 KB