Merge branch 'upstream'

This commit is contained in:
Oliver Jowett 2016-07-10 14:58:49 +01:00
commit bf2b8efee6
10 changed files with 43 additions and 134 deletions

3
debian/control vendored
View file

@ -9,7 +9,8 @@ Vcs-Git: https://github.com/mutability/dump1090.git
Package: dump1090-fa Package: dump1090-fa
Architecture: any Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, python(>=2.5), cron | cron-daemon, curl, lighttpd Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, lighttpd
Provides: fatsv-data-source
Description: ADS-B Ground Station System for RTL-SDR Description: ADS-B Ground Station System for RTL-SDR
Networked Aviation Mode S / ADS-B decoder/translator with RTL-SDR software Networked Aviation Mode S / ADS-B decoder/translator with RTL-SDR software
defined radio USB device support. defined radio USB device support.

12
debian/cron-template vendored
View file

@ -1,12 +0,0 @@
## TEMPLATE FILE - This is used to create /etc/cron.d/dump1090-mutability ##
## The first three lines will be discarded ##
# Checks for updates to the VRS aircraft database once a day at around 5am;
# when an update is available, downloads it and regenerates the JSON data
# used by the webmap.
# NB: the minute value below is randomly generated on install, to avoid
# all installs hitting the server at the same time.
# m h dom mon dow user command
@MIN@ 5 @DOM@ * * @USER@ test -x /usr/share/dump1090-fa/update-aircraft-database.sh && /usr/share/dump1090-fa/update-aircraft-database.sh --log-to-file

View file

@ -8,5 +8,5 @@
RECEIVER_OPTIONS="--device-index 0 --gain -10 --ppm 0 --net-bo-port 30005" RECEIVER_OPTIONS="--device-index 0 --gain -10 --ppm 0 --net-bo-port 30005"
DECODER_OPTIONS="--max-range 300" DECODER_OPTIONS="--max-range 300"
NET_OPTIONS="--net --net-heartbeat 60 --net-ro-size 1000 --net-ro-interval 1 --net-http-port 0 --net-ri-port 0 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005" NET_OPTIONS="--net --net-heartbeat 60 --net-ro-size 1000 --net-ro-interval 1 --net-ri-port 0 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005"
JSON_OPTIONS="--json-location-accuracy 1" JSON_OPTIONS="--json-location-accuracy 1"

View file

@ -20,19 +20,20 @@ set -e
case "$1" in case "$1" in
remove)
echo "Disabling dump1090-fa lighttpd integration.." >&2
lighty-disable-mod dump1090-fa || echo "warning: failed to disable lighttpd module" >&2
invoke-rc.d lighttpd restart || echo "warning: failed to restart lighttpd" >&2
;;
purge) purge)
rm -f /etc/default/dump1090-fa rm -f /etc/default/dump1090-fa
rm -f /etc/cron.d/dump1090-fa
rm -rf /var/cache/dump1090-fa
;; ;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) remove)
if [ -e /etc/lighttpd/conf-enabled/89-dump1090.conf ]; then
echo "Disabling lighttpd integration.." >&2
lighty-disable-mod dump1090 || true
echo "Restarting lighttpd.." >&2
invoke-rc.d lighttpd restart || echo "Warning: lighttpd failed to restart." >&2
fi
;;
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;; ;;
*) *)

View file

