summaryrefslogtreecommitdiffstats
path: root/main/gdnsd
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-08-21 17:06:45 +0300
committerTimo Teräs <timo.teras@iki.fi>2012-08-21 17:06:45 +0300
commitdb3867df2088ca37bed812d9747d337543c6a8b6 (patch)
tree14e1ab3a778fcc7aa17b9981d8d73bb1f1885493 /main/gdnsd
parenteb49991efc0cabf0075b7dc85405c4ed858c29aa (diff)
downloadaports-db3867df2088ca37bed812d9747d337543c6a8b6.tar.bz2
aports-db3867df2088ca37bed812d9747d337543c6a8b6.tar.xz
main/gdnsd: refresh autodc patch
Diffstat (limited to 'main/gdnsd')
-rw-r--r--main/gdnsd/APKBUILD4
-rw-r--r--main/gdnsd/geoip-autodc.patch192
2 files changed, 181 insertions, 15 deletions
diff --git a/main/gdnsd/APKBUILD b/main/gdnsd/APKBUILD
index 8cd799f4c..cba1c3859 100644
--- a/main/gdnsd/APKBUILD
+++ b/main/gdnsd/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=gdnsd
pkgver=1.6.8
-pkgrel=0
+pkgrel=1
pkgdesc="Geographic Authoritative DNS server"
url="https://github.com/blblack/gdnsd/"
arch="all"
@@ -50,7 +50,7 @@ package() {
}
md5sums="6271506577e6b4fd7bcd36a8bf434e6a gdnsd-1.6.8.tar.xz
-7955bf52d394862512ae6c000c8b6242 geoip-autodc.patch
+02eb668b6cad54552568a35985f44a09 geoip-autodc.patch
7fb697653b8295322e53492f9051e831 geoip-speedup.patch
4c8ff14e377fb8f1854b68b7bf9be282 0001-preliminary-djbdns-support.patch
00f2838e0908effaaa2f6e6a1699f25b gdnsd.initd"
diff --git a/main/gdnsd/geoip-autodc.patch b/main/gdnsd/geoip-autodc.patch
index ec88491a1..ae313ef38 100644
--- a/main/gdnsd/geoip-autodc.patch
+++ b/main/gdnsd/geoip-autodc.patch
@@ -1,25 +1,64 @@
-From: Timo TerÃs <timo.teras@iki.fi>
+From 8f172f642d4aa3a30f5a356a4611f66227e74681 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Tue, 21 Aug 2012 16:45:45 +0300
+Subject: [PATCH] plugin_geoip: allow datacenters to be omitted from
+ auto_dc_coords
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
-plugin_geoip: allow datacenters to be omitted from auto_dc_coords
-
-sometimes we might need a datacenter to be accessible only via
-overrides of map (via specific territory) or via nets (only
-specific nets). this makes those datacenters to be sorted always
-last.
+Those datacenters will be never returned automatically. They are
+available only from specific territories (map overrides) or subnets
+(net overrides).
-http://code.google.com/p/gdnsd/issues/detail?id=17
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ plugins/meta/libgdmaps/gdmaps.c | 46 +++++++++++++++-----------
+ plugins/meta/libgdmaps/t/Makefile.am | 3 +-
+ plugins/meta/libgdmaps/t/t14_missingcoords.c | 42 +++++++++++++++++++++++
+ plugins/meta/libgdmaps/t/t14_missingcoords.cfg | 29 ++++++++++++++++
+ 4 files changed, 100 insertions(+), 20 deletions(-)
+ create mode 100644 plugins/meta/libgdmaps/t/t14_missingcoords.c
+ create mode 100644 plugins/meta/libgdmaps/t/t14_missingcoords.cfg
diff --git a/plugins/meta/libgdmaps/gdmaps.c b/plugins/meta/libgdmaps/gdmaps.c
-index b49bfa5..9d20351 100644
+index be23d9b..b367e6f 100644
--- a/plugins/meta/libgdmaps/gdmaps.c
+++ b/plugins/meta/libgdmaps/gdmaps.c
-@@ -180,13 +180,13 @@ static dcinfo_t* dcinfo_new(const vscf_data_t* dc_cfg, const vscf_data_t* dc_aut
+@@ -148,6 +148,7 @@ static dcinfo_t* dcinfo_new(const vscf_data_t* dc_cfg, const vscf_data_t* dc_aut
+ dcinfo_t* info = malloc(sizeof(dcinfo_t));
+
+ const unsigned num_dcs = vscf_array_get_len(dc_cfg);
++ unsigned num_auto = 0;
+ if(!num_dcs)
+ log_fatal("plugin_geoip: map '%s': 'datacenters' must be an array of one or more strings", map_name);
+ if(num_dcs > 254)
+@@ -164,34 +165,26 @@ static dcinfo_t* dcinfo_new(const vscf_data_t* dc_cfg, const vscf_data_t* dc_aut
+ log_fatal("plugin_geoip: map '%s': datacenter name 'auto' is illegal", map_name);
+ }
+
+- if(dc_auto_limit_cfg) {
+- unsigned long auto_limit_ul;
+- if(!vscf_is_simple(dc_auto_limit_cfg) || !vscf_simple_get_as_ulong(dc_auto_limit_cfg, &auto_limit_ul))
+- log_fatal("plugin_geoip: map '%s': auto_dc_limit must be a single unsigned integer value", map_name);
+- if(auto_limit_ul > num_dcs || !auto_limit_ul)
+- auto_limit_ul = num_dcs;
+- info->auto_limit = auto_limit_ul;
+- }
+- else {
+- info->auto_limit = (num_dcs > 3) ? 3 : num_dcs;
+- }
+-
+ if(dc_auto_cfg) {
if(!vscf_is_hash(dc_auto_cfg))
log_fatal("plugin_geoip: map '%s': auto_dc_coords must be a key-value hash", map_name);
- const unsigned num_auto = vscf_hash_get_len(dc_auto_cfg);
+- const unsigned num_auto = vscf_hash_get_len(dc_auto_cfg);
- if(num_auto != num_dcs)
- log_fatal("plugin_geoip: map '%s': auto_dc_coords hash must contain one entry for each datacenter in 'datacenters'", map_name);
- info->coords = malloc(num_auto * 2 * sizeof(double));
++ num_auto = vscf_hash_get_len(dc_auto_cfg);
++ if (info->auto_limit > num_auto)
++ info->auto_limit = num_auto;
+ info->coords = malloc(num_dcs * 2 * sizeof(double));
+ for(unsigned i = 0; i < 2*num_dcs; i++)
+ info->coords[i] = NAN;
@@ -31,15 +70,142 @@ index b49bfa5..9d20351 100644
if(!strcmp(dcname, info->names[dcidx]))
break;
}
-@@ -438,7 +438,10 @@ static unsigned dclists_city_auto_map(dclists_t* lists, const char* map_name, co
+- if(dcidx == info->num_dcs)
++ if(dcidx == num_dcs)
+ log_fatal("plugin_geoip: map '%s': auto_dc_coords key '%s' not matched from 'datacenters' list", map_name, dcname);
++ if(!isnan(info->coords[(dcidx*2)]))
++ log_fatal("plugin_geoip: map '%s': auto_dc_coords key '%s' defined twice", map_name, dcname);
+ const vscf_data_t* coord_cfg = vscf_hash_get_data_byindex(dc_auto_cfg, i);
+ const vscf_data_t* lat_cfg;
+ const vscf_data_t* lon_cfg;
+@@ -216,6 +209,18 @@ static dcinfo_t* dcinfo_new(const vscf_data_t* dc_cfg, const vscf_data_t* dc_aut
+ info->coords = NULL;
+ }
+
++ if(dc_auto_limit_cfg) {
++ unsigned long auto_limit_ul;
++ if(!vscf_is_simple(dc_auto_limit_cfg) || !vscf_simple_get_as_ulong(dc_auto_limit_cfg, &auto_limit_ul))
++ log_fatal("plugin_geoip: map '%s': auto_dc_limit must be a single unsigned integer value", map_name);
++ if(auto_limit_ul > num_auto || !auto_limit_ul)
++ auto_limit_ul = num_auto;
++ info->auto_limit = auto_limit_ul;
++ }
++ else {
++ info->auto_limit = (num_auto > 3) ? 3 : num_auto;
++ }
++
+ return info;
+ }
+
+@@ -438,7 +443,10 @@ static unsigned dclists_city_auto_map(dclists_t* lists, const char* map_name, co
double dists[store_len];
for(unsigned i = 0; i < num_dcs; i++) {
const unsigned c_offs = i * 2;
- dists[i + 1] = haversine(lat_rad, lon_rad, coords[c_offs], coords[c_offs + 1]);
-+ if (coords[c_offs] != NAN)
++ if (!isnan(coords[c_offs]))
+ dists[i + 1] = haversine(lat_rad, lon_rad, coords[c_offs], coords[c_offs + 1]);
+ else
+ dists[i + 1] = +INFINITY;
}
// Given the relatively small num_dcs of most configs,
+diff --git a/plugins/meta/libgdmaps/t/Makefile.am b/plugins/meta/libgdmaps/t/Makefile.am
+index f83592f..e9d26ce 100644
+--- a/plugins/meta/libgdmaps/t/Makefile.am
++++ b/plugins/meta/libgdmaps/t/Makefile.am
+@@ -41,7 +41,8 @@ TESTLIST = \
+ t10_def \
+ t11_def2 \
+ t12_defnone \
+- t13_castatdef
++ t13_castatdef \
++ t14_missingcoords
+
+ check_PROGRAMS = $(TESTLIST:=.bin)
+
+diff --git a/plugins/meta/libgdmaps/t/t14_missingcoords.c b/plugins/meta/libgdmaps/t/t14_missingcoords.c
+new file mode 100644
+index 0000000..9329ee3
+--- /dev/null
++++ b/plugins/meta/libgdmaps/t/t14_missingcoords.c
+@@ -0,0 +1,42 @@
++/* Copyright © 2012 Brandon L Black <blblack@gmail.com>
++ *
++ * This file is part of gdnsd-plugin-geoip.
++ *
++ * gdnsd-plugin-geoip is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation, either version 3 of the License, or
++ * (at your option) any later version.
++ *
++ * gdnsd-plugin-geoip is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with gdnsd. If not, see <http://www.gnu.org/licenses/>.
++ *
++ */
++
++// Unit test for gdmaps
++
++#include "config.h"
++#include <gdnsd-log.h>
++#include "gdmaps_test.h"
++
++int main(int argc, char* argv[]) {
++ if(argc != 2)
++ log_fatal("root directory must be set on commandline");
++
++ gdmaps_t* gdmaps = gdmaps_test_init(argv[1]);
++ unsigned tnum = 0;
++ //datacenters => [ us, ie, sg, tr, br ]
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "137.138.144.168", "\2\1\5\3", 16); // Geneva
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "69.58.186.119", "\1\2\5\3", 16); // US East Coast
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "117.53.170.202", "\3\5\1\2", 20); // Australia
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "133.11.114.194", "\2\4", 8); // JP, horrible custom 'map' entry
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "10.0.0.44", "\4\2", 24); // Custom 'nets' entry
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "10.0.1.44", "", 24); // Custom 'nets' entry, empty
++ gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "192.168.1.1", "\1\2\3\4\5", 16); // meta-default, no loc
++ gdmaps_destroy(gdmaps);
++}
++
+diff --git a/plugins/meta/libgdmaps/t/t14_missingcoords.cfg b/plugins/meta/libgdmaps/t/t14_missingcoords.cfg
+new file mode 100644
+index 0000000..8c57cdd
+--- /dev/null
++++ b/plugins/meta/libgdmaps/t/t14_missingcoords.cfg
+@@ -0,0 +1,29 @@
++options => { debug => true }
++plugins => {
++ geoip => {
++ maps => {
++ # bringing it all together: city-auto w/ 5 dcs,
++ # dual GeoIP inputs, custom maps, custom nets
++ # testing with one datacenter not used in auto coords
++ my_prod_map => {
++ geoip_db => GeoLiteCityv6-20111210.dat,
++ geoip_db_v4_overlay => GeoLiteCity-20111210.dat,
++ datacenters => [ us, ie, sg, tr, br ]
++ auto_dc_limit => 5,
++ auto_dc_coords => {
++ us = [ 38.9, -77 ]
++ ie = [ 53.3, -6.3 ]
++ sg = [ 1.3, 103.9 ]
++ br = [ -22.9, -43.2 ]
++ }
++ map => {
++ AS => { JP => [ ie, tr ] }
++ }
++ nets => {
++ 10.0.1.0/24 => [ ]
++ 10.0.0.0/24 => [ tr, ie ]
++ }
++ }
++ }
++ }
++}
+--
+1.7.12
+