mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Remote logging for the new logging framework.
It works with a simple example, but that's as much testing as it has seen so far. Remote::Destination has a new attribute "request_logs: bool" indicating whether we are interested in the peer's log. Default is false. If true, Bro will send an explicit "I want your logs" message over to the other side, which will then start sending log records back. When such log records are received, they will be recorded exactly in the same way as on the remote side, i.e., same fields/writer/path. All filtering is already performed on the remote side. Log::Filter has two new attributes, "log_local: bool" and "log_remote: bool" (both true by default). If log_local is false, this filter will not record anything locally but still process everything normally otherwise and potentially forward to remote. If log_remote is false, this filter will never send anything to remote even if a peer has requested logs. (Note that with the defaults, requesting logs will mean getting everything.) Note that with log forwarding, *both* sides must create the Filter::Stream. If the remote sends log records for a specific stream, but the local side hasn't created it, the data will be discarded. Filtes on the other hand shouldn't created locally; and if they are, they are ignored for records received from remote).
This commit is contained in:
parent
c355f5d1fa
commit
3f413a2539
11 changed files with 690 additions and 59 deletions
|
@ -5,6 +5,10 @@
|
|||
#ifndef SERIALIZATION_FORMAT
|
||||
#define SERIALIZATION_FORMAT
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "util.h"
|
||||
|
||||
// Abstract base class.
|
||||
|
@ -25,6 +29,10 @@ public:
|
|||
virtual bool Read(char* v, const char* tag) = 0;
|
||||
virtual bool Read(bool* v, const char* tag) = 0;
|
||||
virtual bool Read(double* d, const char* tag) = 0;
|
||||
virtual bool Read(string* s, const char* tag) = 0;
|
||||
|
||||
// Returns number of raw bytes read since last call to StartRead().
|
||||
int BytesRead() const { return bytes_read; }
|
||||
|
||||
// Passes ownership of string.
|
||||
virtual bool Read(char** str, int* len, const char* tag) = 0;
|
||||
|
@ -43,6 +51,7 @@ public:
|
|||
virtual bool Write(double d, const char* tag) = 0;
|
||||
virtual bool Write(const char* s, const char* tag) = 0;
|
||||
virtual bool Write(const char* buf, int len, const char* tag) = 0;
|
||||
virtual bool Write(const string& s, const char* tag) = 0;
|
||||
|
||||
virtual bool WriteOpenTag(const char* tag) = 0;
|
||||
virtual bool WriteCloseTag(const char* tag) = 0;
|
||||
|
@ -65,6 +74,7 @@ protected:
|
|||
uint32 input_pos;
|
||||
|
||||
int bytes_written;
|
||||
int bytes_read;
|
||||
};
|
||||
|
||||
class BinarySerializationFormat : public SerializationFormat {
|
||||
|
@ -81,6 +91,7 @@ public:
|
|||
virtual bool Read(bool* v, const char* tag);
|
||||
virtual bool Read(double* d, const char* tag);
|
||||
virtual bool Read(char** str, int* len, const char* tag);
|
||||
virtual bool Read(string* s, const char* tag);
|
||||
virtual bool Write(int v, const char* tag);
|
||||
virtual bool Write(uint16 v, const char* tag);
|
||||
virtual bool Write(uint32 v, const char* tag);
|
||||
|
@ -91,6 +102,7 @@ public:
|
|||
virtual bool Write(double d, const char* tag);
|
||||
virtual bool Write(const char* s, const char* tag);
|
||||
virtual bool Write(const char* buf, int len, const char* tag);
|
||||
virtual bool Write(const string& s, const char* tag);
|
||||
virtual bool WriteOpenTag(const char* tag);
|
||||
virtual bool WriteCloseTag(const char* tag);
|
||||
virtual bool WriteSeparator();
|
||||
|
@ -112,6 +124,7 @@ public:
|
|||
virtual bool Write(double d, const char* tag);
|
||||
virtual bool Write(const char* s, const char* tag);
|
||||
virtual bool Write(const char* buf, int len, const char* tag);
|
||||
virtual bool Write(const string& s, const char* tag);
|
||||
virtual bool WriteOpenTag(const char* tag);
|
||||
virtual bool WriteCloseTag(const char* tag);
|
||||
virtual bool WriteSeparator();
|
||||
|
@ -126,6 +139,7 @@ public:
|
|||
virtual bool Read(bool* v, const char* tag);
|
||||
virtual bool Read(double* d, const char* tag);
|
||||
virtual bool Read(char** str, int* len, const char* tag);
|
||||
virtual bool Read(string* s, const char* tag);
|
||||
|
||||
private:
|
||||
// Encodes non-printable characters.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue