#define KEEP_DEFAULT 20
uint16_t g_keep = KEEP_DEFAULT;
+NetmaskGroup g_acl;
+
void handleSignal(int signum) {
if (g_verbose) {
cerr<<"[INFO] Got "<<strsignal(signum)<<" signal";
return true;
}
+bool allowedByACL(const ComboAddress& addr) {
+ return g_acl.match(addr);
+}
+
void handleUDPRequest(int fd, boost::any&) {
// TODO make the buffer-size configurable
char buf[4096];
return;
}
+ if (!allowedByACL(saddr)) {
+ cerr<<"[WARNING] UDP query from "<<saddr.toString()<<" is not allowed, dropping"<<endl;
+ return;
+ }
+
if (saddr == ComboAddress("0.0.0.0", 0)) {
cerr<<"[WARNING] Could not determine source of message"<<endl;
return;
return;
}
+ if (!allowedByACL(saddr)) {
+ cerr<<"[WARNING] TCP query from "<<saddr.toString()<<" is not allowed, dropping"<<endl;
+ close(cfd);
+ return;
+ }
+
if (saddr == ComboAddress("0.0.0.0", 0)) {
cerr<<"[WARNING] Could not determine source of message"<<endl;
return;
("verbose", "Be verbose")
("debug", "Be even more verbose")
("listen-address", po::value< vector< string>>(), "IP Address(es) to listen on")
+ ("acl", po::value<vector<string>>(), "IP Address masks that are allowed access, by default only loopback addresses are allowed")
("server-address", po::value<string>()->default_value("127.0.0.1:5300"), "server address")
("work-dir", po::value<string>()->default_value("."), "Directory for storing AXFR and IXFR data")
("keep", po::value<uint16_t>()->default_value(KEEP_DEFAULT), "Number of old zone versions to retain")
return EXIT_FAILURE;
}
+ vector<string> acl = {"127.0.0.0/8", "::1/128"};
+ if (g_vm.count("acl") > 0) {
+ acl = g_vm["acl"].as<vector<string>>();
+ }
+ for (const auto &addr : acl) {
+ try {
+ g_acl.addMask(addr);
+ } catch (const NetmaskException &e) {
+ cerr<<"[ERROR] "<<e.reason<<endl;
+ had_error = true;
+ }
+ }
+ if (g_verbose) {
+ cerr<<"[INFO] ACL set to "<<g_acl.toString()<<"."<<endl;
+ }
+
set<int> allSockets;
for (const auto& addr : listen_addresses) {
for (const auto& stype : {SOCK_DGRAM, SOCK_STREAM}) {