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
|
@ -44,6 +44,7 @@ void SerializationFormat::StartWrite()
|
|||
|
||||
output_pos = 0;
|
||||
bytes_written = 0;
|
||||
bytes_read = 0;
|
||||
}
|
||||
|
||||
uint32 SerializationFormat::EndWrite(char** data)
|
||||
|
@ -64,6 +65,8 @@ bool SerializationFormat::ReadData(void* b, size_t count)
|
|||
|
||||
memcpy(b, input + input_pos, count);
|
||||
input_pos += count;
|
||||
bytes_read += count;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -214,6 +217,20 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinarySerializationFormat::Read(string* v, const char* tag)
|
||||
{
|
||||
char* buffer;
|
||||
int len;
|
||||
|
||||
if ( ! Read(&buffer, &len, tag) )
|
||||
return false;
|
||||
|
||||
*v = string(buffer, len);
|
||||
|
||||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BinarySerializationFormat::Write(char v, const char* tag)
|
||||
{
|
||||
DBG_LOG(DBG_SERIAL, "Write char %s [%s]", fmt_bytes(&v, 1), tag);
|
||||
|
@ -278,6 +295,11 @@ bool BinarySerializationFormat::Write(const char* s, const char* tag)
|
|||
return Write(s, strlen(s), tag);
|
||||
}
|
||||
|
||||
bool BinarySerializationFormat::Write(const string& s, const char* tag)
|
||||
{
|
||||
return Write(s.data(), s.size(), tag);
|
||||
}
|
||||
|
||||
bool BinarySerializationFormat::WriteOpenTag(const char* tag)
|
||||
{
|
||||
return true;
|
||||
|
@ -362,6 +384,12 @@ bool XMLSerializationFormat::Read(char** str, int* len, const char* tag)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool XMLSerializationFormat::Read(string* s, const char* tag)
|
||||
{
|
||||
internal_error("no reading of xml");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XMLSerializationFormat::Write(char v, const char* tag)
|
||||
{
|
||||
return WriteElem(tag, "char", &v, 1);
|
||||
|
@ -416,6 +444,11 @@ bool XMLSerializationFormat::Write(const char* s, const char* tag)
|
|||
return WriteElem(tag, "string", s, strlen(s));
|
||||
}
|
||||
|
||||
bool XMLSerializationFormat::Write(const string& s, const char* tag)
|
||||
{
|
||||
return WriteElem(tag, "string", s.data(), s.size());
|
||||
}
|
||||
|
||||
bool XMLSerializationFormat::WriteOpenTag(const char* tag)
|
||||
{
|
||||
return WriteData("<", 1) && WriteData(tag, strlen(tag) && WriteData(">", 1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue