diff --git a/darkhttpd.c b/darkhttpd.c index 4648938..893782e 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -271,7 +271,8 @@ static char *logfile_name = NULL; /* NULL = no logging */ static FILE *logfile = NULL; static char *pidfile_name = NULL; /* NULL = no pidfile */ static int want_chroot = 0, want_daemon = 0, want_accf = 0, - want_keepalive = 1; + want_keepalive = 1, want_server_id = 1; +static char *server_hdr = NULL; static uint64_t num_requests = 0, total_in = 0, total_out = 0; static int running = 1; /* signal handler sets this to false */ @@ -888,6 +889,9 @@ static void usage(const char *argv0) { "\t\tRequests to the host are redirected to the corresponding url.\n" "\t\tThe option may be specified multiple times, in which case\n" "\t\tthe host is matched in order of appearance.\n\n"); + printf("\t--no-server-id\n" + "\t\tDon't identify the server type in headers\n" + "\t\tor directory listings.\n"); } /* Returns 1 if string is a number, 0 otherwise. Set num to NULL if @@ -1009,6 +1013,9 @@ static void parse_commandline(const int argc, char *argv[]) { url = argv[i]; add_forward_mapping(host, url); } + else if (strcmp(argv[i], "--no-server-id") == 0) { + want_server_id = 0; + } else errx(1, "unknown argument `%s'", argv[i]); } @@ -1285,6 +1292,19 @@ static const char *keep_alive(const struct connection *conn) return (conn->conn_close ? "Connection: close\r\n" : keep_alive_field); } +/* "Generated by " + pkgname + " on " + date + "\n" + * 1234567890123 1234 2 ('\n' and '\0') + */ +static char _generated_on_buf[13 + sizeof(pkgname) - 1 + 4 + DATE_LEN + 2]; +static const char *generated_on(const char date[DATE_LEN]) { + if (!want_server_id) + return ""; + snprintf(_generated_on_buf, sizeof(_generated_on_buf), + "Generated by %s on %s\n", + pkgname, date); + return _generated_on_buf; +} + /* A default reply for any (erroneous) occasion. */ static void default_reply(struct connection *conn, const int errcode, const char *errname, const char *format, ...) @@ -1306,21 +1326,21 @@ static void default_reply(struct connection *conn, "