mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -8,73 +8,71 @@
|
|||
#include "zeek/IPAddr.h"
|
||||
#include "zeek/Val.h"
|
||||
|
||||
namespace zeek::detail
|
||||
{
|
||||
namespace zeek::detail {
|
||||
|
||||
class DNS_Mapping;
|
||||
using DNS_MappingPtr = std::shared_ptr<DNS_Mapping>;
|
||||
|
||||
class DNS_Mapping
|
||||
{
|
||||
class DNS_Mapping {
|
||||
public:
|
||||
DNS_Mapping() = delete;
|
||||
DNS_Mapping(std::string host, struct hostent* h, uint32_t ttl, int type);
|
||||
DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32_t ttl);
|
||||
DNS_Mapping(FILE* f);
|
||||
DNS_Mapping() = delete;
|
||||
DNS_Mapping(std::string host, struct hostent* h, uint32_t ttl, int type);
|
||||
DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32_t ttl);
|
||||
DNS_Mapping(FILE* f);
|
||||
|
||||
bool NoMapping() const { return no_mapping; }
|
||||
bool InitFailed() const { return init_failed; }
|
||||
bool NoMapping() const { return no_mapping; }
|
||||
bool InitFailed() const { return init_failed; }
|
||||
|
||||
~DNS_Mapping() = default;
|
||||
~DNS_Mapping() = default;
|
||||
|
||||
// Returns nil if this was an address request.
|
||||
// TODO: fix this an uses of this to just return the empty string
|
||||
const char* ReqHost() const { return req_host.empty() ? nullptr : req_host.c_str(); }
|
||||
const IPAddr& ReqAddr() const { return req_addr; }
|
||||
std::string ReqStr() const { return req_host.empty() ? req_addr.AsString() : req_host; }
|
||||
int ReqType() const { return req_type; }
|
||||
// Returns nil if this was an address request.
|
||||
// TODO: fix this an uses of this to just return the empty string
|
||||
const char* ReqHost() const { return req_host.empty() ? nullptr : req_host.c_str(); }
|
||||
const IPAddr& ReqAddr() const { return req_addr; }
|
||||
std::string ReqStr() const { return req_host.empty() ? req_addr.AsString() : req_host; }
|
||||
int ReqType() const { return req_type; }
|
||||
|
||||
ListValPtr Addrs();
|
||||
TableValPtr AddrsSet(); // addresses returned as a set
|
||||
StringValPtr Host();
|
||||
ListValPtr Addrs();
|
||||
TableValPtr AddrsSet(); // addresses returned as a set
|
||||
StringValPtr Host();
|
||||
|
||||
double CreationTime() const { return creation_time; }
|
||||
uint32_t TTL() const { return req_ttl; }
|
||||
double CreationTime() const { return creation_time; }
|
||||
uint32_t TTL() const { return req_ttl; }
|
||||
|
||||
void Save(FILE* f) const;
|
||||
void Save(FILE* f) const;
|
||||
|
||||
bool Failed() const { return failed; }
|
||||
bool Valid() const { return ! failed; }
|
||||
bool Failed() const { return failed; }
|
||||
bool Valid() const { return ! failed; }
|
||||
|
||||
bool Expired() const { return util::current_time() > (creation_time + req_ttl); }
|
||||
bool Expired() const { return util::current_time() > (creation_time + req_ttl); }
|
||||
|
||||
void Merge(const DNS_MappingPtr& other);
|
||||
void Merge(const DNS_MappingPtr& other);
|
||||
|
||||
static void InitializeCache(FILE* f);
|
||||
static bool ValidateCacheVersion(FILE* f);
|
||||
static void InitializeCache(FILE* f);
|
||||
static bool ValidateCacheVersion(FILE* f);
|
||||
|
||||
protected:
|
||||
friend class DNS_Mgr;
|
||||
friend class DNS_Mgr;
|
||||
|
||||
void Init(struct hostent* h);
|
||||
void Clear();
|
||||
void Init(struct hostent* h);
|
||||
void Clear();
|
||||
|
||||
std::string req_host;
|
||||
IPAddr req_addr;
|
||||
uint32_t req_ttl = 0;
|
||||
int req_type = 0;
|
||||
std::string req_host;
|
||||
IPAddr req_addr;
|
||||
uint32_t req_ttl = 0;
|
||||
int req_type = 0;
|
||||
|
||||
// This class supports multiple names per address, but we only store one of them.
|
||||
std::vector<std::string> names;
|
||||
StringValPtr host_val;
|
||||
// This class supports multiple names per address, but we only store one of them.
|
||||
std::vector<std::string> names;
|
||||
StringValPtr host_val;
|
||||
|
||||
std::vector<IPAddr> addrs;
|
||||
ListValPtr addrs_val;
|
||||
std::vector<IPAddr> addrs;
|
||||
ListValPtr addrs_val;
|
||||
|
||||
double creation_time = 0.0;
|
||||
bool no_mapping = false; // when initializing from a file, immediately hit EOF
|
||||
bool init_failed = false;
|
||||
bool failed = false;
|
||||
};
|
||||
double creation_time = 0.0;
|
||||
bool no_mapping = false; // when initializing from a file, immediately hit EOF
|
||||
bool init_failed = false;
|
||||
bool failed = false;
|
||||
};
|
||||
|
||||
} // namespace zeek::detail
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue