From 3713346f3959782c5e5d1ddd0252f25fb319d732 Mon Sep 17 00:00:00 2001 From: Salvador Fandino Date: Wed, 20 Apr 2016 16:22:56 +0200 Subject: Provide support for channel endpoints being UNIX file sockets in addition to being TCP/IP sockets. --- nxcomp/Proxy.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'nxcomp/Proxy.cpp') diff --git a/nxcomp/Proxy.cpp b/nxcomp/Proxy.cpp index 7655ccb40..1693590db 100644 --- a/nxcomp/Proxy.cpp +++ b/nxcomp/Proxy.cpp @@ -65,6 +65,7 @@ struct sockaddr_un #include "ClientChannel.h" #include "ServerChannel.h" #include "GenericChannel.h" +#include "ChannelEndPoint.h" // // We need to adjust some values related @@ -6053,8 +6054,36 @@ int Proxy::handleNewSlaveConnection(int clientFd) return handleNewGenericConnection(clientFd, channel_slave, "slave"); } + + int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, - const char *hostname, int port, const char *label) + ChannelEndPoint &endPoint, const char *label) +{ + char *unixPath, *host; + long port; + + if (endPoint.getUnixPath(&unixPath)) { + return handleNewGenericConnectionFromProxyUnix(channelId, type, unixPath, label); + } + + if (endPoint.getTCPHostAndPort(&host, &port)) { + return handleNewGenericConnectionFromProxyTCP(channelId, type, host, port, label); + } + + #ifdef WARNING + *logofs << "Proxy: WARNING! Refusing attempted connection " + << "to " << label << " server.\n" << logofs_flush; + #endif + + cerr << "Warning" << ": Refusing attempted connection " + << "to " << label << " server.\n"; + + return -1; +} + +int Proxy::handleNewGenericConnectionFromProxyTCP(int channelId, T_channel_type type, + const char *hostname, long port, const char *label) + { if (port <= 0) { @@ -6173,8 +6202,8 @@ int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type typ return 1; } -int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, - const char *hostname, const char *path, const char *label) +int Proxy::handleNewGenericConnectionFromProxyUnix(int channelId, T_channel_type type, + const char *path, const char *label) { if (path == NULL || *path == '\0' ) { -- cgit v1.2.3