From e4ceea33dac83d3c2ea668141ddd51abf5342d0c Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 10 Jul 2016 11:56:31 +0100 Subject: [PATCH] Disable the internal webserver at build time. --- dump1090.c | 10 ++++++++++ dump1090.h | 2 ++ net_io.c | 14 ++++++++++++-- stats.c | 4 ++++ stats.h | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/dump1090.c b/dump1090.c index 41f8572..a2a6a31 100644 --- a/dump1090.c +++ b/dump1090.c @@ -150,7 +150,9 @@ void modesInitConfig(void) { Modes.net_output_sbs_ports = strdup("30003"); Modes.net_input_beast_ports = strdup("30004,30104"); Modes.net_output_beast_ports = strdup("30005"); +#ifdef ENABLE_WEBSERVER Modes.net_http_ports = strdup("8080"); +#endif Modes.interactive_rows = getTermRows(); Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; Modes.html_dir = HTMLPATH; @@ -680,7 +682,9 @@ void showHelp(void) { "--modeac Enable decoding of SSR Modes 3/A & 3/C\n" "--net-only Enable just networking, no RTL device or file used\n" "--net-bind-address IP address to bind to (default: Any; Use 127.0.0.1 for private)\n" +#ifdef ENABLE_WEBSERVER "--net-http-port HTTP server ports (default: 8080)\n" +#endif "--net-ri-port TCP raw input listen ports (default: 30001)\n" "--net-ro-port TCP raw output listen ports (default: 30002)\n" "--net-sbs-port TCP BaseStation output listen ports (default: 30003)\n" @@ -993,8 +997,14 @@ int main(int argc, char **argv) { free(Modes.net_bind_address); Modes.net_bind_address = strdup(argv[++j]); } else if (!strcmp(argv[j],"--net-http-port") && more) { +#ifdef ENABLE_WEBSERVER free(Modes.net_http_ports); Modes.net_http_ports = strdup(argv[++j]); +#else + if (strcmp(argv[++j], "0")) { + fprintf(stderr, "warning: --net-http-port not supported in this build, option ignored.\n"); + } +#endif } else if (!strcmp(argv[j],"--net-sbs-port") && more) { free(Modes.net_output_sbs_ports); Modes.net_output_sbs_ports = strdup(argv[++j]); diff --git a/dump1090.h b/dump1090.h index 26a7941..d98353e 100644 --- a/dump1090.h +++ b/dump1090.h @@ -292,7 +292,9 @@ struct { // Internal state char *net_output_sbs_ports; // List of SBS output TCP ports char *net_input_beast_ports; // List of Beast input TCP ports char *net_output_beast_ports; // List of Beast output TCP ports +#ifdef ENABLE_WEBSERVER char *net_http_ports; // List of HTTP ports +#endif char *net_bind_address; // Bind address int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n) int net_verbatim; // if true, send the original message, not the CRC-corrected one diff --git a/net_io.c b/net_io.c index d2b0a89..2d5dfc4 100644 --- a/net_io.c +++ b/net_io.c @@ -69,7 +69,9 @@ static int decodeBinMessage(struct client *c, char *p); static int decodeHexMessage(struct client *c, char *hex); +#ifdef ENABLE_WEBSERVER static int handleHTTPRequest(struct client *c, char *p); +#endif static void send_raw_heartbeat(struct net_service *service); static void send_beast_heartbeat(struct net_service *service); @@ -258,8 +260,10 @@ void modesInitNet(void) { s = makeBeastInputService(); serviceListen(s, Modes.net_bind_address, Modes.net_input_beast_ports); +#ifdef ENABLE_WEBSERVER s = serviceInit("HTTP server", NULL, NULL, "\r\n\r\n", handleHTTPRequest); serviceListen(s, Modes.net_bind_address, Modes.net_http_ports); +#endif } // //========================================================================= @@ -1083,9 +1087,11 @@ static char * appendStatsJson(char *p, else p += snprintf(p, end-p, ",%u", st->remote_accepted[i]); } - p += snprintf(p, end-p, "]"); + p += snprintf(p, end-p, "]}"); - p += snprintf(p, end-p, "},\"http_requests\":%u", st->http_requests); +#ifdef ENABLE_WEBSERVER + p += snprintf(p, end-p, ",\"http_requests\":%u", st->http_requests); +#endif } { @@ -1277,6 +1283,7 @@ void writeJsonToFile(const char *file, char * (*generator) (const char *,int*)) } +#ifdef ENABLE_WEBSERVER // //========================================================================= @@ -1471,6 +1478,9 @@ static int handleHTTPRequest(struct client *c, char *p) { Modes.stats_current.http_requests++; return !keepalive; } + +#endif + // //========================================================================= // diff --git a/stats.c b/stats.c index 46ee2a7..38ae169 100644 --- a/stats.c +++ b/stats.c @@ -155,8 +155,10 @@ void display_stats(struct stats *st) { printf("%u unique aircraft tracks\n", st->unique_aircraft); printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft); +#ifdef ENABLE_WEBSERVER if (Modes.net) printf("%d HTTP requests\n", st->http_requests); +#endif { uint64_t demod_cpu_millis = (uint64_t)st->demod_cpu.tv_sec*1000UL + st->demod_cpu.tv_nsec/1000000UL; @@ -307,8 +309,10 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t // total messages: target->messages_total = st1->messages_total + st2->messages_total; +#ifdef ENABLE_WEBSERVER // network: target->http_requests = st1->http_requests + st2->http_requests; +#endif // CPR decoding: target->cpr_surface = st1->cpr_surface + st2->cpr_surface; diff --git a/stats.h b/stats.h index fee4d7d..cfbd854 100644 --- a/stats.h +++ b/stats.h @@ -95,8 +95,10 @@ struct stats { // total messages: uint32_t messages_total; +#ifdef ENABLE_WEBSERVER // network: uint32_t http_requests; +#endif // CPR decoding: unsigned int cpr_surface;