#include <bitset>
#include "dnsparser.hh"
#include "iputils.hh"
-#undef L
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <sys/stat.h>
#include <fcntl.h>
#include <grp.h>
+#include <unistd.h>
#include "dnsrecords.hh"
#include "mplexer.hh"
#include "statbag.hh"
StatBag S;
-SelectFDMultiplexer g_fdm;
+FDMultiplexer* g_fdm;
int g_pdnssocket;
bool g_verbose;
{
char buffer[1500];
struct NotificationInFlight nif;
+ /* make sure we report enough room for IPv6 */
+ nif.source.sin4.sin_family = AF_INET6;
nif.origSocket = fd;
- socklen_t socklen=sizeof(nif.source);
+ socklen_t socklen=nif.source.getSocklen();
int res=recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&nif.source, &socklen);
if(!res)
if(res < 0)
throw runtime_error("reading packet from remote: "+stringerror());
- string packet(buffer, res);
- MOADNSParser mdp(true, packet);
+ MOADNSParser mdp(true, string(buffer,res));
nif.domain = mdp.d_qname;
nif.origID = mdp.d_header.id;
{
char buffer[1500];
struct NotificationInFlight nif;
+ /* make sure we report enough room for IPv6 */
+ nif.source.sin4.sin_family = AF_INET6;
- socklen_t socklen=sizeof(nif.source);
+ socklen_t socklen=nif.source.getSocklen();
int len=recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&nif.source, &socklen);
if(!len)
reportAllTypes();
openlog("nproxy", LOG_NDELAY | LOG_PID, LOG_DAEMON);
+ g_fdm = FDMultiplexer::getMultiplexerSilent();
+ if(!g_fdm) {
+ throw std::runtime_error("Could not enable a multiplexer");
+ }
+
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
if(::bind(sock,(sockaddr*) &local, local.getSocklen()) < 0)
throw runtime_error("Binding socket for incoming packets to '"+ local.toStringWithPort()+"': "+stringerror());
- g_fdm.addReadFD(sock, handleOutsideUDPPacket); // add to fdmultiplexer for each socket
+ g_fdm->addReadFD(sock, handleOutsideUDPPacket); // add to fdmultiplexer for each socket
syslogFmt(boost::format("Listening for external notifications on address %s") % local.toStringWithPort());
}
syslogFmt(boost::format("Sending notifications from %s to internal address %s") % originAddress.toString() % pdns.toStringWithPort());
- g_fdm.addReadFD(g_pdnssocket, handleInsideUDPPacket);
+ g_fdm->addReadFD(g_pdnssocket, handleInsideUDPPacket);
int null_fd=open("/dev/null",O_RDWR); /* open stdin */
if(null_fd < 0)
struct timeval now;
for(;;) {
gettimeofday(&now, 0);
- g_fdm.run(&now);
+ g_fdm->run(&now);
// check for notifications that have been outstanding for more than 10 seconds
expireOldNotifications();
}