mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Communication must now be enabled explicitly.
The communication subsystem is now disabled until a new BiF, enable_communication(), is called. The base scripts do this automatically when either a Communication::Node is defined, or Bro is asked to listen for incoming connections.
This commit is contained in:
parent
0e2a1605b3
commit
103396f6d3
9 changed files with 27 additions and 43 deletions
|
@ -108,6 +108,9 @@ const src_names = {
|
||||||
event bro_init()
|
event bro_init()
|
||||||
{
|
{
|
||||||
Log::create_stream(COMMUNICATION, [$columns=Info]);
|
Log::create_stream(COMMUNICATION, [$columns=Info]);
|
||||||
|
|
||||||
|
if ( |nodes| > 0 )
|
||||||
|
enable_communication();
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_script_log_common(level: count, src: count, msg: string)
|
function do_script_log_common(level: count, src: count, msg: string)
|
||||||
|
|
|
@ -13,5 +13,6 @@ export {
|
||||||
|
|
||||||
event bro_init() &priority=-10
|
event bro_init() &priority=-10
|
||||||
{
|
{
|
||||||
|
enable_communication();
|
||||||
listen(listen_if_clear, listen_port_clear, F);
|
listen(listen_if_clear, listen_port_clear, F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,6 @@ export {
|
||||||
|
|
||||||
event bro_init() &priority=-10
|
event bro_init() &priority=-10
|
||||||
{
|
{
|
||||||
|
enable_communication();
|
||||||
listen(listen_if_ssl, listen_port_ssl, T);
|
listen(listen_if_ssl, listen_port_ssl, T);
|
||||||
}
|
}
|
||||||
|
|
26
src/Expr.cc
26
src/Expr.cc
|
@ -231,7 +231,6 @@ bool Expr::DoUnserialize(UnserialInfo* info)
|
||||||
NameExpr::NameExpr(ID* arg_id) : Expr(EXPR_NAME)
|
NameExpr::NameExpr(ID* arg_id) : Expr(EXPR_NAME)
|
||||||
{
|
{
|
||||||
id = arg_id;
|
id = arg_id;
|
||||||
ReferenceID();
|
|
||||||
SetType(id->Type()->Ref());
|
SetType(id->Type()->Ref());
|
||||||
|
|
||||||
EventHandler* h = event_registry->Lookup(id->Name());
|
EventHandler* h = event_registry->Lookup(id->Name());
|
||||||
|
@ -244,29 +243,6 @@ NameExpr::~NameExpr()
|
||||||
Unref(id);
|
Unref(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NameExpr::ReferenceID()
|
|
||||||
{
|
|
||||||
// ### This is a hack. We check whether one of the remote serializer's
|
|
||||||
// built-in functions is referenced. If so, we activate the serializer.
|
|
||||||
// A better solution would be to either (1) a generic mechanism in
|
|
||||||
// which have (internal) attributes associated with identifiers and
|
|
||||||
// as we see references to the identifiers, we do bookkeeping
|
|
||||||
// associated with their attribute (so in this case the attribute
|
|
||||||
// would be "flag that inter-Bro communication is being used"),
|
|
||||||
// or (2) after the parse is done, we'd query whether these
|
|
||||||
// particular identifiers were seen, rather than doing the test
|
|
||||||
// here for every NameExpr we create.
|
|
||||||
if ( id->Type()->Tag() == TYPE_FUNC )
|
|
||||||
{
|
|
||||||
const char* const* builtins = remote_serializer->GetBuiltins();
|
|
||||||
while( *builtins )
|
|
||||||
{
|
|
||||||
if ( streq(id->Name(), *builtins++) )
|
|
||||||
using_communication = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Expr* NameExpr::Simplify(SimplifyType simp_type)
|
Expr* NameExpr::Simplify(SimplifyType simp_type)
|
||||||
{
|
{
|
||||||
if ( simp_type != SIMPLIFY_LHS && id->IsConst() )
|
if ( simp_type != SIMPLIFY_LHS && id->IsConst() )
|
||||||
|
@ -393,8 +369,6 @@ bool NameExpr::DoUnserialize(UnserialInfo* info)
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ReferenceID();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,6 @@ protected:
|
||||||
friend class Expr;
|
friend class Expr;
|
||||||
NameExpr() { id = 0; }
|
NameExpr() { id = 0; }
|
||||||
|
|
||||||
void ReferenceID();
|
|
||||||
void ExprDescribe(ODesc* d) const;
|
void ExprDescribe(ODesc* d) const;
|
||||||
|
|
||||||
DECLARE_SERIAL(NameExpr);
|
DECLARE_SERIAL(NameExpr);
|
||||||
|
|
|
@ -3060,13 +3060,6 @@ bool RemoteSerializer::IsActive()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* const* RemoteSerializer::GetBuiltins() const
|
|
||||||
{
|
|
||||||
static const char* builtins[] = { "connect", "listen", 0 };
|
|
||||||
return builtins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoteSerializer::ReportError(const char* msg)
|
void RemoteSerializer::ReportError(const char* msg)
|
||||||
{
|
{
|
||||||
if ( current_peer && current_peer->phase != Peer::SETUP )
|
if ( current_peer && current_peer->phase != Peer::SETUP )
|
||||||
|
|
|
@ -128,10 +128,6 @@ public:
|
||||||
// Log some statistics.
|
// Log some statistics.
|
||||||
void LogStats();
|
void LogStats();
|
||||||
|
|
||||||
// Return a 0-terminated array of built-in functions which,
|
|
||||||
// when referenced, trigger the remote serializer's initialization.
|
|
||||||
const char* const* GetBuiltins() const;
|
|
||||||
|
|
||||||
// Tries to sent out all remaining data.
|
// Tries to sent out all remaining data.
|
||||||
// FIXME: Do we still need this?
|
// FIXME: Do we still need this?
|
||||||
void Finish();
|
void Finish();
|
||||||
|
|
24
src/bro.bif
24
src/bro.bif
|
@ -3632,7 +3632,27 @@ function piped_exec%(program: string, to_write: string%): bool
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "%s", to_write->CheckString());
|
fprintf(f, "%s", to_write->CheckString());
|
||||||
pclose(f);
|
pclose(f);
|
||||||
|
|
||||||
return new Val(true, TYPE_BOOL);
|
return new Val(true, TYPE_BOOL);
|
||||||
|
%}
|
||||||
|
|
||||||
|
## Enables the communication system. Note that by default,
|
||||||
|
## communication is off until explicitly enabled, and all other calls
|
||||||
|
## to communication-related BiFs' will be ignored until done so.
|
||||||
|
function enable_communication%(%): any
|
||||||
|
%{
|
||||||
|
if ( bro_start_network_time != 0.0 )
|
||||||
|
{
|
||||||
|
builtin_error("communication must be enabled in bro_init");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( using_communication )
|
||||||
|
// Ignore duplicate calls.
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
using_communication = 1;
|
||||||
|
remote_serializer->Init();
|
||||||
|
return 0;
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -880,9 +880,6 @@ int main(int argc, char** argv)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( using_communication )
|
|
||||||
remote_serializer->Init();
|
|
||||||
|
|
||||||
persistence_serializer->SetDir((const char *)state_dir->AsString()->CheckString());
|
persistence_serializer->SetDir((const char *)state_dir->AsString()->CheckString());
|
||||||
|
|
||||||
// Print the ID.
|
// Print the ID.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue