From b126b55de2db9d2cffe08c10e6d7c2478379cb4b Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Wed, 3 Aug 2005 20:30:19 +0000 Subject: [PATCH] Implemented 'resolve host names' SVN revision: 1467 --- doc/config.html | 8 ++++++++ src/elogd.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/doc/config.html b/doc/config.html index 14088b97..765c6d5d 100755 --- a/doc/config.html +++ b/doc/config.html @@ -277,6 +277,14 @@ if used under stunnel, and it has to contain the directory if used under
The user and group to run the elogd daemon under when started by root.

+

  • Resolve host names = 0|1 +
    +Resolve remote host names if set to 1. If set to 0, which is the +default, only IP numbers are stored in any log file. If the hosts allow/deny +options are used with host names, this setting must be set to 1. If turned +on, the DNS server is contacted on each HTTP request to elog, which can slow down +the server considerably for slow DNS servers.

    +


    diff --git a/src/elogd.c b/src/elogd.c index aa991a62..127a4784 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.735 2005/08/03 20:30:19 ritt + Implemented 'resolve host names' + Revision 1.734 2005/08/02 18:39:12 ritt Remove obsolete options @@ -3694,7 +3697,8 @@ void free_config() xfree(lb_config[i].config_param[j].uparam); xfree(lb_config[i].config_param[j].value); } - xfree(lb_config[i].config_param); + if (lb_config[i].config_param) + xfree(lb_config[i].config_param); xfree(lb_config[i].section_name); } xfree(lb_config); @@ -3745,6 +3749,7 @@ int parse_config_file(char *file_name) lb_config = xrealloc(lb_config, sizeof(LB_CONFIG) * (n_lb_config + 1)); lb_config[n_lb_config].section_name = xmalloc(strlen(str) + 1); lb_config[n_lb_config].n_params = 0; + lb_config[n_lb_config].config_param = NULL; strcpy(lb_config[n_lb_config].section_name, str); /* enumerate parameters */ @@ -23619,11 +23624,16 @@ void server_loop(void) /* save remote host address */ memcpy(&remote_addr[i_conn], &(acc_addr.sin_addr), sizeof(rem_addr)); memcpy(&rem_addr, &(acc_addr.sin_addr), sizeof(rem_addr)); - phe = gethostbyaddr((char *) &rem_addr, 4, PF_INET); - if (phe != NULL) - strcpy(remote_host[i_conn], phe->h_name); - else + + if (getcfg("global", "Resolve host names", str, sizeof(str)) && atoi(str) == 1) { + phe = gethostbyaddr((char *) &rem_addr, 4, PF_INET); + if (phe != NULL) + strcpy(remote_host[i_conn], phe->h_name); + else + strcpy(remote_host[i_conn], (char *) inet_ntoa(rem_addr)); + } else strcpy(remote_host[i_conn], (char *) inet_ntoa(rem_addr)); + strcpy(rem_host, remote_host[i_conn]); #ifdef DEBUG_CONN eprintf("## open new connection %d\n", i_conn); @@ -23890,12 +23900,18 @@ void server_loop(void) #else rem_addr.s_addr = inet_addr(str); #endif - phe = gethostbyaddr((char *) &rem_addr, 4, PF_INET); - if (phe != NULL) { - strcpy(remote_host[i_conn], phe->h_name); - strcpy(rem_host, remote_host[i_conn]); - } - } + + if (getcfg("global", "Resolve host names", str, sizeof(str)) && atoi(str) == 1) { + phe = gethostbyaddr((char *) &rem_addr, 4, PF_INET); + if (phe != NULL) + strcpy(remote_host[i_conn], phe->h_name); + else + strcpy(remote_host[i_conn], (char *) inet_ntoa(rem_addr)); + } else + strcpy(remote_host[i_conn], (char *) inet_ntoa(rem_addr)); + + strcpy(rem_host, remote_host[i_conn]); + } memset(return_buffer, 0, return_buffer_size); strlen_retbuf = 0;