dump1090 icon indicating copy to clipboard operation
dump1090 copied to clipboard

Display signal level and fix JSON URL for using dump1090 with reverse http proxy.

Open kad opened this issue 10 years ago • 7 comments

For debug purposes, it's good to see signal levels via webui, so I've added that information into exported JSON data.


This change is Reviewable

kad avatar Nov 01 '14 15:11 kad

Why change the URL in dump1090 location instead of configuring nginx to either proxy /dump1090/ or rewrite the request? It seems more correct to use the front-end proxy to map URLs instead of changing locations in the JavaScript.

mernisse avatar Nov 12 '14 15:11 mernisse

First of all, location of rpc call for json data should be relative to top URL of dump1090 application. Having it as /dump1090/xxxx means that on one server it is possible to proxy only to one instance of dump1090, otherwise it will become nightmare of rewrite rules.

Second, we are currently lucky that existing url "/dump1090/data.json" works at all. The code in net_io.c has assumptions that "/" is google maps app, and "/data.json" relative to it is endpoint to generate json data. However, comparison is not strict, so on any running instance of dump1090 http request for "http://server.addr.example.com:8080/some/crap/in/the/url/data.jsonfoo" would anyway result with generation of same data.
So, change at least to make sure that script.js is asking what was initially intended to be asked from server side, despite of implementation error on checking url in net_io.c

snip from net_io.c:

    // Select the content to send, we have just two so far:
    // "/" -> Our google map application.
    // "/data.json" -> Our ajax request to update planes.
    if (strstr(url, "/data.json")) {

example:

GET http://10.0.0.17/some/cra//in/url/data.jsonfdjlfajdljfjdaslfjdlasfdas HTTP/1.0

HTTP/1.1 200
Server: Dump1090
Content-Type: application/json;charset=utf-8
Connection: close
Content-Length: 2025
Cache-Control: no-cache, must-revalidate
Expires: Sat, 26 Jul 1997 05:00:00 GMT

[
{"hex":"4baa0d", "squawk":"0000", "flight":"", "lat":0.000000, "lon":0.000000, "validposition":0, "altitude":3425,  "vert_rate":1664,"track":48, "validtrack":1,"speed":198, "messages":3, "seen":7, "signal":13, "mtime":1415809344, "postime":0},
...

kad avatar Nov 12 '14 16:11 kad

Add signal level does not work do you know why

steel101 avatar Mar 21 '15 22:03 steel101

What do you mean by "does not work" ? what do you see in json output after applying patches ?

kad avatar Mar 22 '15 04:03 kad

When I insert your code I do not get output only na on the webpage On Mar 21, 2015 11:58 PM, "Alexandr D. Kanevskiy" [email protected] wrote:

What do you mean by "does not work" ? what do you see in json output after applying patches ?

— Reply to this email directly or view it on GitHub https://github.com/MalcolmRobb/dump1090/pull/56#issuecomment-84521835.

steel101 avatar Mar 22 '15 05:03 steel101

Interesting. I assume you re-started and re-compiled dump1090 after applying code, so can you check that your dump1090 started to expose that to json ?

In example below, replace your IP / port where your dump1090 running, then verify that in resulted json data there is "signal" and "mtime" keys.

$ curl http://10.0.0.17:8080/data.json
[
{"hex":"47c071", "squawk":"5023", "flight":"SAS705  ", "lat":60.449936, "lon":24.860640, "validposition":1, "altitude":15000,  "vert_rate":3776,"track":258, "validtrack":1,"speed":321, "messages":124, "seen":0, "signal":19, "mtime":1427010095, "postime":1427010093},
...
]

kad avatar Mar 22 '15 07:03 kad

it took me awhile but it is now merged in my fork with more now thank you if any more changes let me know

steel101 avatar Mar 22 '15 14:03 steel101