diff options
Diffstat (limited to 'src/connection.h')
-rw-r--r-- | src/connection.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/connection.h b/src/connection.h index 62dc8d157..da8b1b7c7 100644 --- a/src/connection.h +++ b/src/connection.h @@ -78,6 +78,7 @@ typedef struct ConnectionType { void (*ae_handler)(struct aeEventLoop *el, int fd, void *clientData, int mask); aeFileProc *accept_handler; int (*addr)(connection *conn, char *ip, size_t ip_len, int *port, int remote); + int (*is_local)(connection *conn); int (*listen)(connListener *listener); /* create/shutdown/close connection */ @@ -315,6 +316,16 @@ static inline int connAddrSockName(connection *conn, char *ip, size_t ip_len, in return connAddr(conn, ip, ip_len, port, 0); } +/* Test a connection is local or loopback. + * Return -1 on failure, 0 is not a local connection, 1 is a local connection */ +static inline int connIsLocal(connection *conn) { + if (conn && conn->type->is_local) { + return conn->type->is_local(conn); + } + + return -1; +} + static inline int connGetState(connection *conn) { return conn->state; } |