mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 23:15:20 +00:00
better zoneset type
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@209 e5f2f494-b856-4b98-b285-d166d9295462
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include <dns/message.h>
|
#include <dns/message.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "zoneset.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -38,28 +39,15 @@ using namespace isc::dns::Rdata::Generic;
|
|||||||
const string PROGRAM = "parkinglot";
|
const string PROGRAM = "parkinglot";
|
||||||
const int DNSPORT = 53;
|
const int DNSPORT = 53;
|
||||||
|
|
||||||
static void
|
|
||||||
usage() {
|
|
||||||
cerr << "Usage: parkinglot [-p port]" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef pair<string, void*> Record;
|
|
||||||
typedef set<string> ZoneSet;
|
|
||||||
ZoneSet zones;
|
ZoneSet zones;
|
||||||
|
|
||||||
static void
|
|
||||||
serve(string zone) {
|
|
||||||
zones.insert(zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_db() {
|
init_db() {
|
||||||
serve("jinmei.org");
|
zones.serve("jinmei.org");
|
||||||
serve("nuthaven.org");
|
zones.serve("nuthaven.org");
|
||||||
serve("isc.org");
|
zones.serve("isc.org");
|
||||||
serve("sisotowbell.org");
|
zones.serve("sisotowbell.org");
|
||||||
serve("flame.org");
|
zones.serve("flame.org");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -113,7 +101,8 @@ run_server(int s) {
|
|||||||
|
|
||||||
RRsetPtr query = msg.getSection(SECTION_QUESTION)[0];
|
RRsetPtr query = msg.getSection(SECTION_QUESTION)[0];
|
||||||
|
|
||||||
if (zones.find(query->getName().toText(true)) != zones.end()) {
|
string name = query->getName().toText(true);
|
||||||
|
if (zones.contains(name)) {
|
||||||
msg.setRcode(Message::RCODE_NOERROR);
|
msg.setRcode(Message::RCODE_NOERROR);
|
||||||
RRset* nsset = new RRset(query->getName(), query->getClass(),
|
RRset* nsset = new RRset(query->getName(), query->getClass(),
|
||||||
RRType::NS, TTL(3600));
|
RRType::NS, TTL(3600));
|
||||||
@@ -172,8 +161,10 @@ main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err || (argc - optind) > 0)
|
if (err || (argc - optind) > 0) {
|
||||||
usage();
|
cerr << "Usage: parkinglot [-p port]" << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// initialize DNS database
|
// initialize DNS database
|
||||||
init_db();
|
init_db();
|
||||||
|
32
src/bin/parkinglot/zoneset.h
Normal file
32
src/bin/parkinglot/zoneset.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
#ifndef __ZONELIST_H
|
||||||
|
#define __ZONELIST_H 1
|
||||||
|
|
||||||
|
class ZoneSet : std::set<std::string> {
|
||||||
|
public:
|
||||||
|
void serve(std::string s) { this->insert(s); }
|
||||||
|
bool contains(std::string s) {
|
||||||
|
return (this->find(s) != this->end());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __ZONELIST_H
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: c++
|
||||||
|
// End:
|
Reference in New Issue
Block a user