@ -150,7 +150,9 @@ void modesInitConfig(void) {
Modes.net_output_sbs_ports = strdup("30003"); Modes.net_output_sbs_ports = strdup("30003");
Modes.net_input_beast_ports = strdup("30004,30104"); Modes.net_input_beast_ports = strdup("30004,30104");
Modes.net_output_beast_ports = strdup("30005"); Modes.net_output_beast_ports = strdup("30005");
#ifdef ENABLE_WEBSERVER
Modes.net_http_ports = strdup("8080"); Modes.net_http_ports = strdup("8080");
#endif
Modes.interactive_rows = getTermRows(); Modes.interactive_rows = getTermRows();
Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL;
Modes.html_dir = HTMLPATH; Modes.html_dir = HTMLPATH;
@ -680,7 +682,9 @@ void showHelp(void) {
"--modeac Enable decoding of SSR Modes 3/A & 3/C\n" "--modeac Enable decoding of SSR Modes 3/A & 3/C\n"
"--net-only Enable just networking, no RTL device or file used\n" "--net-only Enable just networking, no RTL device or file used\n"
"--net-bind-address <ip> IP address to bind to (default: Any; Use 127.0.0.1 for private)\n" "--net-bind-address <ip> IP address to bind to (default: Any; Use 127.0.0.1 for private)\n"
#ifdef ENABLE_WEBSERVER
"--net-http-port <ports> HTTP server ports (default: 8080)\n" "--net-http-port <ports> HTTP server ports (default: 8080)\n"
#endif
"--net-ri-port <ports> TCP raw input listen ports (default: 30001)\n" "--net-ri-port <ports> TCP raw input listen ports (default: 30001)\n"
"--net-ro-port <ports> TCP raw output listen ports (default: 30002)\n" "--net-ro-port <ports> TCP raw output listen ports (default: 30002)\n"
"--net-sbs-port <ports> TCP BaseStation output listen ports (default: 30003)\n" "--net-sbs-port <ports> TCP BaseStation output listen ports (default: 30003)\n"
@ -993,8 +997,14 @@ int main(int argc, char **argv) {
free(Modes.net_bind_address); free(Modes.net_bind_address);
Modes.net_bind_address = strdup(argv[++j]); Modes.net_bind_address = strdup(argv[++j]);
} else if (!strcmp(argv[j],"--net-http-port") && more) { } else if (!strcmp(argv[j],"--net-http-port") && more) {
#ifdef ENABLE_WEBSERVER
free(Modes.net_http_ports); free(Modes.net_http_ports);
Modes.net_http_ports = strdup(argv[++j]); 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) { } else if (!strcmp(argv[j],"--net-sbs-port") && more) {
free(Modes.net_output_sbs_ports); free(Modes.net_output_sbs_ports);
Modes.net_output_sbs_ports = strdup(argv[++j]); Modes.net_output_sbs_ports = strdup(argv[++j]);

View file

@ -292,7 +292,9 @@ struct { // Internal state
char *net_output_sbs_ports; // List of SBS output TCP ports char *net_output_sbs_ports; // List of SBS output TCP ports
char *net_input_beast_ports; // List of Beast input TCP ports char *net_input_beast_ports; // List of Beast input TCP ports
char *net_output_beast_ports; // List of Beast output TCP ports char *net_output_beast_ports; // List of Beast output TCP ports
#ifdef ENABLE_WEBSERVER
char *net_http_ports; // List of HTTP ports char *net_http_ports; // List of HTTP ports
#endif
char *net_bind_address; // Bind address char *net_bind_address; // Bind address
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n) 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 int net_verbatim; // if true, send the original message, not the CRC-corrected one

View file

@ -69,7 +69,9 @@
static int decodeBinMessage(struct client *c, char *p); static int decodeBinMessage(struct client *c, char *p);
static int decodeHexMessage(struct client *c, char *hex); static int decodeHexMessage(struct client *c, char *hex);
#ifdef ENABLE_WEBSERVER
static int handleHTTPRequest(struct client *c, char *p); static int handleHTTPRequest(struct client *c, char *p);
#endif
static void send_raw_heartbeat(struct net_service *service); static void send_raw_heartbeat(struct net_service *service);
static void send_beast_heartbeat(struct net_service *service); static void send_beast_heartbeat(struct net_service *service);
@ -258,8 +260,10 @@ void modesInitNet(void) {
s = makeBeastInputService(); s = makeBeastInputService();
serviceListen(s, Modes.net_bind_address, Modes.net_input_beast_ports); 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); s = serviceInit("HTTP server", NULL, NULL, "\r\n\r\n", handleHTTPRequest);
serviceListen(s, Modes.net_bind_address, Modes.net_http_ports); 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]); 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++; Modes.stats_current.http_requests++;
return !keepalive; return !keepalive;
} }
#endif
// //
//========================================================================= //=========================================================================
// //

View file

