mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Removing the --disable-nbdns config option.
- Asynchronous DNS resolver support assumed by default - HAVE_ASYNC_DNS, HAVE_NB_DNS, and USE_NB_DNS preprocessor definitions removed - In the process, I added FindBIND and CheckNameserCompat CMake modules
This commit is contained in:
parent
13569aaab7
commit
570ee48cd9
11 changed files with 111 additions and 86 deletions
|
@ -189,9 +189,7 @@ endforeach(binpact)
|
|||
|
||||
########### next target ###############
|
||||
|
||||
if (HAVE_NB_DNS)
|
||||
set(dns_SRCS nb_dns.c nb_dns.h)
|
||||
endif ()
|
||||
set(dns_SRCS nb_dns.c nb_dns.h)
|
||||
|
||||
set(openssl_SRCS X509.cc SSLCiphers.cc SSLInterpreter.cc SSLProxy.cc
|
||||
SSLv2.cc SSLv3.cc SSLv3Automaton.cc)
|
||||
|
@ -382,10 +380,10 @@ add_dependencies(bro make_dbg_constants)
|
|||
|
||||
target_link_libraries(bro
|
||||
m
|
||||
resolv
|
||||
binpac_lib
|
||||
${PCAP_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${BIND_LIBRARY}
|
||||
)
|
||||
|
||||
install(TARGETS bro DESTINATION bin)
|
||||
|
|
|
@ -53,9 +53,7 @@ public:
|
|||
const char* ReqHost() const { return host; }
|
||||
uint32 ReqAddr() const { return addr; }
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
int MakeRequest(nb_dns_info* nb_dns);
|
||||
#endif
|
||||
int RequestPending() const { return request_pending; }
|
||||
void RequestDone() { request_pending = 0; }
|
||||
|
||||
|
@ -66,7 +64,6 @@ protected:
|
|||
int request_pending;
|
||||
};
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
int DNS_Mgr_Request::MakeRequest(nb_dns_info* nb_dns)
|
||||
{
|
||||
if ( ! nb_dns )
|
||||
|
@ -80,7 +77,6 @@ int DNS_Mgr_Request::MakeRequest(nb_dns_info* nb_dns)
|
|||
else
|
||||
return nb_dns_addr_request(nb_dns, addr, (void*) this, err) >= 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
class DNS_Mapping {
|
||||
public:
|
||||
|
@ -350,13 +346,11 @@ DNS_Mgr::DNS_Mgr(DNS_MgrMode arg_mode)
|
|||
host_mappings.SetDeleteFunc(DNS_Mgr_mapping_delete_func);
|
||||
addr_mappings.SetDeleteFunc(DNS_Mgr_mapping_delete_func);
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
char err[NB_DNS_ERRSIZE];
|
||||
nb_dns = nb_dns_init(err);
|
||||
|
||||
if ( ! nb_dns )
|
||||
warn(fmt("problem initializing NB-DNS: %s", err));
|
||||
#endif
|
||||
|
||||
dns_mapping_valid = dns_mapping_unverified = dns_mapping_new_name =
|
||||
dns_mapping_lost_name = dns_mapping_name_changed =
|
||||
|
@ -372,10 +366,8 @@ DNS_Mgr::DNS_Mgr(DNS_MgrMode arg_mode)
|
|||
|
||||
DNS_Mgr::~DNS_Mgr()
|
||||
{
|
||||
#ifdef HAVE_NB_DNS
|
||||
if ( nb_dns )
|
||||
nb_dns_finish(nb_dns);
|
||||
#endif
|
||||
|
||||
delete [] cache_name;
|
||||
delete [] dir;
|
||||
|
@ -410,14 +402,12 @@ bool DNS_Mgr::Init()
|
|||
|
||||
did_init = 1;
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
io_sources.Register(this, true);
|
||||
|
||||
// We never set idle to false, having the main loop only calling us from
|
||||
// time to time. If we're issuing more DNS requests than we can handle
|
||||
// in this way, we are having problems anyway ...
|
||||
idle = true;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -531,7 +521,6 @@ void DNS_Mgr::Resolve()
|
|||
|
||||
int i;
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
int first_req = 0;
|
||||
int num_pending = min(requests.length(), MAX_PENDING_REQUESTS);
|
||||
int last_req = num_pending - 1;
|
||||
|
@ -597,7 +586,6 @@ void DNS_Mgr::Resolve()
|
|||
--num_pending;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// All done with the list of requests.
|
||||
for ( i = requests.length() - 1; i >= 0; --i )
|
||||
|
@ -860,7 +848,6 @@ TableVal* DNS_Mgr::LookupNameInCache(string name)
|
|||
return d->AddrsSet();
|
||||
}
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
void DNS_Mgr::AsyncLookupAddr(dns_mgr_addr_type host, LookupCallback* callback)
|
||||
{
|
||||
if ( ! did_init )
|
||||
|
@ -956,13 +943,10 @@ void DNS_Mgr::IssueAsyncRequests()
|
|||
++asyncs_pending;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DNS_Mgr::GetFds(int* read, int* write, int* except)
|
||||
{
|
||||
#ifdef HAVE_NB_DNS
|
||||
*read = nb_dns_fd(nb_dns);
|
||||
#endif
|
||||
}
|
||||
|
||||
double DNS_Mgr::NextTimestamp(double* network_time)
|
||||
|
@ -971,7 +955,6 @@ double DNS_Mgr::NextTimestamp(double* network_time)
|
|||
return asyncs_timeouts.size() ? timer_mgr->Time() : -1.0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
void DNS_Mgr::CheckAsyncAddrRequest(dns_mgr_addr_type addr, bool timeout)
|
||||
{
|
||||
// Note that this code is a mirror of that for CheckAsyncHostRequest.
|
||||
|
@ -1030,13 +1013,9 @@ void DNS_Mgr::CheckAsyncHostRequest(const char* host, bool timeout)
|
|||
// eventually times out.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DNS_Mgr::Process()
|
||||
{
|
||||
#ifndef HAVE_NB_DNS
|
||||
internal_error("DNS_Mgr::Process(): should never be reached");
|
||||
#else
|
||||
|
||||
while ( asyncs_timeouts.size() > 0 )
|
||||
{
|
||||
|
@ -1084,9 +1063,8 @@ void DNS_Mgr::Process()
|
|||
|
||||
IssueAsyncRequests();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_NB_DNS
|
||||
|
||||
int DNS_Mgr::AnswerAvailable(int timeout)
|
||||
{
|
||||
int fd = nb_dns_fd(nb_dns);
|
||||
|
@ -1116,4 +1094,3 @@ int DNS_Mgr::AnswerAvailable(int timeout)
|
|||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -79,10 +79,8 @@ public:
|
|||
virtual void Timeout() = 0;
|
||||
};
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
void AsyncLookupAddr(dns_mgr_addr_type host, LookupCallback* callback);
|
||||
void AsyncLookupName(string name, LookupCallback* callback);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
friend class LookupCallback;
|
||||
|
@ -102,7 +100,6 @@ protected:
|
|||
void LoadCache(FILE* f);
|
||||
void Save(FILE* f, PDict(DNS_Mapping)& m);
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
// Selects on the fd to see if there is an answer available (timeout is
|
||||
// secs). Returns 0 on timeout, -1 on EINTR, and 1 if answer is ready.
|
||||
int AnswerAvailable(int timeout);
|
||||
|
@ -115,8 +112,6 @@ protected:
|
|||
void CheckAsyncAddrRequest(dns_mgr_addr_type addr, bool timeout);
|
||||
void CheckAsyncHostRequest(const char* host, bool timeout);
|
||||
|
||||
#endif
|
||||
|
||||
// IOSource interface.
|
||||
virtual void GetFds(int* read, int* write, int* except);
|
||||
virtual double NextTimestamp(double* network_time);
|
||||
|
|
10
src/bro.bif
10
src/bro.bif
|
@ -2808,10 +2808,6 @@ private:
|
|||
# function result. Therefore, they can only be called inside a when-condition.
|
||||
function lookup_addr%(host: addr%) : string
|
||||
%{
|
||||
#ifndef HAVE_NB_DNS
|
||||
run_time("lookup_addr(): not configured for asynchronous DNS lookups");
|
||||
return new StringVal("<error>");
|
||||
#else
|
||||
// FIXME: Is should be easy to adapt the function to synchronous
|
||||
// lookups if we're reading a trace.
|
||||
Trigger* trigger = frame->GetTrigger();
|
||||
|
@ -2839,15 +2835,10 @@ function lookup_addr%(host: addr%) : string
|
|||
new LookupHostCallback(trigger, frame->GetCall(), true));
|
||||
#endif
|
||||
return 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
function lookup_hostname%(host: string%) : addr_set
|
||||
%{
|
||||
#ifndef HAVE_NB_DNS
|
||||
run_time("lookup_hostname(): not configured for asynchronous DNS lookups");
|
||||
return new StringVal("<error>");
|
||||
#else
|
||||
// FIXME: Is should be easy to adapt the function to synchronous
|
||||
// lookups if we're reading a trace.
|
||||
Trigger* trigger = frame->GetTrigger();
|
||||
|
@ -2864,7 +2855,6 @@ function lookup_hostname%(host: string%) : addr_set
|
|||
dns_mgr->AsyncLookupName(host->CheckString(),
|
||||
new LookupHostCallback(trigger, frame->GetCall(), false));
|
||||
return 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
# Stop Bro's packet processing.
|
||||
|
|
|
@ -406,11 +406,7 @@ int main(int argc, char** argv)
|
|||
|
||||
enum DNS_MgrMode dns_type = DNS_DEFAULT;
|
||||
|
||||
#ifdef HAVE_NB_DNS
|
||||
dns_type = getenv("BRO_DNS_FAKE") ? DNS_FAKE : DNS_DEFAULT;
|
||||
#else
|
||||
dns_type = DNS_FAKE;
|
||||
#endif
|
||||
|
||||
RETSIGTYPE (*oldhandler)(int);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue