From cc27ff623431afba0c8476223ad37006f284c9fe Mon Sep 17 00:00:00 2001 From: Jeff Lawson Date: Thu, 27 Feb 2014 14:40:14 -0600 Subject: [PATCH 01/22] link to FlightAware for flight details --- public_html/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public_html/script.js b/public_html/script.js index 05d29b7..9300c27 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -265,6 +265,7 @@ function refreshSelected() { } else if (selected && selected.flight != '') { html += ' [FlightStats]'; + html += ' [FlightAware]'; } html += ''; From a13c2f854071a363f27ffc393b9b5b91383b9e43 Mon Sep 17 00:00:00 2001 From: ddeitterick Date: Wed, 16 Jul 2014 21:42:02 -0400 Subject: [PATCH 02/22] Add Distance to Table Info Add distance to table if site coordinates are provided and sort the table by distance. If coordinates aren't provided, the column isn't displayed. --- public_html/script.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/public_html/script.js b/public_html/script.js index 05d29b7..062bba0 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -399,11 +399,16 @@ function refreshTableInfo() { 'align="right">Altitude'; html += 'Speed'; - html += 'Distance'; + } + html += 'Track'; - html += 'Msgs'; - html += 'Seen'; for (var tablep in Planes) { var tableplane = Planes[tablep] @@ -447,6 +452,25 @@ function refreshTableInfo() { html += '' + tableplane.altitude + ''; html += '' + tableplane.speed + ''; } + // Add distance column to table if site coordinates are provided + if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) { + html += ''; + if (tableplane.vPosition) { + var siteLatLon = new google.maps.LatLng(SiteLat, SiteLon); + var planeLatLon = new google.maps.LatLng(tableplane.latitude, tableplane.longitude); + var dist = google.maps.geometry.spherical.computeDistanceBetween (siteLatLon, planeLatLon); + if (Metric) { + dist /= 1000; + } else { + dist /= 1852; + } + dist = (Math.round((dist)*10)/10).toFixed(1); + html += dist; + } else { + html += '0'; + } + html += ''; + } html += ''; if (tableplane.vTrack) { @@ -499,6 +523,8 @@ function sortTable(szTableID,iCol) { if (typeof iCol==='undefined'){ if(iSortCol!=-1){ var iCol=iSortCol; + } else if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) { + var iCol=5; } else { var iCol=iDefaultSortCol; } From f933ed2723bb47e54b6e1b264c7f9c661929ab3d Mon Sep 17 00:00:00 2001 From: ddeitterick Date: Wed, 16 Jul 2014 21:51:41 -0400 Subject: [PATCH 03/22] Center "Distance from Site" for Selected Plane Center "Distance from Site" under "Lat/Long" for selected plane. --- public_html/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public_html/script.js b/public_html/script.js index 05d29b7..4e1ed2d 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -326,12 +326,12 @@ function refreshSelected() { dist /= 1852; } dist = (Math.round((dist)*10)/10).toFixed(1); - html += 'Distance from Site: ' + dist + + html += 'Distance from Site: ' + dist + (Metric ? ' km' : ' NM') + ''; } // End of SiteShow } else { if (SiteShow) { - html += 'Distance from Site: n/a ' + + html += 'Distance from Site: n/a ' + (Metric ? ' km' : ' NM') + ''; } else { html += 'n/a'; From e5fddba1824879160e67ebc4150a9d61df8e1405 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Sun, 10 Aug 2014 00:01:31 -0700 Subject: [PATCH 04/22] Add flightradar24.com link --- public_html/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public_html/script.js b/public_html/script.js index 05d29b7..fa81925 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -263,6 +263,7 @@ function refreshSelected() { } else if (selected && selected.squawk == 7700) { // General Emergency html += '  Squawking: General Emergency '; } else if (selected && selected.flight != '') { + html += ' [FR24]'; html += ' [FlightStats]'; } From 0317c48aac58bb64d19236a48ffc86f8dec21720 Mon Sep 17 00:00:00 2001 From: hhm Date: Fri, 15 Aug 2014 04:39:35 -0400 Subject: [PATCH 05/22] B"H make sure to close sockets when finished --- net_io.c | 64 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/net_io.c b/net_io.c index 25abb88..48325d0 100644 --- a/net_io.c +++ b/net_io.c @@ -161,8 +161,15 @@ void modesFreeClient(struct client *c) { } } - // It's now safe to remove this client - close(c->fd); + free(c); +} +// +//========================================================================= +// +// Close the client connection and mark it as closed +// +void modesCloseClient(struct client *c) { + close(c->fd); if (c->service == Modes.sbsos) { if (Modes.stat_sbs_connections) Modes.stat_sbs_connections--; } else if (c->service == Modes.ros) { @@ -174,7 +181,7 @@ void modesFreeClient(struct client *c) { if (Modes.debug & MODES_DEBUG_NET) printf("Closing client %d\n", c->fd); - free(c); + c->fd = -1; } // //========================================================================= @@ -188,15 +195,19 @@ void modesSendAllClients(int service, void *msg, int len) { // Read next before servicing client incase the service routine deletes the client! struct client *next = c->next; - if (c->service == service) { + if (c->fd != -1) { + if (c->service == service) { #ifndef _WIN32 - int nwritten = write(c->fd, msg, len); + int nwritten = write(c->fd, msg, len); #else - int nwritten = send(c->fd, msg, len, 0 ); + int nwritten = send(c->fd, msg, len, 0 ); #endif - if (nwritten != len) { - modesFreeClient(c); + if (nwritten != len) { + modesCloseClient(c); + } } + } else { + modesFreeClient(c); } c = next; } @@ -707,11 +718,12 @@ int handleHTTPRequest(struct client *c, char *p) { httpver = (strstr(p, "HTTP/1.1") != NULL) ? 11 : 10; if (httpver == 10) { // HTTP 1.0 defaults to close, unless otherwise specified. - keepalive = strstr(p, "Connection: keep-alive") != NULL; + //keepalive = strstr(p, "Connection: keep-alive") != NULL; } else if (httpver == 11) { // HTTP 1.1 defaults to keep-alive, unless close is specified. - keepalive = strstr(p, "Connection: close") == NULL; + //keepalive = strstr(p, "Connection: close") == NULL; } + keepalive = 0; // Identify he URL. p = strchr(p,' '); @@ -775,7 +787,7 @@ int handleHTTPRequest(struct client *c, char *p) { // Create the header and send the reply hdrlen = snprintf(hdr, sizeof(hdr), - "HTTP/1.1 200 OK\r\n" + "HTTP/1.0 200 OK\r\n" "Server: Dump1090\r\n" "Content-Type: %s\r\n" "Connection: %s\r\n" @@ -845,6 +857,10 @@ void modesReadFromClient(struct client *c, char *sep, nread = recv(c->fd, c->buf+c->buflen, left, 0); if (nread < 0) {errno = WSAGetLastError();} #endif + if (nread == 0) { + modesCloseClient(c); + return; + } // If we didn't get all the data we asked for, then return once we've processed what we did get. if (nread != left) { @@ -855,7 +871,7 @@ void modesReadFromClient(struct client *c, char *sep, #else if ( (nread < 0) && (errno != EWOULDBLOCK)) { // Error, or end of file #endif - modesFreeClient(c); + modesCloseClient(c); } if (nread <= 0) { break; // Serve next client @@ -902,7 +918,7 @@ void modesReadFromClient(struct client *c, char *sep, } // Have a 0x1a followed by 1, 2 or 3 - pass message less 0x1a to handler. if (handler(c, s)) { - modesFreeClient(c); + modesCloseClient(c); return; } fullmsg = 1; @@ -918,7 +934,7 @@ void modesReadFromClient(struct client *c, char *sep, while ((e = strstr(s, sep)) != NULL) { // end of first message if found *e = '\0'; // The handler expects null terminated strings if (handler(c, s)) { // Pass message to handler. - modesFreeClient(c); // Handler returns 1 on error to signal we . + modesCloseClient(c); // Handler returns 1 on error to signal we . return; // should close the client connection } s = e + strlen(sep); // Move to start of next message @@ -945,15 +961,19 @@ void modesReadFromClients(void) { struct client *c = modesAcceptClients(); while (c) { - // Read next before servicing client incase the service routine deletes the client! - struct client *next = c->next; + // Read next before servicing client incase the service routine deletes the client! + struct client *next = c->next; - if (c->service == Modes.ris) { - modesReadFromClient(c,"\n",decodeHexMessage); - } else if (c->service == Modes.bis) { - modesReadFromClient(c,"",decodeBinMessage); - } else if (c->service == Modes.https) { - modesReadFromClient(c,"\r\n\r\n",handleHTTPRequest); + if (c->fd >= 0) { + if (c->service == Modes.ris) { + modesReadFromClient(c,"\n",decodeHexMessage); + } else if (c->service == Modes.bis) { + modesReadFromClient(c,"",decodeBinMessage); + } else if (c->service == Modes.https) { + modesReadFromClient(c,"\r\n\r\n",handleHTTPRequest); + } + } else { + modesFreeClient(c); } c = next; } From 84fa09c22896c1218ef5a1a2a0c32453702c91f8 Mon Sep 17 00:00:00 2001 From: hhm Date: Mon, 18 Aug 2014 03:06:43 -0400 Subject: [PATCH 06/22] B"H net_io.c: revert previous change and advertise HTTP 1.1 It seems server code should be compatible with HTTP 1.1; the features unique to 1.1 mostly are upon the client to support, and some headers used (for example Cache-Control) may need 1.1. --- net_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index 48325d0..7e15343 100644 --- a/net_io.c +++ b/net_io.c @@ -787,7 +787,7 @@ int handleHTTPRequest(struct client *c, char *p) { // Create the header and send the reply hdrlen = snprintf(hdr, sizeof(hdr), - "HTTP/1.0 200 OK\r\n" + "HTTP/1.1 200 OK\r\n" "Server: Dump1090\r\n" "Content-Type: %s\r\n" "Connection: %s\r\n" From eb41be3884ea25aad05c99da562e014dbff0e1e3 Mon Sep 17 00:00:00 2001 From: hhm Date: Sun, 14 Sep 2014 06:28:03 -0400 Subject: [PATCH 07/22] B"H net_io: http: check if file can be sent --- net_io.c | 22 +++++++++++++++++----- winstubs.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/net_io.c b/net_io.c index 25abb88..67dfa2c 100644 --- a/net_io.c +++ b/net_io.c @@ -741,14 +741,26 @@ int handleHTTPRequest(struct client *c, char *p) { } else { struct stat sbuf; int fd = -1; + char *rp, *hrp; - if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { - content = (char *) malloc(sbuf.st_size); - if (read(fd, content, sbuf.st_size) == -1) { - snprintf(content, sbuf.st_size, "Error reading from file: %s", strerror(errno)); + rp = realpath(getFile, NULL); + hrp = realpath(HTMLPATH, NULL); + hrp = (hrp ? hrp : HTMLPATH); + clen = -1; + content = "Server error"; + if (rp && (!strncmp(hrp, rp, strlen(hrp)))) { + if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { + content = (char *) malloc(sbuf.st_size); + if (read(fd, content, sbuf.st_size) != -1) { + clen = sbuf.st_size; + free(content); + } } - clen = sbuf.st_size; } else { + errno = ENOENT; + } + + if (clen < 0) { char buf[128]; clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno)); content = strdup(buf); diff --git a/winstubs.h b/winstubs.h index f416668..051e2f0 100644 --- a/winstubs.h +++ b/winstubs.h @@ -75,6 +75,7 @@ _inline uint64_t strtoll(const char *p, void *e, UINT32 base) {return _atoi64(p) _inline int inet_aton(const char * cp, DWORD * ulAddr) { *ulAddr = inet_addr(cp); return 0;} #define snprintf _snprintf #define vsnprintf _vsnprintf +#define realpath(A, B) _fullpath(B, A, _MAX_PATH) _inline void cls() { HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); From 31b28b3878e2096158a84df5163f656274c398ab Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 15 Sep 2014 01:43:14 +0100 Subject: [PATCH 08/22] Rearrange phase enhancement so that it handles phase errors in both directions. This almost doubles the number of messages recovered by phase enhancement. --- mode_s.c | 107 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 39 deletions(-) diff --git a/mode_s.c b/mode_s.c index 34ddec1..5c47883 100644 --- a/mode_s.c +++ b/mode_s.c @@ -1456,46 +1456,75 @@ int detectOutOfPhase(uint16_t *pPreamble) { if (pPreamble[-1] > pPreamble[1]/3) return -1; return 0; } + + +uint16_t clamped_scale(uint16_t v, uint16_t scale) { + uint32_t scaled = (uint32_t)v * scale / 16384; + if (scaled > 65535) return 65535; + return (uint16_t) scaled; +} +// This function decides whether we are sampling early or late, +// and by approximately how much, by looking at the energy in +// preamble bits before and after the expected pulse locations. // -//========================================================================= -// -// This function does not really correct the phase of the message, it just -// applies a transformation to the first sample representing a given bit: -// -// If the previous bit was one, we amplify it a bit. -// If the previous bit was zero, we decrease it a bit. -// -// This simple transformation makes the message a bit more likely to be -// correctly decoded for out of phase messages: -// -// When messages are out of phase there is more uncertainty in -// sequences of the same bit multiple times, since 11111 will be -// transmitted as continuously altering magnitude (high, low, high, low...) -// -// However because the message is out of phase some part of the high -// is mixed in the low part, so that it is hard to distinguish if it is -// a zero or a one. -// -// However when the message is out of phase passing from 0 to 1 or from -// 1 to 0 happens in a very recognizable way, for instance in the 0 -> 1 -// transition, magnitude goes low, high, high, low, and one of of the -// two middle samples the high will be *very* high as part of the previous -// or next high signal will be mixed there. -// -// Applying our simple transformation we make more likely if the current -// bit is a zero, to detect another zero. Symmetrically if it is a one -// it will be more likely to detect a one because of the transformation. -// In this way similar levels will be interpreted more likely in the -// correct way. +// It then deals with one sample pair at a time, comparing samples +// to make a decision about the bit value. Based on this decision it +// modifies the sample value of the *adjacent* sample which will +// contain some of the energy from the bit we just inspected. // +// pPayload[0] should be the start of the preamble, +// pPayload[-1 .. MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] should be accessible. +// pPayload[MODES_PREAMBLE_SAMPLES .. MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] will be updated. void applyPhaseCorrection(uint16_t *pPayload) { int j; - for (j = 0; j < MODES_LONG_MSG_SAMPLES; j += 2, pPayload += 2) { - if (pPayload[0] > pPayload[1]) { // One - pPayload[2] = (pPayload[2] * 5) / 4; - } else { // Zero - pPayload[2] = (pPayload[2] * 4) / 5; + // we expect 1 bits at 0, 2, 7, 9 + // and 0 bits at -1, 1, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14 + // use bits -1,6 for early detection (bit 0/7 arrived a little early, our sample period starts after the bit phase so we include some of the next bit) + // use bits 3,10 for late detection (bit 2/9 arrived a little late, our sample period starts before the bit phase so we include some of the last bit) + + uint32_t onTime = (pPayload[0] + pPayload[2] + pPayload[7] + pPayload[9]); + uint32_t early = (pPayload[-1] + pPayload[6]) << 1; + uint32_t late = (pPayload[3] + pPayload[10]) << 1; + + if (early > late) { + // Our sample period starts late and so includes some of the next bit. + + uint16_t scaleUp = 16384 + 16384 * early / (early + onTime); // 1 + early / (early+onTime) + uint16_t scaleDown = 16384 - 16384 * early / (early + onTime); // 1 - early / (early+onTime) + + // trailing bits are 0; final data sample will be a bit low. + pPayload[MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] = + clamped_scale(pPayload[MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1], scaleUp); + for (j = MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 2; j > MODES_PREAMBLE_SAMPLES; j -= 2) { + if (pPayload[j] > pPayload[j+1]) { + // x [1 0] y + // x overlapped with the "1" bit and is slightly high + pPayload[j-1] = clamped_scale(pPayload[j-1], scaleDown); + } else { + // x [0 1] y + // x overlapped with the "0" bit and is slightly low + pPayload[j-1] = clamped_scale(pPayload[j-1], scaleUp); + } + } + } else { + // Our sample period starts early and so includes some of the previous bit. + + uint16_t scaleUp = 16384 + 16384 * late / (late + onTime); // 1 + late / (late+onTime) + uint16_t scaleDown = 16384 - 16384 * late / (late + onTime); // 1 - late / (late+onTime) + + // leading bits are 0; first data sample will be a bit low. + pPayload[MODES_PREAMBLE_SAMPLES] = clamped_scale(pPayload[MODES_PREAMBLE_SAMPLES], scaleUp); + for (j = MODES_PREAMBLE_SAMPLES; j < MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 2; j += 2) { + if (pPayload[j] > pPayload[j+1]) { + // x [1 0] y + // y overlapped with the "0" bit and is slightly low + pPayload[j+2] = clamped_scale(pPayload[j+2], scaleUp); + } else { + // x [0 1] y + // y overlapped with the "1" bit and is slightly high + pPayload[j+2] = clamped_scale(pPayload[j+2], scaleDown); + } } } } @@ -1509,7 +1538,7 @@ void applyPhaseCorrection(uint16_t *pPayload) { void detectModeS(uint16_t *m, uint32_t mlen) { struct modesMessage mm; unsigned char msg[MODES_LONG_MSG_BYTES], *pMsg; - uint16_t aux[MODES_LONG_MSG_SAMPLES]; + uint16_t aux[MODES_PREAMBLE_SAMPLES+MODES_LONG_MSG_SAMPLES+1]; uint32_t j; int use_correction = 0; @@ -1631,10 +1660,10 @@ void detectModeS(uint16_t *m, uint32_t mlen) { // If the previous attempt with this message failed, retry using // magnitude correction // Make a copy of the Payload, and phase correct the copy - memcpy(aux, pPayload, sizeof(aux)); - applyPhaseCorrection(aux); + memcpy(aux, &pPreamble[-1], sizeof(aux)); + applyPhaseCorrection(&aux[1]); Modes.stat_out_of_phase++; - pPayload = aux; + pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES]; // TODO ... apply other kind of corrections } From 04f4abda709f13545a813c5090a49a54540da5d3 Mon Sep 17 00:00:00 2001 From: hhm Date: Mon, 15 Sep 2014 09:08:49 -0400 Subject: [PATCH 09/22] B"H net_io.c: add missing else statement --- net_io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net_io.c b/net_io.c index 67dfa2c..1679ef1 100644 --- a/net_io.c +++ b/net_io.c @@ -753,6 +753,7 @@ int handleHTTPRequest(struct client *c, char *p) { content = (char *) malloc(sbuf.st_size); if (read(fd, content, sbuf.st_size) != -1) { clen = sbuf.st_size; + } else { free(content); } } From 8d307cd0ebe8ac2b446d717d048dc11951c3eb29 Mon Sep 17 00:00:00 2001 From: hhm Date: Wed, 17 Sep 2014 06:32:03 -0400 Subject: [PATCH 10/22] B"H net_io.c: http serve: return HTTP response codes --- net_io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index 1679ef1..91cf47d 100644 --- a/net_io.c +++ b/net_io.c @@ -695,6 +695,7 @@ int handleHTTPRequest(struct client *c, char *p) { char hdr[512]; int clen, hdrlen; int httpver, keepalive; + int statuscode = 500; char *url, *content; char ctype[48]; char getFile[1024]; @@ -736,6 +737,7 @@ int handleHTTPRequest(struct client *c, char *p) { // "/" -> Our google map application. // "/data.json" -> Our ajax request to update planes. if (strstr(url, "/data.json")) { + statuscode = 200; content = aircraftsToJson(&clen); //snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_JSON); } else { @@ -753,6 +755,7 @@ int handleHTTPRequest(struct client *c, char *p) { content = (char *) malloc(sbuf.st_size); if (read(fd, content, sbuf.st_size) != -1) { clen = sbuf.st_size; + statuscode = 200; } else { free(content); } @@ -764,6 +767,7 @@ int handleHTTPRequest(struct client *c, char *p) { if (clen < 0) { char buf[128]; clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno)); + statuscode = 404; content = strdup(buf); } @@ -788,7 +792,7 @@ int handleHTTPRequest(struct client *c, char *p) { // Create the header and send the reply hdrlen = snprintf(hdr, sizeof(hdr), - "HTTP/1.1 200 OK\r\n" + "HTTP/1.1 %i \r\n" "Server: Dump1090\r\n" "Content-Type: %s\r\n" "Connection: %s\r\n" @@ -796,6 +800,7 @@ int handleHTTPRequest(struct client *c, char *p) { "Cache-Control: no-cache, must-revalidate\r\n" "Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n" "\r\n", + statuscode, ctype, keepalive ? "keep-alive" : "close", clen); From df19d51bc633e80ca714ce4c52438c3631024f7e Mon Sep 17 00:00:00 2001 From: hhm Date: Wed, 17 Sep 2014 06:58:53 -0400 Subject: [PATCH 11/22] B"H net_io.c: use %d like local code --- net_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index 91cf47d..10e09d0 100644 --- a/net_io.c +++ b/net_io.c @@ -792,7 +792,7 @@ int handleHTTPRequest(struct client *c, char *p) { // Create the header and send the reply hdrlen = snprintf(hdr, sizeof(hdr), - "HTTP/1.1 %i \r\n" + "HTTP/1.1 %d \r\n" "Server: Dump1090\r\n" "Content-Type: %s\r\n" "Connection: %s\r\n" From 32fc5fddd0900b446600dbf05e88d44187d4b5f5 Mon Sep 17 00:00:00 2001 From: hhm Date: Wed, 17 Sep 2014 07:32:34 -0400 Subject: [PATCH 12/22] B"H net_io.c: http server: content should be dynamically allocated --- net_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index 10e09d0..4a19429 100644 --- a/net_io.c +++ b/net_io.c @@ -749,7 +749,7 @@ int handleHTTPRequest(struct client *c, char *p) { hrp = realpath(HTMLPATH, NULL); hrp = (hrp ? hrp : HTMLPATH); clen = -1; - content = "Server error"; + content = calloc(1, 1); if (rp && (!strncmp(hrp, rp, strlen(hrp)))) { if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { content = (char *) malloc(sbuf.st_size); From c265ea1d553c0fb09e22b72ed51058dfea9df35c Mon Sep 17 00:00:00 2001 From: hhm Date: Wed, 17 Sep 2014 07:58:19 -0400 Subject: [PATCH 13/22] B"H net_io.c http server: hopefully mem code is OK now Still learning the ropes memory-wise :-) --- net_io.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net_io.c b/net_io.c index 4a19429..d1bbd39 100644 --- a/net_io.c +++ b/net_io.c @@ -749,15 +749,13 @@ int handleHTTPRequest(struct client *c, char *p) { hrp = realpath(HTMLPATH, NULL); hrp = (hrp ? hrp : HTMLPATH); clen = -1; - content = calloc(1, 1); + content = strdup("Server error occured"); if (rp && (!strncmp(hrp, rp, strlen(hrp)))) { if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { - content = (char *) malloc(sbuf.st_size); + content = (char *) realloc(content, sbuf.st_size); if (read(fd, content, sbuf.st_size) != -1) { clen = sbuf.st_size; statuscode = 200; - } else { - free(content); } } } else { @@ -766,9 +764,9 @@ int handleHTTPRequest(struct client *c, char *p) { if (clen < 0) { char buf[128]; - clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno)); + content = realloc(content, sizeof(buf)); + clen = snprintf(content,sizeof(buf),"Error opening HTML file: %s", strerror(errno)); statuscode = 404; - content = strdup(buf); } if (fd != -1) { @@ -800,7 +798,7 @@ int handleHTTPRequest(struct client *c, char *p) { "Cache-Control: no-cache, must-revalidate\r\n" "Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n" "\r\n", - statuscode, + statuscode, ctype, keepalive ? "keep-alive" : "close", clen); From 75438d5595208da219080f6efc8d04984613f8b2 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 2 Oct 2014 22:50:09 +0100 Subject: [PATCH 14/22] Change the marker color for aircraft with no recent updates. --- public_html/config.js | 1 + public_html/planeObject.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/public_html/config.js b/public_html/config.js index c4d7ecd..f7d8e2e 100644 --- a/public_html/config.js +++ b/public_html/config.js @@ -20,6 +20,7 @@ CONST_ZOOMLVL = 5; // The default marker color MarkerColor = "rgb(127, 127, 127)"; SelectedColor = "rgb(225, 225, 225)"; +StaleColor = "rgb(190, 190, 190)"; // -- Site Settings --------------------------------------- SiteShow = false; // true or false diff --git a/public_html/planeObject.js b/public_html/planeObject.js index dfb0130..98153fd 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -53,10 +53,16 @@ var planeObject = { // Should create an icon for us to use on the map... funcGetIcon : function() { + this.markerColor = MarkerColor; // If this marker is selected we should make it lighter than the rest. if (this.is_selected == true) { this.markerColor = SelectedColor; } + + // If we have not seen a recent update, change color + if (this.seen > 15) { + this.markerColor = StaleColor; + } // Plane marker var baseSvg = { From 5b4d811c7da67f9c84924d21a3ad0d415b526456 Mon Sep 17 00:00:00 2001 From: demonx Date: Sat, 25 Oct 2014 21:33:45 +0200 Subject: [PATCH 15/22] Ability to assign bind address for services --- dump1090.c | 4 ++++ dump1090.h | 2 ++ net_io.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dump1090.c b/dump1090.c index e8096a3..664190e 100644 --- a/dump1090.c +++ b/dump1090.c @@ -76,6 +76,7 @@ void modesInitConfig(void) { Modes.net_input_raw_port = MODES_NET_INPUT_RAW_PORT; Modes.net_output_beast_port = MODES_NET_OUTPUT_BEAST_PORT; Modes.net_input_beast_port = MODES_NET_INPUT_BEAST_PORT; + Modes.net_bind_address = MODES_NET_BIND_ADDRESS; Modes.net_http_port = MODES_NET_HTTP_PORT; Modes.interactive_rows = getTermRows(); Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL; @@ -409,6 +410,7 @@ void showHelp(void) { "--modeac Enable decoding of SSR Modes 3/A & 3/C\n" "--net-beast TCP raw output in Beast binary format\n" "--net-only Enable just networking, no RTL device or file used\n" +"--net-bind-address IP address to bind to (default: 127.0.0.1; 0.0.0.0 for public)\n" "--net-http-port HTTP server port (default: 8080)\n" "--net-ri-port TCP raw input listen port (default: 30001)\n" "--net-ro-port TCP raw output listen port (default: 30002)\n" @@ -716,6 +718,8 @@ int main(int argc, char **argv) { Modes.net_output_beast_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bi-port") && more) { Modes.net_input_beast_port = atoi(argv[++j]); + } else if (!strcmp(argv[j],"--net-bind-address") && more) { + Modes.net_bind_address = argv[++j]; } else if (!strcmp(argv[j],"--net-http-port") && more) { Modes.net_http_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-sbs-port") && more) { diff --git a/dump1090.h b/dump1090.h index b7adae3..558264c 100644 --- a/dump1090.h +++ b/dump1090.h @@ -173,6 +173,7 @@ #define MODES_NET_OUTPUT_SBS_PORT 30003 #define MODES_NET_INPUT_BEAST_PORT 30004 #define MODES_NET_OUTPUT_BEAST_PORT 30005 +#define MODES_NET_BIND_ADDRESS "127.0.0.1" #define MODES_NET_HTTP_PORT 8080 #define MODES_CLIENT_BUF_SIZE 1024 #define MODES_NET_SNDBUF_SIZE (1024*64) @@ -305,6 +306,7 @@ struct { // Internal state int net_input_raw_port; // Raw input TCP port int net_output_beast_port; // Beast output TCP port int net_input_beast_port; // Beast input TCP port + char *net_bind_address; // Bind address int net_http_port; // HTTP port int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n) int quiet; // Suppress stdout diff --git a/net_io.c b/net_io.c index f3a8397..ca68901 100644 --- a/net_io.c +++ b/net_io.c @@ -85,7 +85,7 @@ void modesInitNet(void) { for (j = 0; j < MODES_NET_SERVICES_NUM; j++) { services[j].enabled = (services[j].port != 0); if (services[j].enabled) { - int s = anetTcpServer(Modes.aneterr, services[j].port, NULL); + int s = anetTcpServer(Modes.aneterr, services[j].port, Modes.net_bind_address); if (s == -1) { fprintf(stderr, "Error opening the listening port %d (%s): %s\n", services[j].port, services[j].descr, Modes.aneterr); From abaf9d8b39494ae628fdd0e11925ded21ae27275 Mon Sep 17 00:00:00 2001 From: Malcolm Robb Date: Wed, 29 Oct 2014 17:39:34 +0000 Subject: [PATCH 16/22] Fix W3C Validation Errors #34 Submitted by ddeitterick, but the push didn't work on IE8/9. I hope I've extracted the required parts and implemented them correctly here. --- public_html/gmap.html | 4 +++- public_html/style.css | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public_html/gmap.html b/public_html/gmap.html index 96f412a..9ab2dc2 100644 --- a/public_html/gmap.html +++ b/public_html/gmap.html @@ -1,10 +1,11 @@ + - + @@ -13,6 +14,7 @@ + DUMP1090