@ -155,8 +155,10 @@ void display_stats(struct stats *st) {
printf("%u unique aircraft tracks\n", st->unique_aircraft); printf("%u unique aircraft tracks\n", st->unique_aircraft);
printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft); printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft);
#ifdef ENABLE_WEBSERVER
if (Modes.net) if (Modes.net)
printf("%d HTTP requests\n", st->http_requests); 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; 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: // total messages:
target->messages_total = st1->messages_total + st2->messages_total; target->messages_total = st1->messages_total + st2->messages_total;
#ifdef ENABLE_WEBSERVER
// network: // network:
target->http_requests = st1->http_requests + st2->http_requests; target->http_requests = st1->http_requests + st2->http_requests;
#endif
// CPR decoding: // CPR decoding:
target->cpr_surface = st1->cpr_surface + st2->cpr_surface; target->cpr_surface = st1->cpr_surface + st2->cpr_surface;

View file

@ -95,8 +95,10 @@ struct stats {
// total messages: // total messages:
uint32_t messages_total; uint32_t messages_total;
#ifdef ENABLE_WEBSERVER
// network: // network:
uint32_t http_requests; uint32_t http_requests;
#endif
// CPR decoding: // CPR decoding:
unsigned int cpr_surface; unsigned int cpr_surface;

View file

@ -1,109 +0,0 @@
#!/bin/bash
# This script checks for a new version of BasicAircraftLookup from
# the VRS website and, if one is available, downloads it and updates
# the dump1090 webmap json files.
set -e
# defaults that can be overridden:
VRS_URL=${VRS_URL:-http://www.virtualradarserver.co.uk/Files/BasicAircraftLookup.sqb.gz}
CACHEDIR=${CACHEDIR:-/var/cache/dump1090-fa}
JSONDIR=${JSONDIR:-$CACHEDIR/db}
SQBDIR=${SQBDIR:-$CACHEDIR/sqb}
LOGFILE=${LOGFILE:-/dev/null}
UPDATESCRIPT=${UPDATESCRIPT:-/usr/share/dump1090-fa/vrs-basicaircraft-to-json.py}
if [ -f /etc/default/dump1090-mutability ]
then
. /etc/default/dump1090-mutability
fi
ETAGFILE=$SQBDIR/BasicAircraftLookup.sqb.etag
SQBFILE=$SQBDIR/BasicAircraftLookup.sqb
CHECKMODIFIED=true
LOGTOFILE=false
while [ "$#" -gt 0 ]
do
case "$1" in
-f|--force) CHECKMODIFIED=false ;;
-l|--log-to-file) LOGTOFILE=true ;;
*) echo "unrecognized option: $1" >&2; exit 1 ;;
esac
shift
done
if $LOGTOFILE; then exec >>$LOGFILE 2>&1; fi
log() {
date "+%c $*" >&2
}
mkdir -p $CACHEDIR $JSONDIR $SQBDIR
rm -f $ETAGFILE.new $SQBFILE.new
log "Checking VRS server for an updated database.."
# get ETag
curl --silent --fail --include --head $VRS_URL | grep ETag >$ETAGFILE.new
# check for existing file
RETRIEVE=true
ARGS=""
if $CHECKMODIFIED && [ -f $SQBFILE ]
then
if [ -s $ETAGFILE -a -s $ETAGFILE.new ]
then
if cmp -s $ETAGFILE $ETAGFILE.new
then
log "Database not modified."
RETRIEVE=false
else
log "Database modified, will retrieve a new copy."
fi
else
# do an if-modified-since
log "Database possibly modified, will try to retrieve a new copy."
ARGS="-z $SQBFILE"
fi
fi
if $RETRIEVE
then
log "Retrieving database.."
curl --silent --fail --remote-time --retry 2 $ARGS -o $SQBFILE.new $VRS_URL
mv $ETAGFILE.new $ETAGFILE
if [ -f $SQBFILE.new ]
then
log "Decompressing database.."
zcat $SQBFILE.new >$SQBFILE
touch -r $SQBFILE.new $SQBFILE
rm $SQBFILE.new
else
log "Database not modified."
fi
fi
UPDATE=true
if $CHECKMODIFIED
then
if test -f $JSONDIR/last_update; then
if ! test $SQBFILE -nt $JSONDIR/last_update; then UPDATE=false; fi
fi
fi
if $UPDATE
then
log "Updating JSON files from database.."
mkdir -p $JSONDIR/new
$UPDATESCRIPT $SQBFILE $JSONDIR/new
rm -f $JSONDIR/*.json
mv $JSONDIR/new/*.json $JSONDIR/
touch -r $SQBFILE $JSONDIR/last_update
rmdir $JSONDIR/new
log "Done."
else
log "No update to JSON files needed."
fi