Project

General

Profile

Feature #2653 ยป 0001-mod_proxy-add-unix-domain-socket-support.patch

Patch adding unix domain socket support - bachp, 2015-07-09 13:49

View differences:

src/mod_proxy.c
static int proxy_establish_connection(server *srv, handler_ctx *hctx) {
struct sockaddr *proxy_addr;
struct sockaddr_in proxy_addr_in;
#ifdef HAVE_SYS_UN_H
struct sockaddr_un proxy_addr_un;
#endif
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
struct sockaddr_in6 proxy_addr_in6;
#endif
......
int proxy_fd = hctx->fd;
#ifdef HAVE_SYS_UN_H
if (strstr(host->host->ptr, "/")) {
memset(&proxy_addr_un, 0, sizeof(proxy_addr_un));
proxy_addr_un.sun_family = AF_UNIX;
strcpy(proxy_addr_un.sun_path, host->host->ptr);
servlen = sizeof(proxy_addr_un);
proxy_addr = (struct sockaddr *) &proxy_addr_un;
} else
#endif
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
if (strstr(host->host->ptr, ":")) {
memset(&proxy_addr_in6, 0, sizeof(proxy_addr_in6));
......
break;
case PROXY_STATE_INIT:
#ifdef HAVE_SYS_UN_H
if (strstr(host->host->ptr,"/")) {
if (-1 == (hctx->fd = socket(AF_UNIX, SOCK_STREAM, 0))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
return HANDLER_ERROR;
}
} else
#endif
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
if (strstr(host->host->ptr,":")) {
if (-1 == (hctx->fd = socket(AF_INET6, SOCK_STREAM, 0))) {
    (1-1/1)