Commit c10df422 authored by Evan Hunt's avatar Evan Hunt
Browse files

better zoneset type


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@209 e5f2f494-b856-4b98-b285-d166d9295462
parent 4249f009
......@@ -28,6 +28,7 @@
#include <dns/message.h>
#include "common.h"
#include "zoneset.h"
using namespace std;
......@@ -38,28 +39,15 @@ using namespace isc::dns::Rdata::Generic;
const string PROGRAM = "parkinglot";
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;
static void
serve(string zone) {
zones.insert(zone);
}
static void
init_db() {
serve("jinmei.org");
serve("nuthaven.org");
serve("isc.org");
serve("sisotowbell.org");
serve("flame.org");
zones.serve("jinmei.org");
zones.serve("nuthaven.org");
zones.serve("isc.org");
zones.serve("sisotowbell.org");
zones.serve("flame.org");
}
static int
......@@ -113,7 +101,8 @@ run_server(int s) {
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);
RRset* nsset = new RRset(query->getName(), query->getClass(),
RRType::NS, TTL(3600));
......@@ -172,8 +161,10 @@ main(int argc, char* argv[])
}
}
if (err || (argc - optind) > 0)
usage();
if (err || (argc - optind) > 0) {
cerr << "Usage: parkinglot [-p port]" << endl;
exit(1);
}
// initialize DNS database
init_db();
......
// 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:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment