mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Conn: Add InitPostScript() and conn_id_ctx singleton
This commit is contained in:
parent
a2922cdde9
commit
eba6355b84
3 changed files with 17 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <cctype>
|
||||
|
||||
#include "zeek/Desc.h"
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/Reporter.h"
|
||||
#include "zeek/RunState.h"
|
||||
|
@ -22,6 +23,12 @@ namespace zeek {
|
|||
|
||||
uint64_t Connection::total_connections = 0;
|
||||
uint64_t Connection::current_connections = 0;
|
||||
zeek::RecordValPtr Connection::conn_id_ctx_singleton;
|
||||
|
||||
void Connection::InitPostScript() {
|
||||
if ( id::conn_id_ctx->NumFields() == 0 )
|
||||
conn_id_ctx_singleton = zeek::make_intrusive<zeek::RecordVal>(id::conn_id_ctx);
|
||||
}
|
||||
|
||||
Connection::Connection(zeek::IPBasedConnKeyPtr k, double t, uint32_t flow, const Packet* pkt)
|
||||
: Session(t, connection_timeout, connection_status_update, detail::connection_status_update_interval),
|
||||
|
|
|
@ -209,6 +209,9 @@ public:
|
|||
// Returns true once Done() is called.
|
||||
bool IsFinished() { return finished; }
|
||||
|
||||
// Runs after all scripts have been parsed.
|
||||
static void InitPostScript();
|
||||
|
||||
private:
|
||||
// Common initialization for the constructors. This can move back into the
|
||||
// (sole) constructor when we remove the deprecated one in 8.1.
|
||||
|
@ -244,6 +247,11 @@ private:
|
|||
// Count number of connections.
|
||||
static uint64_t total_connections;
|
||||
static uint64_t current_connections;
|
||||
|
||||
// When the conn_id_ctx record type has no fields,
|
||||
// this holds a singleton record value for it that
|
||||
// is shared among all conn_id record values.
|
||||
static RecordValPtr conn_id_ctx_singleton;
|
||||
};
|
||||
|
||||
// The following is used by script optimization.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <binpac.h>
|
||||
|
||||
#include "zeek/Conn.h"
|
||||
#include "zeek/DNS_Mgr.h"
|
||||
#include "zeek/Debug.h"
|
||||
#include "zeek/Desc.h"
|
||||
|
@ -842,6 +843,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
|
|||
exit(1);
|
||||
|
||||
RecordType::InitPostScript();
|
||||
Connection::InitPostScript();
|
||||
|
||||
conn_key_mgr->InitPostScript();
|
||||
telemetry_mgr->InitPostScript();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue