Created
October 8, 2018 22:25
-
-
Save jsoref/b84e9863616486c0f82834bb98e53457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
// this is a complicated definition that I haven't finished parsing | |
typedef std::function< | |
int( | |
const ComboAddress& ip, | |
const DNSName& qdomain, | |
int qtype, | |
bool doTCP, | |
bool sendRDQuery, | |
int EDNS0Level, | |
struct timeval* now, | |
boost::optional<Netmask>& srcmask, | |
boost::optional<const ResolveContext&> context, | |
std::shared_ptr<RemoteLogger> outgoingLogger, | |
LWResult *lwr, | |
bool* chained | |
) | |
> asyncresolve_t; | |
// at the end of the day, this defines a function type called asyncresolve_t | |
// basic member setter takes that type and stores it | |
void setAsyncCallback(asyncresolve_t func) | |
{ | |
d_asyncResolve = func; | |
} | |
// basic class member defines an instance pointer to the function type, initially pointing to a null pointer | |
asyncresolve_t d_asyncResolve{nullptr}; | |
// function that calls the interesting function | |
int asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* n | |
ow, boost::optional<Netmask>& srcmask, LWResult* res, bool* chained) const; | |
} | |
int SyncRes::asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* n | |
ow, boost::optional<Netmask>& srcmask, LWResult* res, bool* chained) const | |
{ | |
// null check | |
if (d_asyncResolve) { | |
// simple function call | |
ret = d_asyncResolve(ip, sendQname, type, doTCP, sendRDQuery, EDNSLevel, now, srcmask, ctx, luaconfsLocal->outgoingProtobufServer, res, chained); | |
} | |
} | |
BOOST_AUTO_TEST_CASE(test_cname_nxdomain) { | |
std::unique_ptr<SyncRes> sr; | |
initSR(sr); | |
primeHints(); | |
const DNSName target("cname.powerdns.com."); | |
const DNSName cnameTarget("cname-target.powerdns.com"); | |
sr->setAsyncCallback( | |
[target, cnameTarget /* I really can't parse this array notation */] | |
( | |
const ComboAddress& ip, | |
const DNSName& domain, | |
int type, | |
bool doTCP, | |
bool sendRDQuery, | |
int EDNS0Level, | |
struct timeval* now, | |
boost::optional<Netmask>& srcmask, | |
boost::optional<const ResolveContext&> context, | |
std::shared_ptr<RemoteLogger> outgoingLogger, | |
LWResult* res, | |
bool* chained | |
) { | |
/* lambda implementation of a function that we assue to be compatible with asyncresolve_t */ | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment