mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Working around not being able to do lookup_addr() for IPv6
addresses. Rather than crashing, we warn the user once and then always time out the call. This addresses #291, and a #355 is new ticket scheduling fixing the actual problem to later.
This commit is contained in:
parent
ffaa20602c
commit
bbbe32e443
2 changed files with 19 additions and 3 deletions
|
@ -130,11 +130,17 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
|
||||||
|
|
||||||
Val* timeout = arg_timeout ? arg_timeout->ExprVal() : 0;
|
Val* timeout = arg_timeout ? arg_timeout->ExprVal() : 0;
|
||||||
|
|
||||||
|
// Make sure we don't get deleted if somebody calls a method like
|
||||||
|
// Timeout() while evaluating the trigger.
|
||||||
|
Ref(this);
|
||||||
|
|
||||||
if ( ! Eval() && timeout )
|
if ( ! Eval() && timeout )
|
||||||
{
|
{
|
||||||
timer = new TriggerTimer(timeout->AsInterval(), this);
|
timer = new TriggerTimer(timeout->AsInterval(), this);
|
||||||
timer_mgr->Add(timer);
|
timer_mgr->Add(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unref(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger::~Trigger()
|
Trigger::~Trigger()
|
||||||
|
|
16
src/bro.bif
16
src/bro.bif
|
@ -2813,7 +2813,7 @@ private:
|
||||||
# function result. Therefore, they can only be called inside a when-condition.
|
# function result. Therefore, they can only be called inside a when-condition.
|
||||||
function lookup_addr%(host: addr%) : string
|
function lookup_addr%(host: addr%) : string
|
||||||
%{
|
%{
|
||||||
// FIXME: Is should be easy to adapt the function to synchronous
|
// FIXME: It should be easy to adapt the function to synchronous
|
||||||
// lookups if we're reading a trace.
|
// lookups if we're reading a trace.
|
||||||
Trigger* trigger = frame->GetTrigger();
|
Trigger* trigger = frame->GetTrigger();
|
||||||
|
|
||||||
|
@ -2829,8 +2829,18 @@ function lookup_addr%(host: addr%) : string
|
||||||
#ifdef BROv6
|
#ifdef BROv6
|
||||||
if ( ! is_v4_addr(host) )
|
if ( ! is_v4_addr(host) )
|
||||||
{
|
{
|
||||||
builtin_run_time("lookup_addr() only supports IPv4 addresses");
|
// FIXME: This is a temporary work-around until we get this
|
||||||
return new StringVal("<ipv6-address>");
|
// fixed. We warn the user once, and always trigger a timeout.
|
||||||
|
// Ticket #355 records the problem.
|
||||||
|
static bool warned = false;
|
||||||
|
if ( ! warned )
|
||||||
|
{
|
||||||
|
warn("lookup_addr() only supports IPv4 addresses currently");
|
||||||
|
warned = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger->Timeout();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_mgr->AsyncLookupAddr(to_v4_addr(host),
|
dns_mgr->AsyncLookupAddr(to_v4_addr(host),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue