Pls discuss: Teeaction: send copy of query to second nameserver, sponge responses #3762

Merged
merged 6 commits into from Apr 26, 2016

Projects

None yet

2 participants

@ahupowerdns
Member

This adds a getStats() too all Actions which is currently empty, but could be exposed via the API so people could query it remotely. I think it makes sense like this but @rgacogne is closed in tune with the architecture of dnsdist post 1.0.0 I think. So please ponder before merging!

@rgacogne rgacogne commented on the diff Apr 25, 2016
pdns/dnsdistdist/dnsrulactions.cc
+ d_worker=std::thread(std::bind(&TeeAction::worker, this));
+}
+
+TeeAction::~TeeAction()
+{
+ d_pleaseQuit=true;
+ close(d_fd);
+ d_worker.join();
+}
+
+DNSAction::Action TeeAction::operator()(DNSQuestion* dq, string* ruleresult) const
+{
+ if(dq->tcp)
+ d_tcpdrops++;
+ else {
+ d_queries++;
@rgacogne
rgacogne Apr 25, 2016 Member

Given that this may be called from different threads, perhaps we might want to make d_tcpdrops and d_queries atomic

@rgacogne rgacogne commented on an outdated diff Apr 25, 2016
pdns/dnsdistdist/dnsrulactions.cc
+{
+ char packet[1500];
+ int res=0;
+ struct dnsheader* dh=(struct dnsheader*)packet;
+ for(;;) {
+ res=waitForData(d_fd, 0, 250000);
+ if(d_pleaseQuit)
+ break;
+ if(res < 0) {
+ usleep(250000);
+ continue;
+ }
+ if(res==0)
+ continue;
+ res=recv(d_fd, packet, sizeof(packet), 0);
+ if(res <= 0)
@rgacogne
rgacogne Apr 25, 2016 Member

< sizeof(struct dnsheader), otherwise we might be reading garbage below

@ahupowerdns ahupowerdns merged commit fb2e6a1 into PowerDNS:master Apr 26, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment