aboutsummaryrefslogtreecommitdiffstats
path: root/epan/maxmind_db.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-27HTTPS In Still More Places, update more URLs.Guy Harris1-2/+2
Microsoft reshuffled their documentation - almost all of it moved from msdn.microsoft.com to docs.microsoft.com. Some blogs moved to devblogs.microsoft.com; the comments *didn't* move, so in one case we go to the Wayback Machine - the link isn't dead, but it formats horribly, at least on my browser, but the archived version formats OK. Use the Wayback Machine for some URLs, and update others. Update the sections for MS-ADTS. Point to the HTML versions of some RFCs and I-Ds. Change-Id: I344b20f880de63f1ae2a4e3f9ff98af78a7fe139 Reviewed-on: https://code.wireshark.org/review/34101 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-04maxmind_db: Work around an apparent GLib bug.Gerald Combs1-3/+18
g_async_queue_timeout_pop can return immediately on macOS and possibly other OSes when using older versions of GLib. Replace it with g_async_queue_pop and a "stop" sentinel value. Bug: 15545 Change-Id: Id0bfacd4a94ec9645d2d27ba92d3a2f48e7d5f37 Reviewed-on: https://code.wireshark.org/review/32289 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-02-16Re-implement "Map" feature for EndpointsPeter Wu1-1/+8
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>
2019-02-11Change maxmind_db_lookup_ipv4 to look more like maxmind_db_lookup_ipv6Peter Wu1-5/+5
Both functions accept an address in network byte order, but maxmind_db_lookup_ipv4 does not accept a pointer. Add an indirection and remove unnecessary memcpy calls. This removes some confusion for me. Change-Id: I291c54c8c55bc8048ca011b84918c8a5d3ed1398 Reviewed-on: https://code.wireshark.org/review/31951 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-11maxmind_db: improve debug messages, harden against bad inputPeter Wu1-18/+27
Ensure that country, city, etc. are reset when processing new responses. Otherwise if the new response lacks a City, then it would use the result of the last query. Harden against bad addresses and print debug messages if a bad address is detected. Miscellaneous cleanups: improve debug messages (strip whitespace earlier, etc.), use g_string_assign when possible. Change-Id: I2acad5fcc02c5a8bf684e8fb01ee2d688d926990 Reviewed-on: https://code.wireshark.org/review/31950 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-11maxmind_db: fix broken GeoIP lookups due to bad address processingPeter Wu1-3/+1
The "current address" must remain valid until the end of response is processed, otherwise a bogus entry will be inserted. Move "cur_addr" outside the block to avoid undefined behavior. Change-Id: Icc2c64280ffeabd632b51d36d6be2020eb83a6a9 Fixes: v2.9.1rc0-125-g2d9a6c2583 ("maxmind_db: force buffer contain an empty string (CID: 1441961).") Reviewed-on: https://code.wireshark.org/review/31949 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-05maxmind_db: Close our pipe FDs inside a lock.Gerald Combs1-4/+15
Lock our pipe mutex before closing its file descriptors. This should hopefully fix some infrequent crashes that I'm seeing on my Windows 7 VM. Add a note about GRWLock behavior on Windows which doesn't appear to be related to this issue, but which is nevertheless important. Ping-Bug: 14701 Change-Id: I32e66a24258264fa65a907f319755594f90c0177 Reviewed-on: https://code.wireshark.org/review/31375 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-26maxmind_db: force buffer contain an empty string (CID: 1441961).Dario Lombardo1-0/+2
Change-Id: Ia290f528befa0c071de9e62ea264fdda0740d6f8 Reviewed-on: https://code.wireshark.org/review/31206 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-03maxminddb: Expand a comment.Gerald Combs1-2/+8
Change-Id: Iac0d158ccc56c40c87ccc8399a8a5b16af768e12 Reviewed-on: https://code.wireshark.org/review/30901 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-03Revert "maxmind: Simplify our read logic."Gerald Combs1-14/+28
This reverts commit 4154e35cde9c863ace57598cabc37034dab2ab1c. Apparently we do need to call PeekNamedPipe on Windows. Change-Id: I9c9bbcb56bf1e1c2e6ae240ac5056b8a80674f15 Reviewed-on: https://code.wireshark.org/review/30900 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-02maxmind: Simplify our read logic.Gerald Combs1-28/+14
Don't bother checking to see if our pipe has data. Change-Id: I55f24850a16f66be9c679ad51e35df9f35c206db Reviewed-on: https://code.wireshark.org/review/30877 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-01maxmind: Process responses one character at a time.Gerald Combs1-22/+62
Process mmdbresolve output one character at a time and only after ws_pipe_data_available tells us that we can do so without blocking. Bug: 14701 Change-Id: Ib8f5eabed28e9385585a022d948b83f830c6358c Reviewed-on: https://code.wireshark.org/review/30850 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-30maxmind: Move response processing to a thread.Gerald Combs1-98/+150
Move response processing to a thread. Blind attempt at fixing bug 14701. Bug: 14701 Change-Id: I2b7e6a0669c4784c7c169e659fa37ea2e62c96a3 Reviewed-on: https://code.wireshark.org/review/30837 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01wsutil: introduce ws_pipe_close() helper and use it to terminate mmdbresolvePascal Quantin1-2/+1
We were not calling TerminateProcess() to stop mmdbresolve.Exe process on Windows. Bug: 15248 Change-Id: Ic90cf438a8003a6fefb023b7056984681ce09b46 Reviewed-on: https://code.wireshark.org/review/30449 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01mmdb: do not lock the pipe mutex recursivelyPascal Quantin1-9/+11
According to GLib documentation, take twice the lock in the same thread leads to undefined behavior (and could lead to deadlocks). Change-Id: I40e02ba9d619eb1db2a04f2be54c461c817b15ff Reviewed-on: https://code.wireshark.org/review/30446 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-26maxmind_db.c: fix a memory leakPascal Quantin1-3/+3
Change-Id: Iee898541ec723cec209a3561899530a8dbe6e680 Reviewed-on: https://code.wireshark.org/review/27809 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-24maxmind: Move request processing to a thread.Gerald Combs1-33/+86
It's possible to block while we're writing to our mmdbresolve pipe, particularly on Windows. Move the write to a separate thread. Add an #ifdef to mmdbresolve.c which helps test blocking. Bug: 14701 Change-Id: I6cb8a46a190a268da64f1e6f54d1052d03743c95 Reviewed-on: https://code.wireshark.org/review/27750 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18maxmind: Process our requests more often.Gerald Combs1-2/+12
The answer to // XXX Should we call maxmind_db_lookup_process first? in maxmind_db.c is "yes", since it's possible to fill up our pipe between host name lookup intervals, at least on Windows. Note that we might want to move request processing to a thread. Bug: 14701 Change-Id: I8cfb77444d7f999e77571bc6bb61ea7f1f677778 Reviewed-on: https://code.wireshark.org/review/27644 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-13Properly initialize mmdb_lookup_t.Gerald Combs1-3/+8
Set our initial geographic coordinates to DBL_MAX, otherwise we might give people the wrong impression about the PIRATA weather buoy at 0°0'0" N 0°0'0" E. Change-Id: I34683883ef02c4fe40d5d93a7695d0cca277345c Reviewed-on: https://code.wireshark.org/review/26463 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-11maxmind: check val_start before using it.Dario Lombardo1-4/+4
Change-Id: Id3ee8e8d4c54c02d68048ec677fdda599b329713 Reviewed-on: https://code.wireshark.org/review/26417 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-11maxmind: use ws_strtou32 to convert AS numbers.Dario Lombardo1-3/+7
Change-Id: I0578f8a674feee6e4763d5481a2285b7b2a054dc Reviewed-on: https://code.wireshark.org/review/26416 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10MaxMindDB: Add country ISO codes.Gerald Combs1-1/+4
Add and dissect country ISO codes. Prefer them when printing summary information. Change-Id: I3ce2bde88fa5ca2604c8bb745c42f239660252ff Reviewed-on: https://code.wireshark.org/review/26415 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10MaxMind DB: Fixup IPv6 address interning.Gerald Combs1-2/+7
Intern IPv6 addresses into their own hash table. Change-Id: I1ad60bf56585fcd89964e949e8754af3c7512a75 Reviewed-on: https://code.wireshark.org/review/26414 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10Process MaxMind DB data one line at a time.Gerald Combs1-77/+74
Use fgets instead of ws_read + g_strsplit. Change-Id: I9d13183cc129e0c749742779f9c48fdfba21a8fc Reviewed-on: https://code.wireshark.org/review/26374 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-09maxminf_db.c: ad an explicit cast to please gcc 7.3.1Pascal Quantin1-1/+1
Change-Id: Ie97008ece77e485948a3a8d418a49b77c1a52a33 Reviewed-on: https://code.wireshark.org/review/26395 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-09GeoIP: avoid closing random file descriptorsPeter Wu1-6/+19
Previously there were three different pipe validity checks: PID != WS_INVALID_PID, PID != 0 and stdin != 0. This resulted in using/closing file descriptors which might be owned by something else. When no GeoIP databases are defined, mmdb_resolve_stop would be called to close the pipe and set PID to WS_INVALID_PID. stdin is however not cleared and future invocations would try to close the previous fd. Change-Id: I1d15da29208efb41098ee6a4edeeabf61f84c2b3 Fixes: v2.5.1rc0-466-ga1da75c554 ("Transition from GeoIP Legacy to MaxMindDB.") Reviewed-on: https://code.wireshark.org/review/26391 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-09Add MaxMindDB 1.3.2 library to WindowsPascal Quantin1-2/+2
Change-Id: I328b6a05cc356be59ac63e80eae55a832bf76a47 Reviewed-on: https://code.wireshark.org/review/26347 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-09Intern MaxMinDB IPv6 addresses.Gerald Combs1-3/+14
Make sure our IPv6 addresses are unique and allocated, similar to our strings. Bug: 14514 Change-Id: I602b3b0ec4674fb2bc8cbaa973a73a6f3188e0c3 Reviewed-on: https://code.wireshark.org/review/26371 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-08MaxMind DB fixups.Gerald Combs1-9/+12
Make sure the text we read is null terminated. Properly strip our lines and chunked strings. Copy over cast and strtod fixes from change 26347. Change-Id: I0695e35c446c1bd277c53b458b07e428cdd90fb8 Reviewed-on: https://code.wireshark.org/review/26370 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-06maxmind_db.c: fix a memory leakPascal Quantin1-0/+1
Change-Id: Ie3484e863363a8d2b9ccb435088886020678d15d Reviewed-on: https://code.wireshark.org/review/26284 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-06maxmind_db.c: add an explicit cast to please gcc 7.3.1Pascal Quantin1-1/+1
Change-Id: Idb2ae052804fb523d6769fe50b5bb4ba45e40f79 Reviewed-on: https://code.wireshark.org/review/26283 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-06Transition from GeoIP Legacy to MaxMindDB.Gerald Combs1-0/+513
MaxMind is discontinuing its legacy databases in April in favor of GeoIP2, which use a newer database format (MaxMind DB). The reference C library (libmaxminddb) is available under the Apache 2.0 license which isn't quite compatible with ours. Add mmdbresolve, a utility that reads IPv4 and IPv6 addresses on stdin and prints resolved information on stdout. Place it under a liberal license (MIT) so that we can keep libmaxminddb at arm's length. Add epan/maxmind_db.[ch], which spawns mmdbresolve and communicates with it via stdio. Migrate the preferences and documentation to MaxMindDB. Change the IPv4 and IPv6 asnum fields to FT_UINT32s. Change the geographic coordinate fields to FT_DOUBLEs. Bug: 10658 Change-Id: I24aeed637bea1b41d173270bda413af230f4425f Reviewed-on: https://code.wireshark.org/review/26214 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>