acl/app/net_tools/dns/nslookup.h

96 lines
1.9 KiB
C
Raw Normal View History

#pragma once
2014-11-19 00:25:21 +08:00
//////////////////////////////////////////////////////////////////////////
class nslookup_callback
{
public:
nslookup_callback() {}
virtual ~nslookup_callback() {}
virtual void nslookup_report(size_t total, size_t curr) = 0;
virtual void nslookup_finish(const char* dbpath) = 0;
protected:
private:
};
//////////////////////////////////////////////////////////////////////////
class nslookup;
struct IP_INFO
{
char ip[64];
int ttl;
};
class domain_info
{
public:
domain_info(nslookup& ns, const char* domain);
~domain_info();
const char* get_domain() const
{
return domain_;
}
double get_spent() const;
void set_begin();
void set_end();
void add_ip(const char* ip, int ttl);
const std::vector<IP_INFO*>& get_ip_list() const
{
return ip_list_;
}
private:
// get_nslookup <20><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>Ա<EFBFBD> nslookup <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
friend class nslookup;
nslookup& get_nslookup() const
{
return ns_;
}
private:
nslookup& ns_;
char domain_[256];
struct timeval begin_;
struct timeval end_;
std::vector<IP_INFO*> ip_list_;
};
class nslookup : public acl::rpc_request
{
public:
nslookup(const char* filepath, nslookup_callback* callback,
const char* dns_ip, int dns_port, int timeout);
protected:
~nslookup();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
virtual void rpc_run();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ϣ
2014-11-19 00:25:21 +08:00
virtual void rpc_onover();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>̵߳<DFB3>֪ͨ<CDA8><D6AA>Ϣ
2014-11-19 00:25:21 +08:00
virtual void rpc_wakeup(void* ctx);
private:
acl::string filepath_;
nslookup_callback* callback_;
acl::string dns_ip_;
int dns_port_;
int timeout_;
std::vector<domain_info*>* domain_list_;
size_t nresult_; // <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ز<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
2014-11-19 00:25:21 +08:00
bool load_file();
void lookup_all();
2022-05-19 23:57:35 +08:00
static void dns_result(ACL_DNS_DB *dns_db, void *ctx, int errnum,
const ACL_RFC1035_MESSAGE*);
2014-11-19 00:25:21 +08:00
};