mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Emit missing GeoIP database errors only once at startup
Instead of one error per lookup.
This commit is contained in:
parent
d7097635f4
commit
2ede95422b
3 changed files with 26 additions and 3 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
2.6-beta2-8 | 2018-09-21 13:25:50 -0500
|
||||||
|
|
||||||
|
* Emit missing GeoIP database errors only once at startup (Jon Siwek, Corelight)
|
||||||
|
|
||||||
2.6-beta2-7 | 2018-09-21 10:18:55 -0500
|
2.6-beta2-7 | 2018-09-21 10:18:55 -0500
|
||||||
|
|
||||||
* Fix compile error in MMDB GeoIP code (Jon Siwek, Corelight)
|
* Fix compile error in MMDB GeoIP code (Jon Siwek, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.6-beta2-7
|
2.6-beta2-8
|
||||||
|
|
21
src/bro.bif
21
src/bro.bif
|
@ -3695,6 +3695,8 @@ const char* MMDB::Filename()
|
||||||
|
|
||||||
std::unique_ptr<MMDB> mmdb_loc;
|
std::unique_ptr<MMDB> mmdb_loc;
|
||||||
std::unique_ptr<MMDB> mmdb_asn;
|
std::unique_ptr<MMDB> mmdb_asn;
|
||||||
|
static bool did_mmdb_loc_db_error = false;
|
||||||
|
static bool did_mmdb_asn_db_error = false;
|
||||||
|
|
||||||
static bool mmdb_open(const char* filename, bool asn)
|
static bool mmdb_open(const char* filename, bool asn)
|
||||||
{
|
{
|
||||||
|
@ -3719,6 +3721,11 @@ static bool mmdb_open(const char* filename, bool asn)
|
||||||
|
|
||||||
catch ( const std::exception& e )
|
catch ( const std::exception& e )
|
||||||
{
|
{
|
||||||
|
if ( asn )
|
||||||
|
did_mmdb_asn_db_error = false;
|
||||||
|
else
|
||||||
|
did_mmdb_loc_db_error = false;
|
||||||
|
|
||||||
reporter->Info("Failed to open MaxMind DB: %s [%s]", filename,
|
reporter->Info("Failed to open MaxMind DB: %s [%s]", filename,
|
||||||
e.what());
|
e.what());
|
||||||
return false;
|
return false;
|
||||||
|
@ -3742,6 +3749,7 @@ static void mmdb_check_loc()
|
||||||
if ( mmdb_loc && mmdb_loc->StaleDB() )
|
if ( mmdb_loc && mmdb_loc->StaleDB() )
|
||||||
{
|
{
|
||||||
reporter->Info("Closing stale MaxMind DB [%s]", mmdb_loc->Filename());
|
reporter->Info("Closing stale MaxMind DB [%s]", mmdb_loc->Filename());
|
||||||
|
did_mmdb_loc_db_error = false;
|
||||||
mmdb_loc.release();
|
mmdb_loc.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3751,6 +3759,7 @@ static void mmdb_check_asn()
|
||||||
if ( mmdb_asn && mmdb_asn->StaleDB() )
|
if ( mmdb_asn && mmdb_asn->StaleDB() )
|
||||||
{
|
{
|
||||||
reporter->Info("Closing stale MaxMind DB [%s]", mmdb_asn->Filename());
|
reporter->Info("Closing stale MaxMind DB [%s]", mmdb_asn->Filename());
|
||||||
|
did_mmdb_asn_db_error = false;
|
||||||
mmdb_asn.release();
|
mmdb_asn.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3943,7 +3952,12 @@ function lookup_location%(a: addr%) : geo_location
|
||||||
{
|
{
|
||||||
if ( ! mmdb_try_open_loc() )
|
if ( ! mmdb_try_open_loc() )
|
||||||
{
|
{
|
||||||
|
if ( ! did_mmdb_loc_db_error )
|
||||||
|
{
|
||||||
|
did_mmdb_loc_db_error = true;
|
||||||
builtin_error("Failed to open GeoIP location database");
|
builtin_error("Failed to open GeoIP location database");
|
||||||
|
}
|
||||||
|
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4021,7 +4035,12 @@ function lookup_asn%(a: addr%) : count
|
||||||
{
|
{
|
||||||
if ( ! mmdb_try_open_asn() )
|
if ( ! mmdb_try_open_asn() )
|
||||||
{
|
{
|
||||||
builtin_error("No open GeoIP ASN database");
|
if ( ! did_mmdb_asn_db_error )
|
||||||
|
{
|
||||||
|
did_mmdb_asn_db_error = true;
|
||||||
|
builtin_error("Failed to open GeoIP ASN database");
|
||||||
|
}
|
||||||
|
|
||||||
return new Val(0, TYPE_COUNT);
|
return new Val(0, TYPE_COUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue