From d9e96a55e7e1794d6f6d6e6542e3eba90b1e00d8 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 30 Jun 2018 14:06:05 +0000 Subject: [PATCH] Feature: Allow to match on a specific listen-socket --- src/cfgfile.c | 7 +++++++ src/cfgfile.h | 1 + src/connection.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/cfgfile.c b/src/cfgfile.c index 0a5347bd..87e46883 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -596,6 +596,7 @@ static void config_clear_resource(resource_t *resource) xmlFree(resource->vhost); xmlFree(resource->module); xmlFree(resource->handler); + free(resource->listen_socket); free(resource); resource = nextresource; } @@ -2007,6 +2008,12 @@ static void _parse_resource(xmlDocPtr doc, resource->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address")); + temp = (char *)xmlGetProp(node, XMLSTR("listen-socket")); + if (temp) { + resource->listen_socket = config_href_to_id(temp); + xmlFree(temp); + } + resource->vhost = (char *)xmlGetProp(node, XMLSTR("vhost")); resource->module = (char *)xmlGetProp(node, XMLSTR("module")); diff --git a/src/cfgfile.h b/src/cfgfile.h index b9cee049..e7f0b071 100644 --- a/src/cfgfile.h +++ b/src/cfgfile.h @@ -139,6 +139,7 @@ typedef struct _resource { char *destination; int port; char *bind_address; + char *listen_socket; char *vhost; char *module; char *handler; diff --git a/src/connection.c b/src/connection.c index 15d6a727..02ec6dfd 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1176,6 +1176,9 @@ static int _handle_resources(client_t *client, char **uri) if (resource->bind_address != NULL && serverhost != NULL && strcmp(resource->bind_address, serverhost) != 0) continue; + if (resource->listen_socket != NULL && (listen_sock->id == NULL || strcmp(resource->listen_socket, listen_sock->id) != 0)) + continue; + /* Check for the vhost to match. */ if (resource->vhost != NULL && vhost != NULL && strcmp(resource->vhost, vhost) != 0) continue;