aboutsummaryrefslogtreecommitdiffstats
path: root/epan/maxmind_db.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-02-10 00:19:54 +0100
committerPeter Wu <peter@lekensteyn.nl>2019-02-16 21:11:12 +0000
commitba1ef0ec3d15927e72d3705bed295807e5054a75 (patch)
tree6ae4973c228051dbcbceefe95c81c49f68115d21 /epan/maxmind_db.c
parent2f7cc1ac334778857f8319ad4f2a0e8248ed9195 (diff)
Re-implement "Map" feature for Endpoints
This feature was removed in v2.5.1rc0-427-gf529ab5d0a, anticipating that MaxMind would remove support for it in 2019. They have however changed their mind and maintained latitude and longitude information. They recommend displaying an accuracy radius, but the reported values are 50, 100, 200 and 1000km. When implemented literally, a marker in Ireland would cover the whole island plus mainland, so I have instead opted to use a fixed radius of 1km at deeper zoom levels. The old ipmap.html file was outdated and had broken tiles, I rewrote a new one from scratch using the light-weight Leaflet library combined with tiles from OpenStreetMap. This is more mobile-friendly and secure (https, SRI). To improve handling of nearby or overlapping nodes, clustering is used (individual nodes can still be inspected). Browser compatibility results: IE8 is unusable, IE9 partially works (tooltips sometimes disappear and the cluster radius control is gone), IE11 works. Of course Firefox 65 and Chromium 72 have no issues. The map popup description in the generated GeoJSON structure is now split in several properties, allowing presentation to be handled by the HTML page instead of the C code. Bug: 14693 Change-Id: If2ec9c518f7723ac0ab27b6272463356875a0ff2 Reviewed-on: https://code.wireshark.org/review/31952 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/maxmind_db.c')
-rw-r--r--epan/maxmind_db.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/epan/maxmind_db.c b/epan/maxmind_db.c
index 9acf8e047e..a0086b3569 100644
--- a/epan/maxmind_db.c
+++ b/epan/maxmind_db.c
@@ -119,6 +119,7 @@ static void mmdb_resolve_stop(void);
#define RES_ASN_NUMBER "autonomous_system_number"
#define RES_LOCATION_LATITUDE "location.latitude"
#define RES_LOCATION_LONGITUDE "location.longitude"
+#define RES_LOCATION_ACCURACY "location.accuracy_radius"
#define RES_END "# End "
// Interned strings and v6 addresses, similar to GLib's string chunks.
@@ -145,7 +146,7 @@ static const void *chunkify_v6_addr(const ws_in6_addr *addr) {
}
static void init_lookup(mmdb_lookup_t *lookup) {
- mmdb_lookup_t empty_lookup = { FALSE, NULL, NULL, NULL, 0, NULL, DBL_MAX, DBL_MAX };
+ mmdb_lookup_t empty_lookup = { FALSE, NULL, NULL, NULL, 0, NULL, DBL_MAX, DBL_MAX, 0 };
*lookup = empty_lookup;
}
@@ -311,6 +312,12 @@ read_mmdbr_stdout_worker(gpointer data _U_) {
} else if (val_start && g_str_has_prefix(line, RES_LOCATION_LONGITUDE)) {
response->mmdb_val.found = TRUE;
response->mmdb_val.longitude = g_ascii_strtod(val_start, NULL);
+ } else if (val_start && g_str_has_prefix(line, RES_LOCATION_ACCURACY)) {
+ if (ws_strtou16(val_start, NULL, &response->mmdb_val.accuracy)) {
+ response->mmdb_val.found = TRUE;
+ } else {
+ MMDB_DEBUG("Invalid accuracy radius: %s", val_start);
+ }
} else if (g_str_has_prefix(line, RES_END)) {
if (response->mmdb_val.found && cur_addr[0]) {
if (country_iso->len) {