Permalink
Browse files

Selector /server-status can now be disabled and no longer leaks IP ad…

…dresses by default
  • Loading branch information...
kimholviala committed Jan 28, 2018
1 parent ff90756 commit 2b522069cdfc5e52846b40f578de6590a63d7951
Showing with 18 additions and 12 deletions.
  1. +2 −1 README
  2. +12 −10 file.c
  3. +2 −1 gophernicus.c
  4. +1 −0 gophernicus.h
  5. +1 −0 options.c
3 README
@@ -40,11 +40,12 @@ Command line options:
-nq Disable HTTP-style query strings (?query)
-ns Disable logging to syslog
-na Disable autogenerated caps.txt
-nt Disable /server-status
-nm Disable shared memory use (for debugging)
-nr Disable root user checking (for debugging)
-np Disable HAproxy proxy protocol
-d Debug to syslog (not for production use)
-d Debug output in syslog and /server-status
-v Display version number and build date
-b Display the BSD license
-? Display this help
22 file.c
@@ -204,16 +204,18 @@ void server_status(state *st, shm_state *shm, int shmid)
if ((now - shm->session[i].req_atime) < st->session_timeout) {
sessions++;
printf("Session: %-4i %-40s %-4li %-7li gopher%s://%s:%i/%c%s" CRLF,
(int) (now - shm->session[i].req_atime),
shm->session[i].req_remote_addr,
shm->session[i].hits,
shm->session[i].kbytes,
(shm->session[i].server_port == st->server_tls_port ? "s" : ""),
shm->session[i].server_host,
shm->session[i].server_port,
shm->session[i].req_filetype,
shm->session[i].req_selector);
if (st->debug) {
printf("Session: %-4i %-40s %-4li %-7li gopher%s://%s:%i/%c%s" CRLF,
(int) (now - shm->session[i].req_atime),
shm->session[i].req_remote_addr,
shm->session[i].hits,
shm->session[i].kbytes,
(shm->session[i].server_port == st->server_tls_port ? "s" : ""),
shm->session[i].server_host,
shm->session[i].server_port,
shm->session[i].req_filetype,
shm->session[i].req_selector);
}
}
}
@@ -450,6 +450,7 @@ void init_state(state *st)
st->opt_iconv = TRUE;
st->opt_query = TRUE;
st->opt_caps = TRUE;
st->opt_status = TRUE;
st->opt_shm = TRUE;
st->opt_root = TRUE;
st->opt_proxy = TRUE;
@@ -676,7 +677,7 @@ int main(int argc, char *argv[])
/* Handle /server-status requests */
#ifdef HAVE_SHMEM
if (sstrncmp(st.req_selector, SERVER_STATUS) == MATCH) {
if (st.opt_status && sstrncmp(st.req_selector, SERVER_STATUS) == MATCH) {
if (shm) server_status(&st, shm, shmid);
return OK;
}
@@ -348,6 +348,7 @@ typedef struct {
char opt_vhost;
char opt_query;
char opt_caps;
char opt_status;
char opt_shm;
char opt_root;
char opt_proxy;
@@ -140,6 +140,7 @@ void parse_args(state *st, int argc, char *argv[])
if (*optarg == 'q') { st->opt_query = FALSE; break; }
if (*optarg == 's') { st->opt_syslog = FALSE; break; }
if (*optarg == 'a') { st->opt_caps = FALSE; break; }
if (*optarg == 't') { st->opt_status = FALSE; break; }
if (*optarg == 'm') { st->opt_shm = FALSE; break; }
if (*optarg == 'r') { st->opt_root = FALSE; break; }
if (*optarg == 'p') { st->opt_proxy = FALSE; break; }

0 comments on commit 2b52206

Please sign in to comment.