summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-10-21 14:47:30 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-10-21 14:47:30 -0400
commit3f2561dec5e4510a4fe7ddfa9f310c799fc55073 (patch)
tree194ef9df582a19f0e0825165aedcdbb159a568ee /src/network.c
parent168f67a1b1ea17e3fa0a6b18bbd092e6b21765ee (diff)
downloadlighttpd1.4-3f2561dec5e4510a4fe7ddfa9f310c799fc55073.tar.gz
lighttpd1.4-3f2561dec5e4510a4fe7ddfa9f310c799fc55073.zip
[core] translate DNS to IP str for cond socket cmp
translate DNS to IP string for conditinal socket comparison in lighttpd.conf for $SERVER["socket"] == ...
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/network.c b/src/network.c
index c9ac2564..566b2567 100644
--- a/src/network.c
+++ b/src/network.c
@@ -97,8 +97,10 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
* (optimization: check strings here to filter out exact matches;
* binary addresses are matched further below) */
for (size_t i = 0; i < srv->srv_sockets.used; ++i) {
- if (buffer_is_equal(srv->srv_sockets.ptr[i]->srv_token, host_token))
+ if (buffer_is_equal(srv->srv_sockets.ptr[i]->srv_token, host_token)) {
+ buffer_copy_buffer(host_token, srv->srv_sockets.ptr[i]->srv_token);
return 0;
+ }
}
buffer_copy_buffer(srv->tmp_buf, host_token); /*(allocates ->ptr even if host_token is NULL)*/
@@ -188,8 +190,10 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
/* check if we already know this socket (after potential DNS resolution), and if yes, don't init it */
for (size_t i = 0; i < srv->srv_sockets.used; ++i) {
- if (0 == memcmp(&srv->srv_sockets.ptr[i]->addr, &addr, sizeof(addr)))
+ if (0 == memcmp(&srv->srv_sockets.ptr[i]->addr, &addr, sizeof(addr))) {
+ buffer_copy_buffer(host_token, srv->srv_sockets.ptr[i]->srv_token);
return 0;
+ }
}
srv_socket = calloc(1, sizeof(*srv_socket));
@@ -201,7 +205,9 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
srv_socket->is_ssl = s->ssl_enabled;
srv_socket->srv_token = buffer_init();
- buffer_copy_buffer(srv_socket->srv_token, host_token);
+ sock_addr_inet_ntop_copy_buffer(srv_socket->srv_token, &srv_socket->addr);
+ /* update host_token (dc->string) for consistent string comparison in lighttpd.conf conditions */
+ buffer_copy_buffer(host_token, srv_socket->srv_token);
if (srv->srv_sockets.size == 0) {
srv->srv_sockets.size = 4;
@@ -225,7 +231,6 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
log_error_write(srv, __FILE__, __LINE__, "ss", "fcntl:", strerror(errno));
return -1;
}
- sock_addr_inet_ntop_copy_buffer(srv_socket->srv_token, &srv_socket->addr);
} else
#ifdef HAVE_SYS_UN_H
if (AF_UNIX == srv_socket->addr.plain.sa_family) {