Commit 8c850a29 authored by Mark Andrews's avatar Mark Andrews

2280. [func] Allow the experimental http server to be reached

                        over IPv6 as well as IPv4. [RT #17332]
parent da31aff2
2280. [func] Allow the experimental http server to be reached
over IPv6 as well as IPv4. [RT #17332]
2279. [bug] Use setsockopt(SO_NOSIGPIPE), when available,
to protect applications from receiving spurious
SIGPIPE signals when using the resolver.
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.h,v 1.87 2007/06/19 23:46:59 tbox Exp $ */
/* $Id: server.h,v 1.88 2007/12/14 04:01:20 marka Exp $ */
#ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1
......@@ -100,8 +100,10 @@ struct ns_server {
dns_acache_t *acache;
isc_httpdmgr_t *httpd;
isc_sockaddr_t httpd_sockaddr;
isc_httpdmgr_t *httpd4;
isc_sockaddr_t httpd_sockaddr4;
isc_httpdmgr_t *httpd6;
isc_sockaddr_t httpd_sockaddr6;
};
#define NS_SERVER_MAGIC ISC_MAGIC('S','V','E','R')
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.494 2007/12/02 18:56:03 marka Exp $ */
/* $Id: server.c,v 1.495 2007/12/14 04:01:20 marka Exp $ */
/*! \file */
......@@ -222,8 +222,8 @@ static const struct {
#ifdef HAVE_LIBXML2
void
server_httpd_create(ns_server_t *server);
static isc_result_t
server_httpd_create(ns_server_t *server, int pf);
static isc_result_t
render_index(const char *url, const char *querystring, void *args,
......@@ -2992,24 +2992,37 @@ load_configuration(const char *filename, ns_server_t *server,
* XXXMLG this will have to change later. Eventually, we will want
* XXXMLG to start it once, and add/remove listener ports as the
* XXXMLG user wants, which will allow more than one.
* XXXMLG We will also want to support IPv6 and some form of ACL.
* XXXMLG We will also want to support some form of ACL.
*/
obj = NULL;
result = ns_config_get(maps, "stats-server", &obj);
if (result == ISC_R_SUCCESS && obj != NULL) {
if (!isc_sockaddr_equal(cfg_obj_assockaddr(obj),
&server->httpd_sockaddr)) {
if (server->httpd != NULL)
isc_httpdmgr_shutdown(&server->httpd);
server->httpd_sockaddr = *cfg_obj_assockaddr(obj);
server_httpd_create(server);
&server->httpd_sockaddr4)) {
if (server->httpd4 != NULL)
isc_httpdmgr_shutdown(&server->httpd4);
server->httpd_sockaddr4 = *cfg_obj_assockaddr(obj);
CHECKM(server_httpd_create(server, AF_INET),
"stats-server");
}
} else if (server->httpd4 != NULL)
isc_httpdmgr_shutdown(&server->httpd4);
obj = NULL;
result = ns_config_get(maps, "stats-server-v6", &obj);
if (result == ISC_R_SUCCESS && obj != NULL) {
if (!isc_sockaddr_equal(cfg_obj_assockaddr(obj),
&server->httpd_sockaddr6)) {
if (server->httpd6 != NULL)
isc_httpdmgr_shutdown(&server->httpd6);
server->httpd_sockaddr6 = *cfg_obj_assockaddr(obj);
CHECKM(server_httpd_create(server, AF_INET6),
"stats-server-v6");
}
} else {
if (server->httpd != NULL)
isc_httpdmgr_shutdown(&server->httpd);
}
} else if (server->httpd6 != NULL)
isc_httpdmgr_shutdown(&server->httpd6);
#endif
v4ports = NULL;
......@@ -3689,8 +3702,10 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
flush ? ": flushing changes" : "");
#ifdef HAVE_LIBXML2
if (server->httpd != NULL)
isc_httpdmgr_shutdown(&server->httpd);
if (server->httpd4 != NULL)
isc_httpdmgr_shutdown(&server->httpd4);
if (server->httpd6 != NULL)
isc_httpdmgr_shutdown(&server->httpd6);
#endif
ns_controls_shutdown(server->controls);
......@@ -3735,12 +3750,12 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
#ifdef HAVE_LIBXML2
void
server_httpd_create(ns_server_t *server)
{
static isc_result_t
server_httpd_create(ns_server_t *server, int pf) {
isc_socket_t *sock;
isc_task_t *task;
isc_result_t result;
isc_httpdmgr_t *httpd;
task = NULL;
result = isc_task_create(ns_g_taskmgr, 0, &task);
......@@ -3748,24 +3763,42 @@ server_httpd_create(ns_server_t *server)
isc_task_setname(task, "httpd", NULL);
sock = NULL;
result = isc_socket_create(ns_g_socketmgr, PF_INET,
isc_sockettype_tcp, &sock);
INSIST(result == ISC_R_SUCCESS);
result = isc_socket_create(ns_g_socketmgr, pf, isc_sockettype_tcp,
&sock);
if (result != ISC_R_SUCCESS)
return (result);
isc_socket_setname(sock, "httpd", NULL);
result = isc_socket_bind(sock, &server->httpd_sockaddr);
INSIST(result == ISC_R_SUCCESS);
#ifndef ISC_ALLOW_MAPPED
isc_socket_ipv6only(sock, ISC_TRUE);
#endif
if (pf == AF_INET)
result = isc_socket_bind(sock, &server->httpd_sockaddr4);
else
result = isc_socket_bind(sock, &server->httpd_sockaddr6);
if (result != ISC_R_SUCCESS)
goto cleanup;
server->httpd = NULL;
httpd = NULL;
result = isc_httpdmgr_create(ns_g_mctx, sock, task, ns_g_timermgr,
&server->httpd);
INSIST(result == ISC_R_SUCCESS);
&httpd);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_httpdmgr_addurl(server->httpd, "/", render_index, server);
isc_httpdmgr_addurl(server->httpd, "/bind9.xsl", render_xsl, server);
isc_httpdmgr_addurl(httpd, "/", render_index, server);
isc_httpdmgr_addurl(httpd, "/bind9.xsl", render_xsl, server);
if (pf == AF_INET)
server->httpd4 = httpd;
else
server->httpd6 = httpd;
cleanup:
isc_task_detach(&task);
isc_socket_detach(&sock);
return (result);
}
#endif
......@@ -3882,7 +3915,10 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
/*
* HTTP server configuration.
*/
server->httpd = NULL;
server->httpd4 = NULL;
isc_sockaddr_any(&server->httpd_sockaddr4);
server->httpd6 = NULL;
isc_sockaddr_any6(&server->httpd_sockaddr6);
server->magic = NS_SERVER_MAGIC;
*serverp = server;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment