[hamradio-commits] [dump1090] 01/01: * Fix a segfault in my merge of PR#33 * Add config.json to net_io.c and script.js to pass the --lat and --lon command line args up to the web ui. Add Proxy config to apache2.conf for this as well.
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Thu Oct 23 16:08:16 UTC 2014
This is an automated email from the git hooks/post-receive script.
mernisse-guest pushed a commit to branch master
in repository dump1090.
commit 0576fee31e2714c8715e4779ce9688e9adf5aa54
Author: Matthew Ernisse <mernisse at ub3rgeek.net>
Date: Thu Oct 23 12:05:47 2014 -0400
* Fix a segfault in my merge of PR#33
* Add config.json to net_io.c and script.js to pass the --lat and
--lon command line args up to the web ui. Add Proxy config to
apache2.conf for this as well.
---
debian/apache2.conf | 1 +
debian/changelog | 15 ++-
debian/patches/00-makefile.patch | 34 ++++---
debian/patches/04-socket_leak.patch | 56 +++++++----
.../05-disable-local-file-http-access.patch | 108 +++++++++++++++++++--
5 files changed, 172 insertions(+), 42 deletions(-)
diff --git a/debian/apache2.conf b/debian/apache2.conf
index bb3d40f..7f9aa13 100644
--- a/debian/apache2.conf
+++ b/debian/apache2.conf
@@ -10,4 +10,5 @@ Alias /dump1090 /usr/share/dump1090/public_html
<IfModule mod_proxy_http.c>
ProxyPass /dump1090/data.json http://127.0.0.1:8080/dump1090/data.json
+ ProxyPass /dump1090/config.json http://127.0.0.1:8080/dump1090/config.json
</IfModule>
diff --git a/debian/changelog b/debian/changelog
index 1ba8d30..a8937da 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,21 @@
-dump1090 (1.09.1007.14+dfsg-5) unstable; urgency=high
+dump1090 (1.09.1007.14+dfsg-6) unstable; urgency=low
+
+ * Fix segfault in the network code. This was a problem with my merging
+ of PR#33.
+ * Add config.json so the web interface can know the lattitude and
+ longitude of the station from the command line.
+ * Patch script.js to support config.json and render the site location
+ automatically from the command line arguments.
+
+ -- Matthew Ernisse <mernisse at ub3rgeek.net> Wed, 22 Oct 2014 23:15:18 -0400
+
+dump1090 (1.09.1007.14+dfsg-5) unstable; urgency=low
* Add modprobe.d blacklist to prevent kernel DVB-T drivers from loading.
-- Matthew Ernisse <mernisse at ub3rgeek.net> Wed, 22 Oct 2014 15:46:23 -0400
-dump1090 (1.09.1007.14+dfsg-4) unstable; urgency=medium
+dump1090 (1.09.1007.14+dfsg-4) unstable; urgency=low
* Apply PR#33 from upstream. This fixes a segfault and possible file
descriptor exhaustion in the network code.
diff --git a/debian/patches/00-makefile.patch b/debian/patches/00-makefile.patch
index 2d2d470..c3b51f8 100644
--- a/debian/patches/00-makefile.patch
+++ b/debian/patches/00-makefile.patch
@@ -4,31 +4,35 @@ Forwarded: not-needed
--- a/Makefile
+++ b/Makefile
-@@ -4,17 +4,19 @@
- #
+@@ -5,16 +5,21 @@
PROGNAME=dump1090
--ifdef PREFIX
+ ifdef PREFIX
-BINDIR=$(PREFIX)/bin
-SHAREDIR=$(PREFIX)/share/$(PROGNAME)
-EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
--endif
-+BINDIR=$(DESTDIR)/usr/bin
-+SBINDIR=$(DESTDIR)/usr/sbin
-+SHAREDIR=$(DESTDIR)/usr/share/$(PROGNAME)
-+EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)/public_html\"
++ BINDIR=$(PREFIX)/bin
++ SBINDIR=$(PREFIX)/sbin
++ SHAREDIR=$(PREFIX)/share/$(PROGNAME)
++ EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
++else
++ BINDIR=$(DESTDIR)/usr/bin
++ SBINDIR=$(DESTDIR)/usr/sbin
++ SHAREDIR=$(DESTDIR)/usr/share/$(PROGNAME)
++ EXTRACFLAGS+=-DHTMLPATH=\"$(SHAREDIR)/public_html\"
+ endif
-CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr`
--LIBS=`pkg-config --libs librtlsdr` -lpthread -lm
-+CFLAGS=-O2 -g -Wall -W $(shell pkg-config --cflags librtlsdr)
-+CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
-+CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
-+CFLAGS += $(shell dpkg-buildflags --get CXXFLAGS)
-+LIBS=$(shell pkg-config --libs librtlsdr) -lpthread -lm
-+LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
++CFLAGS+=-O2 -g -Wall -W `pkg-config --cflags librtlsdr`
+ LIBS=`pkg-config --libs librtlsdr` -lpthread -lm
CC=gcc
-
all: dump1090 view1090
%.o: %.c
+@@ -28,3 +33,4 @@
+
+ clean:
+ rm -f *.o dump1090 view1090
++
diff --git a/debian/patches/04-socket_leak.patch b/debian/patches/04-socket_leak.patch
index 699d7be..b10608c 100644
--- a/debian/patches/04-socket_leak.patch
+++ b/debian/patches/04-socket_leak.patch
@@ -49,7 +49,7 @@ Forwarded: https://github.com/MalcolmRobb/dump1090/pull/33
//
//=========================================================================
//
-@@ -189,15 +198,20 @@
+@@ -189,15 +198,19 @@
// Read next before servicing client incase the service routine deletes the client!
struct client *next = c->next;
@@ -71,11 +71,10 @@ Forwarded: https://github.com/MalcolmRobb/dump1090/pull/33
}
+ } else {
+ modesFreeClient(c);
-+ modesCloseClient(c);
}
c = next;
}
-@@ -870,6 +884,10 @@
+@@ -870,6 +883,10 @@
nread = recv(c->fd, c->buf+c->buflen, left, 0);
if (nread < 0) {errno = WSAGetLastError();}
#endif
@@ -86,7 +85,7 @@ Forwarded: https://github.com/MalcolmRobb/dump1090/pull/33
// If we didn't get all the data we asked for, then return once we've processed what we did get.
if (nread != left) {
-@@ -880,7 +898,7 @@
+@@ -880,7 +897,7 @@
#else
if ( (nread < 0) && (errno != EWOULDBLOCK)) { // Error, or end of file
#endif
@@ -95,37 +94,60 @@ Forwarded: https://github.com/MalcolmRobb/dump1090/pull/33
return;
}
if (nread <= 0) {
-@@ -929,6 +947,7 @@
+@@ -928,7 +945,7 @@
+ }
// Have a 0x1a followed by 1, 2 or 3 - pass message less 0x1a to handler.
if (handler(c, s)) {
- modesFreeClient(c);
+- modesFreeClient(c);
+ modesCloseClient(c);
return;
}
fullmsg = 1;
-@@ -942,12 +961,17 @@
- // in the buffer, note that we full-scan the buffer at every read for simplicity.
+@@ -938,24 +955,33 @@
+ } else {
+ //
+ // This is the ASCII scanning case, AVR RAW or HTTP at present
+- // If there is a complete message still in the buffer, there must be the separator 'sep'
+- // in the buffer, note that we full-scan the buffer at every read for simplicity.
++ // If there is a complete message still in the buffer, there must
++ // be the separator 'sep' in the buffer, note that we full-scan
++ // the buffer at every read for simplicity.
//
while ((e = strstr(s, sep)) != NULL) { // end of first message if found
- *e = '\0'; // The handler expects null terminated strings
-+ *e = '\0'; // The handler expects null
-+ // terminated strings
++ // The handler expects null terminated strings.
++ *e = '\0';
if (handler(c, s)) { // Pass message to handler.
- modesFreeClient(c); // Handler returns 1 on error to signal we .
- return; // should close the client connection
-+ modesFreeClient(c); // Handler returns 1 on
-+ // error to signal we should
-+ // should close the client
-+ // connection
++ // Handler returns 1 on error to signal we should should
++ // close the client connection.
+ modesCloseClient(c);
++ return;
}
- s = e + strlen(sep); // Move to start of next message
-+ s = e + strlen(sep); // Move to start of next
-+ // message.
++ // Move to start of next message.
++ s = e + strlen(sep);
fullmsg = 1;
}
}
-@@ -971,15 +995,20 @@
+
+- if (fullmsg) { // We processed something - so
+- c->buflen = &(c->buf[c->buflen]) - s; // Update the unprocessed buffer length
+- memmove(c->buf, s, c->buflen); // Move what's remaining to the start of the buffer
+- } else { // If no message was decoded process the next client
++ if (fullmsg) {
++ // We processed something - so update the unprocessed buffer
++ // length
++ c->buflen = &(c->buf[c->buflen]) - s;
++ // Move what's remaining to the start of the buffer
++ memmove(c->buf, s, c->buflen);
++ } else {
++ // If no message was decoded process the next client
+ break;
+ }
+ }
+@@ -971,15 +997,20 @@
struct client *c = modesAcceptClients();
while (c) {
diff --git a/debian/patches/05-disable-local-file-http-access.patch b/debian/patches/05-disable-local-file-http-access.patch
index 840a781..baa501d 100644
--- a/debian/patches/05-disable-local-file-http-access.patch
+++ b/debian/patches/05-disable-local-file-http-access.patch
@@ -1,11 +1,15 @@
Description: Disable local file serving from the internal HTTP server.
This patch relies somewhat on the 02-http-buffer.patch being applied.
+ .
+ This patch also adds support for user lattitude and longitude variables
+ on the command line to be passed up to the web ui, removing the need for
+ the user to edit both /etc/defaults/dump1090 AND config.js.
Author: Matthew John Ernisse <mernisse at ub3rgeek.net>
Forwarded: no
--- a/net_io.c
+++ b/net_io.c
-@@ -704,9 +704,7 @@
+@@ -703,9 +703,7 @@
#define HTTP_OK "200 OK";
#define HTTP_NOTFOUND "404 Not Found";
#define MODES_CONTENT_TYPE_HTML "text/html;charset=utf-8"
@@ -15,7 +19,7 @@ Forwarded: no
//
// Get an HTTP request header and write the response to the client.
// gain here we assume that the socket buffer is enough without doing
-@@ -722,8 +720,6 @@
+@@ -721,8 +719,6 @@
int httpver, keepalive;
char *url, *content;
char ctype[48];
@@ -24,7 +28,7 @@ Forwarded: no
if (Modes.debug & MODES_DEBUG_NET)
printf("\nHTTP request: %s\n", c->buf);
-@@ -751,55 +747,17 @@
+@@ -750,55 +746,28 @@
printf("HTTP requested URL: %s\n\n", url);
}
@@ -43,8 +47,7 @@ Forwarded: no
if (strstr(url, "/data.json")) {
content = aircraftsToJson(&clen);
- //snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_JSON);
-+ snprintf(ctype, sizeof(ctype), MODES_CONTENT_TYPE_JSON);
- } else {
+- } else {
- struct stat sbuf;
- int fd = -1;
-
@@ -57,10 +60,16 @@ Forwarded: no
- }
- clen = sbuf.st_size;
- } else {
-- char buf[128];
++ snprintf(ctype, sizeof(ctype), MODES_CONTENT_TYPE_JSON);
++ } else if (strstr(url, "/config.json")) {
++ if (Modes.fUserLat != 0.0 && Modes.fUserLon != 0.0) {
+ char buf[128];
- clen = snprintf(buf, sizeof(buf), "Error opening %s: %s",
- getFile, strerror(errno));
-- content = strdup(buf);
++ clen = snprintf(buf, sizeof(buf),
++ "{\"SiteLat\": %f, \"SiteLon\": %f}",
++ Modes.fUserLat, Modes.fUserLon);
+ content = strdup(buf);
- httpcode = HTTP_NOTFOUND;
- }
-
@@ -80,7 +89,11 @@ Forwarded: no
- snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_CSS);
- } else if (strstr(ext, ".js")) {
- snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_JS);
-- }
++ } else {
++ content = strdup("{}");
++ clen = strlen(content);
+ }
++ } else {
+ httpcode = HTTP_NOTFOUND
+ content = strdup("File not found.");
+ clen = strlen(content);
@@ -88,3 +101,82 @@ Forwarded: no
}
// Create the header and send the reply
+--- a/public_html/script.js
++++ b/public_html/script.js
+@@ -53,6 +53,36 @@
+ });
+ }
+
++function fetchJSONConfig() {
++ // Load config from json if able.
++ $.getJSON('/dump1090/config.json', function(data) {
++ if (!("SiteLat" in data) || !("SiteLon" in data)) {
++ return;
++ }
++ SiteShow = true;
++ SiteLat = data["SiteLat"];
++ SiteLon = data["SiteLon"];
++ var markerImage = new google.maps.MarkerImage(
++ 'http://maps.google.com/mapfiles/kml/pal4/icon57.png',
++ new google.maps.Size(32, 32),
++ new google.maps.Point(0, 0),
++ new google.maps.Point(16, 16));
++ var marker = new google.maps.Marker({
++ position: new google.maps.LatLng(SiteLat, SiteLon),
++ map: GoogleMap,
++ icon: markerImage,
++ title: 'My Radar Site',
++ zIndex: -99999
++ });
++
++ if (SiteCircles) {
++ for (var i=0;i<SiteCirclesDistances.length;i++) {
++ drawCircle(marker, SiteCirclesDistances[i]);
++ }
++ }
++ });
++}
++
+ // Initalizes the map and starts up our timers to call various functions
+ function initialize() {
+ // Make a list of all the available map IDs
+@@ -167,34 +197,14 @@
+ google.maps.event.addListener(GoogleMap, 'zoom_changed', function() {
+ localStorage['ZoomLvl'] = GoogleMap.getZoom();
+ });
+-
+- // Add home marker if requested
+- if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) {
+- var siteMarker = new google.maps.LatLng(SiteLat, SiteLon);
+- var markerImage = new google.maps.MarkerImage(
+- 'http://maps.google.com/mapfiles/kml/pal4/icon57.png',
+- new google.maps.Size(32, 32), // Image size
+- new google.maps.Point(0, 0), // Origin point of image
+- new google.maps.Point(16, 16)); // Position where marker should point
+- var marker = new google.maps.Marker({
+- position: siteMarker,
+- map: GoogleMap,
+- icon: markerImage,
+- title: 'My Radar Site',
+- zIndex: -99999
+- });
+-
+- if (SiteCircles) {
+- for (var i=0;i<SiteCirclesDistances.length;i++) {
+- drawCircle(marker, SiteCirclesDistances[i]); // in meters
+- }
+- }
+- }
++
+
+ // These will run after page is complitely loaded
+ $(window).load(function() {
+- $('#dialog-modal').css('display', 'inline'); // Show hidden settings-windows content
+- });
++ $('#dialog-modal').css('display', 'inline'); // Show hidden settings-windows content
++ });
++
++ fetchJSONConfig();
+
+ // Load up our options page
+ optionsInitalize();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git
More information about the pkg-hamradio-commits
mailing list