diff --git a/coaa1090.obj b/coaa1090.obj index ea337ca..b199408 100644 Binary files a/coaa1090.obj and b/coaa1090.obj differ diff --git a/dump1090-win.1.09.0608.14.zip b/dump1090-win.1.10.2910.14.zip similarity index 80% rename from dump1090-win.1.09.0608.14.zip rename to dump1090-win.1.10.2910.14.zip index 5bd3d84..68f52ee 100644 Binary files a/dump1090-win.1.09.0608.14.zip and b/dump1090-win.1.10.2910.14.zip differ 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.dsp b/dump1090.dsp index d64d0d1..6bd819b 100644 --- a/dump1090.dsp +++ b/dump1090.dsp @@ -131,6 +131,10 @@ SOURCE=.\winstubs.h # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Dump1090.rc +# End Source File # End Group # Begin Group "Library Files" diff --git a/dump1090.h b/dump1090.h index b7adae3..c11bda4 100644 --- a/dump1090.h +++ b/dump1090.h @@ -37,7 +37,7 @@ // MinorVer changes when additional features are added, but not for bug fixes (range 00-99) // DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update // -#define MODES_DUMP1090_VERSION "1.09.0608.14" +#define MODES_DUMP1090_VERSION "1.10.2910.14" // ============================= Include files ========================== @@ -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 "0.0.0.0" #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/dump1090.rc b/dump1090.rc new file mode 100644 index 0000000..18bd250 --- /dev/null +++ b/dump1090.rc @@ -0,0 +1,115 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "ntverp.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,10,2910,14 + PRODUCTVERSION 1,10,2910,14 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x3L + FILESUBTYPE 0x7L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Dump1090 for Win32 \0" + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Mode A/C/S decoder for RTL Dongles\0" + VALUE "FileVersion", "1, 10, 2910, 14\0" + VALUE "InternalName", "DUMP1090.EXE\0" + VALUE "LegalCopyright", "Copyright (C) 2012 by Salvatore Sanfilippo \r\nCopyright (C) 2014 by Malcolm Robb \0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "DUMP1090.EXE\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "DUMP1090\0" + VALUE "ProductVersion", "1, 10, 2910, 14\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""ntverp.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/net_io.c b/net_io.c index f3a8397..a979883 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); @@ -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; } @@ -702,6 +713,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]; @@ -714,11 +726,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,' '); @@ -743,22 +756,35 @@ 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 { 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 = strdup("Server error occured"); + if (rp && (!strncmp(hrp, rp, strlen(hrp)))) { + if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { + content = (char *) realloc(content, sbuf.st_size); + if (read(fd, content, sbuf.st_size) != -1) { + clen = sbuf.st_size; + statuscode = 200; + } } - clen = sbuf.st_size; } else { - char buf[128]; - clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno)); - content = strdup(buf); + errno = ENOENT; + } + + if (clen < 0) { + content = realloc(content, 128); + clen = snprintf(content, 128,"Error opening HTML file: %s", strerror(errno)); + statuscode = 404; } if (fd != -1) { @@ -782,7 +808,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 %d \r\n" "Server: Dump1090\r\n" "Content-Type: %s\r\n" "Connection: %s\r\n" @@ -790,6 +816,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); @@ -852,6 +879,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) { @@ -862,7 +893,7 @@ void modesReadFromClient(struct client *c, char *sep, #else if ( (nread < 0) && (errno != EWOULDBLOCK)) { // Error, or end of file #endif - modesFreeClient(c); + modesCloseClient(c); return; } if (nread <= 0) { @@ -910,7 +941,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; @@ -926,7 +957,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 @@ -953,15 +984,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; } 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/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