Commit Diff
Diff:
ed247332c5c765e1d37d2af2b08476d8db206fd3
864007e35886884e5c1f48e8f3f47652dd111654
Commit:
864007e35886884e5c1f48e8f3f47652dd111654 (tags/BETA_4)
Tree:
0de4cb74b63984c68ab75f3612cb8c22bb683ce7
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Tue Mar 9 15:48:35 2010 UTC
Message:
* part 2 of TTLPATCH merge There are going to be a few changes in how I do development. The next tag will be BETA_4 and that will be called stable under a branch called BETA_4STABLE. Here patches can be applied if W needs any. All this so that I can develop on HEAD which isn't guaranteed to be stable as in compiling or even running.
blob - e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
blob + 68f4744263bbf2cb738978748b36867814ef1037
--- example7.conf
+++ example7.conf
@@ -0,0 +1,153 @@
+; sample config file that is in production.
+;
+version "2";
+
+; this is for the host dione.centroid.eu which is in Panama
+; it serves best for the Americas and Australia (?)
+
+region "LACNIC" {
+ ;
+ ; ARIN and LACNIC blocks below
+ ;
+ ; lacnic netblocks
+ 186.0.0.0/8;
+ 187.0.0.0/8;
+ 189.0.0.0/8;
+ 190.0.0.0/8;
+ 191.0.0.0/8;
+ 200.0.0.0/8;
+ 201.0.0.0/8;
+ ; arin netblocks
+ 216.0.0.0/8;
+ 209.0.0.0/8;
+ 208.0.0.0/8;
+ 207.0.0.0/8;
+ 206.0.0.0/8;
+ 205.0.0.0/8;
+ 204.0.0.0/8;
+ 199.0.0.0/8;
+ 198.0.0.0/8;
+ 192.0.0.0/8;
+ 184.0.0.0/8;
+ 173.0.0.0/8;
+ 172.0.0.0/8;
+ 170.0.0.0/8;
+ 169.0.0.0/8;
+ 168.0.0.0/8;
+ 167.0.0.0/8;
+ 166.0.0.0/8;
+ 165.0.0.0/8;
+ 164.0.0.0/8;
+ 162.0.0.0/8;
+ 161.0.0.0/8;
+ 160.0.0.0/8;
+ 159.0.0.0/8;
+ 158.0.0.0/8;
+ 157.0.0.0/8;
+ 156.0.0.0/8;
+ 155.0.0.0/8;
+ 152.0.0.0/8;
+ 149.0.0.0/8;
+ 148.0.0.0/8;
+ 147.0.0.0/8;
+ 146.0.0.0/8;
+ 144.0.0.0/8;
+ 143.0.0.0/8;
+ 140.0.0.0/8;
+ 139.0.0.0/8;
+ 138.0.0.0/8;
+ 137.0.0.0/8;
+ 136.0.0.0/8;
+ 135.0.0.0/8;
+ 134.0.0.0/8;
+ 132.0.0.0/8;
+ 131.0.0.0/8;
+ 130.0.0.0/8;
+ 129.0.0.0/8;
+ 128.0.0.0/8;
+ 108.0.0.0/8;
+ 99.0.0.0/8;
+ 98.0.0.0/8;
+ 97.0.0.0/8;
+ 96.0.0.0/8;
+ 76.0.0.0/8;
+ 75.0.0.0/8;
+ 74.0.0.0/8;
+ 73.0.0.0/8;
+ 72.0.0.0/8;
+ 71.0.0.0/8;
+ 70.0.0.0/8;
+ 69.0.0.0/8;
+ 68.0.0.0/8;
+ 67.0.0.0/8;
+ 66.0.0.0/8;
+ 65.0.0.0/8;
+ 64.0.0.0/8;
+ 63.0.0.0/8;
+ 24.0.0.0/8;
+ 7.0.0.0/8;
+ ; Australia likes going through the US, LACNIC is closer
+ ; these two blocks are just some of many
+ 202.0.0.0/8;
+ 203.0.0.0/8;
+
+}
+;
+; This region is served by proteus.solarscale.de which resides in RIPE
+; it serves regions RIPE, AFRINIC and APNIC although the traceroutes
+; from China seem to indicate as much latency for proteus as there is
+; for dione
+;
+region "RIPE" {
+ ;
+ ; for RIPE we'll just put the prefix 0.0.0.0/0
+ ; this should work because the higher the prefix the more
+ ; precedence the region has, let's give it a shot.
+ ;
+
+ 0.0.0.0/0;
+ 192.168.0.0/16;
+ 147.102.0.0/16;
+}
+zone "centroid.eu" {
+ centroid.eu,soa,3600,uranus.centroid.eu.,pjp.solarscale.de.,1258740680,3600,1800,7200,3600
+ centroid.eu,ns,3600,proteus.solarscale.de.
+ centroid.eu,ns,3600,uranus.centroid.eu.
+ centroid.eu,ns,3600,dione.solarscale.de.
+ ; balance these two
+ centroid.eu,balance,3600,62.75.160.180
+ centroid.eu,balance,3600,200.46.208.61
+ ;
+ centroid.eu,mx,3600,10,proteus.solarscale.de.
+ centroid.eu,aaaa,3600,2001:a60:f074::8
+ ; and these two
+ www.centroid.eu,balance,3600,62.75.160.180
+ www.centroid.eu,balance,3600,200.46.208.61
+ ;
+ www.centroid.eu,aaaa,3600,2001:a60:f074::8
+ uranus.centroid.eu,a,3600,212.114.251.91
+ uranus.centroid.eu,aaaa,3600,2001:a60:f000:99::2
+ proteus.centroid.eu,a,3600,62.75.160.180
+ dione.centroid.eu,a,3600,200.46.208.61
+ rosalind.centroid.eu,aaaa,3600,2001:a60:f074::8
+ irc.centroid.eu,a,3600,212.114.251.91
+ irc.centroid.eu,aaaa,3600,2001:a60:f074::24
+ irc2.centroid.eu,a,3600,200.46.208.61
+ ipv6.centroid.eu,soa,3600,uranus.centroid.eu.,pjp.solarscale.de.,1244725285,3600,1800,7200,3600
+ ipv6.centroid.eu,aaaa,3600,2001:a60:f074::8
+ www.ipv6.centroid.eu,aaaa,3600,2001:a60:f074::8
+ localhost.centroid.eu,a,3600,127.0.0.1
+ localhost.centroid.eu,aaaa,3600,::1
+}
+zone "ipv6.solarscale.de" {
+ ipv6.solarscale.de,soa,3600,proteus.solarscale.de.,pjp.solarscale.de.,1234896563,3600,1800,7200,3600
+ ipv6.solarscale.de,ns,3600,proteus.solarscale.de.
+ ipv6.solarscale.de,ns,3600,uranus.centroid.eu.
+ ipv6.solarscale.de,aaaa,3600,2001:a60:f074::8
+ www.ipv6.solarscale.de,aaaa,3600,2001:a60:f074::8
+}
+zone "reverse dns" {
+ 0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,soa,3600,proteus.solarscale.de.,pjp.solarscale.de.,1234896562,3600,1800,7200,3600
+ 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,ptr,3600,uranus.centroid.eu.
+ 2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,ptr,3600,setebos.centroid.eu.
+}
blob - e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
blob + 387c4cf23356f6414d8ade534dd56550961e1e93
--- region.c
+++ region.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010 Peter J. Philipp
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include "include.h"
+#include "dns.h"
+#include "db.h"
+
+u_int8_t find_region(in_addr_t);
+void init_region(void);
+void insert_region(char *address, char *prefix, u_int8_t region);
+in_addr_t getmask(int prefix);
+
+SLIST_HEAD(listhead, entry) head;
+
+struct entry {
+ char name[INET_ADDRSTRLEN];
+ in_addr_t hostmask;
+ in_addr_t netmask;
+ u_int8_t region;
+ u_int8_t prefix;
+ SLIST_ENTRY(entry) entries;
+} *n1, *n2, *np;
+
+
+static const char rcsid[] = "$Id: region.c,v 1.3 2010/03/09 15:48:35 pbug Exp $";
+
+void
+init_region(void)
+{
+ SLIST_INIT(&head);
+ return;
+}
+
+void
+insert_region(char *address, char *prefix, u_int8_t region)
+{
+ int pnum;
+
+ pnum = atoi(prefix);
+
+ n2 = malloc(sizeof(struct entry)); /* Insert after. */
+
+ n2->hostmask = inet_addr(address);
+ n2->netmask = getmask(pnum);
+ n2->region = region;
+ n2->prefix = pnum;
+
+ SLIST_INSERT_HEAD(&head, n2, entries);
+}
+
+/*
+ * FIND_REGION - walk the region list and find the correponding network with
+ * the highest prefix, so that a /24 has more precedence than
+ * a /8 for example.
+ */
+
+u_int8_t
+find_region(in_addr_t address)
+{
+ u_int32_t hostmask, netmask;
+ u_int32_t a = address;
+ u_int8_t region = 0xff;
+ u_int8_t prefix = 0;
+
+ SLIST_FOREACH(np, &head, entries) {
+ hostmask = np->hostmask;
+ netmask = np->netmask;
+ if ((hostmask & netmask) == (a & netmask)) {
+ if (np->prefix >= prefix) {
+ region = np->region;
+ prefix = np->prefix;
+ }
+ } /* if hostmask */
+ } /* SLIST */
+
+ return (region);
+}
+
+in_addr_t
+getmask(int prefix)
+{
+ in_addr_t ret = 0xffffffff;
+
+ ret >>= prefix; /* 0x00ffffff */
+ ret = ~ret; /* 0xff000000 */
+
+ return (htonl(ret));
+}
repomaster@centroid.eu