Commit graph

5 commits

Author SHA1 Message Date
Christian Kreibich
c2e791287e Fix MMDB::Lookup() to check result status correctly
This function confused checking the return value of MMDB_lookup_sockaddr() with
testing the value of the returned result.found_entry bit when that call
succeeds. Both need to happen.
2024-01-25 23:54:22 -08:00
Christian Kreibich
dbad072f06 Modernize various C++/Zeek-isms in the MMDB code. 2024-01-11 17:13:41 -08:00
Christian Kreibich
e8f0f727cd Fix MMDB code to re-open explicitly opened DBs correctly
The filename from which a DB first gets opened (either via an explicitly
specified filename, or via the path sequence now configurable at the script
layer) is now "sticky", meaning re-opening won't switch to a different file.

This was easiest by moving most state into the MMDB class itself. The previous
approach of tracking the two DB instances via a smart pointer and blowing the
pointed-to objects away as needed is now instead one of two objects fixed over
the lifetime of Zeek, able to open/close/reopen their underlying Maxmind DBs.

The MMDB class now only has one Lookup() method since there was no need to break
them apart -- it saves the return of a MMDB_lookup_result_s over the stack and
there's no need for throwing an exception.
2024-01-10 20:44:40 -08:00
Christian Kreibich
07499cd2e5 Simplify MMDB code by moving more lookup functionality into MMDB class 2024-01-10 20:44:40 -08:00
Christian Kreibich
a06053ce75 Move MMDB logic out of mmdb.bif and into MMDB.cc/h.
This does not change the implementation except for some light renaming where
things are now naturally scoped within MMDB.cc.
2024-01-10 20:44:35 -08:00