net-dns/dnsdist: New package, #611892
authorbgo <bgo@9dt.de>
Tue, 23 May 2017 21:44:31 +0000 (23:44 +0200)
committerMichał Górny <mgorny@gentoo.org>
Tue, 23 May 2017 22:16:54 +0000 (00:16 +0200)
Closes: https://github.com/gentoo/gentoo/pull/4606

net-dns/dnsdist/Manifest [new file with mode: 0644]
net-dns/dnsdist/dnsdist-1.1.0.ebuild [new file with mode: 0644]
net-dns/dnsdist/dnsdist-9999.ebuild [new file with mode: 0644]
net-dns/dnsdist/files/dnsdist-readline.patch [new file with mode: 0644]
net-dns/dnsdist/files/dnsdist.conf.example [new file with mode: 0644]
net-dns/dnsdist/files/dnsdist.confd [new file with mode: 0644]
net-dns/dnsdist/files/dnsdist.initd [new file with mode: 0644]
net-dns/dnsdist/metadata.xml [new file with mode: 0644]

diff --git a/net-dns/dnsdist/Manifest b/net-dns/dnsdist/Manifest
new file mode 100644 (file)
index 0000000..83b82a3
--- /dev/null
@@ -0,0 +1 @@
+DIST dnsdist-1.1.0.tar.bz2 874837 SHA256 b4a1e8931b6d05a24494f54224211c0de0eeb1f5ff170f6b9f5665219bfeafc2 SHA512 91da716997c2440e153944f510a39dd86c9cf8ba8093a7f51a9a5d58ab0a1c230bd99ec57fe8ff0721279c8c4429ad576fe797c1fbe4cde2b9fb8f0405025320 WHIRLPOOL 6d88f4159b8155c9600af94e6e8401c426f183102a18b3f35fc066b8a19d781f5800a2aa64d306ab4ee0daadbaaab1d29b2df05c10058a9b99b9d9cf1abf071e
diff --git a/net-dns/dnsdist/dnsdist-1.1.0.ebuild b/net-dns/dnsdist/dnsdist-1.1.0.ebuild
new file mode 100644 (file)
index 0000000..4b02515
--- /dev/null
@@ -0,0 +1,99 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://github.com/PowerDNS/pdns.git"
+
+if [[ ${PV} = 9999 ]]; then
+       ADDITIONAL_ECLASSES="autotools git-r3"
+fi
+
+inherit eutils flag-o-matic user ${ADDITIONAL_ECLASSES}
+
+DESCRIPTION="A highly DNS-, DoS- and abuse-aware loadbalancer"
+HOMEPAGE="http://dnsdist.org"
+
+if [[ ${PV} == 9999 ]]; then
+       SRC_URI=""
+       S="${WORKDIR}/${P}/pdns/dnsdistdist"
+else
+       SRC_URI="https://downloads.powerdns.com/releases/${P}.tar.bz2"
+       KEYWORDS="~amd64"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="dnscrypt luajit readline regex remote-logging +ssl test"
+RESTRICT="readline? ( bindist )"
+REQUIRED_USE="dnscrypt? ( ssl )"
+
+DEPEND="
+       >=dev-libs/boost-1.35:=
+       luajit? ( dev-lang/luajit:= )
+       !luajit? ( >=dev-lang/lua-5.1:= )
+       remote-logging? ( dev-libs/protobuf:= )
+       readline? ( sys-libs/readline:0= )
+       !readline? ( dev-libs/libedit:= )
+       regex? ( dev-libs/re2:= )
+       ssl? ( dev-libs/libsodium:= )
+"
+
+RDEPEND="${DEPEND}"
+
+[[ ${PV} == 9999 ]] && DEPEND+="
+       app-text/pandoc
+       dev-util/ragel
+"
+
+src_prepare() {
+       eapply "${FILESDIR}/${PN}-readline.patch"
+       eapply_user
+
+       [[ ${PV} == 9999 ]] && eautoreconf
+}
+
+src_configure() {
+       if use readline ; then
+               local -x LIBEDIT_CFLAGS="-I/usr/include/readline"
+               local -x LIBEDIT_LIBS="-lreadline -lcurses"
+               append-cxxflags -DREADLINE
+       fi
+
+       econf \
+               --sysconfdir=/etc/dnsdist \
+               $(use_enable ssl libsodium) \
+               $(use_with remote-logging protobuf) \
+               $(use_enable regex re2) \
+               $(use_enable dnscrypt) \
+               $(use_with luajit) \
+               $(use_enable test unit-tests)
+}
+
+src_install() {
+       default
+
+       insinto /etc/dnsdist
+       doins "${FILESDIR}"/dnsdist.conf.example
+
+       newconfd "${FILESDIR}"/dnsdist.confd ${PN}
+       newinitd "${FILESDIR}"/dnsdist.initd ${PN}
+}
+
+pkg_preinst() {
+       enewgroup dnsdist
+       enewuser dnsdist -1 -1 -1 dnsdist
+}
+
+pkg_postinst() {
+       elog "dnsdist provides multiple instances support. You can create more instances"
+       elog "by symlinking the dnsdist init script to another name."
+       elog
+       elog "The name must be in the format dnsdist.<suffix> and dnsdist will use the"
+       elog "/etc/dnsdist/dnsdist-<suffix>.conf configuration file instead of the default."
+
+       if use readline ; then
+               ewarn "dnsdist (GPLv2) was linked against readline (GPLv3)."
+               ewarn "A binary distribution should therefore not happen."
+       fi
+}
diff --git a/net-dns/dnsdist/dnsdist-9999.ebuild b/net-dns/dnsdist/dnsdist-9999.ebuild
new file mode 100644 (file)
index 0000000..a057142
--- /dev/null
@@ -0,0 +1,101 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://github.com/PowerDNS/pdns.git"
+
+if [[ ${PV} = 9999 ]]; then
+       ADDITIONAL_ECLASSES="autotools git-r3"
+fi
+
+inherit eutils flag-o-matic user ${ADDITIONAL_ECLASSES}
+
+DESCRIPTION="A highly DNS-, DoS- and abuse-aware loadbalancer"
+HOMEPAGE="http://dnsdist.org"
+
+if [[ ${PV} == 9999 ]]; then
+       SRC_URI=""
+       S="${WORKDIR}/${P}/pdns/dnsdistdist"
+else
+       SRC_URI="https://downloads.powerdns.com/releases/${P}.tar.bz2"
+       KEYWORDS="~amd64"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="dnscrypt luajit readline regex remote-logging snmp +ssl test"
+RESTRICT="readline? ( bindist )"
+REQUIRED_USE="dnscrypt? ( ssl )"
+
+DEPEND="
+       >=dev-libs/boost-1.35:=
+       luajit? ( dev-lang/luajit:= )
+       !luajit? ( >=dev-lang/lua-5.1:= )
+       remote-logging? ( dev-libs/protobuf:= )
+       readline? ( sys-libs/readline:0= )
+       !readline? ( dev-libs/libedit:= )
+       regex? ( dev-libs/re2:= )
+       snmp? ( net-analyzer/net-snmp:= )
+       ssl? ( dev-libs/libsodium:= )
+"
+
+RDEPEND="${DEPEND}"
+
+[[ ${PV} == 9999 ]] && DEPEND+="
+       app-text/pandoc
+       dev-util/ragel
+"
+
+src_prepare() {
+       eapply "${FILESDIR}/${PN}-readline.patch"
+       eapply_user
+
+       [[ ${PV} == 9999 ]] && eautoreconf
+}
+
+src_configure() {
+       if use readline ; then
+               local -x LIBEDIT_CFLAGS="-I/usr/include/readline"
+               local -x LIBEDIT_LIBS="-lreadline -lcurses"
+               append-cxxflags -DREADLINE
+       fi
+
+       econf \
+               --sysconfdir=/etc/dnsdist \
+               $(use_enable ssl libsodium) \
+               $(use_with remote-logging protobuf) \
+               $(use_enable regex re2) \
+               $(use_enable dnscrypt) \
+               $(use_with luajit) \
+               $(use_enable test unit-tests) \
+               $(use_with snmp net-snmp)
+}
+
+src_install() {
+       default
+
+       insinto /etc/dnsdist
+       doins "${FILESDIR}"/dnsdist.conf.example
+
+       newconfd "${FILESDIR}"/dnsdist.confd ${PN}
+       newinitd "${FILESDIR}"/dnsdist.initd ${PN}
+}
+
+pkg_preinst() {
+       enewgroup dnsdist
+       enewuser dnsdist -1 -1 -1 dnsdist
+}
+
+pkg_postinst() {
+       elog "dnsdist provides multiple instances support. You can create more instances"
+       elog "by symlinking the dnsdist init script to another name."
+       elog
+       elog "The name must be in the format dnsdist.<suffix> and dnsdist will use the"
+       elog "/etc/dnsdist/dnsdist-<suffix>.conf configuration file instead of the default."
+
+       if use readline ; then
+               ewarn "dnsdist (GPLv2) was linked against readline (GPLv3)."
+               ewarn "A binary distribution should therefore not happen."
+       fi
+}
diff --git a/net-dns/dnsdist/files/dnsdist-readline.patch b/net-dns/dnsdist/files/dnsdist-readline.patch
new file mode 100644 (file)
index 0000000..d6e031f
--- /dev/null
@@ -0,0 +1,25 @@
+diff -Naur dnsdist-1.1.0/dnsdist.cc dnsdist-1.1.0-gentoo/dnsdist.cc
+--- dnsdist-1.1.0/dnsdist.cc   2016-12-29 13:45:46.000000000 +0100
++++ dnsdist-1.1.0-gentoo/dnsdist.cc    2017-05-21 15:09:10.414951426 +0200
+@@ -29,6 +29,8 @@
+ 
+ #if defined (__OpenBSD__)
+ #include <readline/readline.h>
++#elif defined READLINE
++#include <readline/readline.h>
+ #else
+ #include <editline/readline.h>
+ #endif
+diff -Naur dnsdist-1.1.0/dnsdist-console.cc dnsdist-1.1.0-gentoo/dnsdist-console.cc
+--- dnsdist-1.1.0/dnsdist-console.cc   2016-12-29 13:45:46.000000000 +0100
++++ dnsdist-1.1.0-gentoo/dnsdist-console.cc    2017-05-21 15:09:24.758950947 +0200
+@@ -25,6 +25,9 @@
+ #if defined (__OpenBSD__)
+ #include <readline/readline.h>
+ #include <readline/history.h>
++#elif defined READLINE
++#include <readline/readline.h>
++#include <readline/history.h>
+ #else
+ #include <editline/readline.h>
+ #endif
diff --git a/net-dns/dnsdist/files/dnsdist.conf.example b/net-dns/dnsdist/files/dnsdist.conf.example
new file mode 100644 (file)
index 0000000..ffcc606
--- /dev/null
@@ -0,0 +1,19 @@
+--[[
+This is an example dnsdist configuration file.
+Please refer to the dnsdist documentation
+at http://dnsdist.org/README/ for more information.
+]]--
+
+-- Listen on 192.0.2.1 on port 53.
+setLocal("192.0.2.1:53")
+
+-- Add 2001:db8::2:1 to the list of adresses dnsdist should listen on
+addLocal("2001:db8::2:1")
+
+-- Add to the ACL set who can use this server
+addACL("192.0.2.0/24")
+addACL("2001:db8::/32")
+
+-- Instantiate two new downstram server with their default settings
+newServer("198.51.100.1")
+newServer("198.51.100.2")
diff --git a/net-dns/dnsdist/files/dnsdist.confd b/net-dns/dnsdist/files/dnsdist.confd
new file mode 100644 (file)
index 0000000..7151fd0
--- /dev/null
@@ -0,0 +1,13 @@
+# /etc/conf.d/dnsdist
+
+# Options to pass on to dnsdist during the start
+DNSDIST_OPTIONS=""
+
+# Run dnsdist as this user
+DNSDIST_USER="dnsdist"
+
+# Run dnsdist in this group
+DNSDIST_GROUP="dnsdist"
+
+# Set the maximum number of open file descriptors
+rc_ulimit="-n 2048"
diff --git a/net-dns/dnsdist/files/dnsdist.initd b/net-dns/dnsdist/files/dnsdist.initd
new file mode 100644 (file)
index 0000000..bfeef82
--- /dev/null
@@ -0,0 +1,55 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="configcheck"
+#extra_started_commands=""
+
+DNSDIST_INSTANCE="${SVCNAME#dnsdist[.-]}"
+DNSDIST_CONFFILE="/etc/dnsdist/${SVCNAME#dnsdist[.-]}.conf"
+DNSDIST="/usr/bin/dnsdist"
+PIDDIR=/run/dnsdist
+PIDFILE=$PIDDIR/$SVCNAME.pid
+
+
+if [ -n "${DNSDIST_INSTANCE}" ] && [ "${DNSDIST_INSTANCE}" != "dnsdist" ]
+then
+       DNSDIST_INSTANCE="dnsdist-${SVCNAME#dnsdist[.-]}"
+       DNSDIST_CONFFILE="/etc/dnsdist/${DNSDIST_INSTANCE}.conf"
+else
+       DNSDIST_INSTANCE="default"
+fi
+
+depend() {
+       need net
+}
+
+start() {
+       checkpath -q -d ${PIDDIR} -o ${DNSDIST_USER}:${DNSDIST_GROUP} 
+
+       configcheck || return 1
+
+       ebegin "Starting dnsdist (${DNSDIST_INSTANCE})"
+       start-stop-daemon --start --exec $DNSDIST --pidfile ${PIDFILE} \
+               -- -d -p ${PIDFILE} -u ${DNSDIST_USER} -g ${DNSDIST_GROUP} \
+               -C $DNSDIST_CONFFILE ${DNSDIST_OPTIONS} 
+       eend $?
+}
+
+stop() {
+       ebegin "Stopping dnsdist (${DNSDIST_INSTANCE})"
+       start-stop-daemon --stop --exec $DNSDIST --pidfile ${PIDFILE}
+       eend $?
+}
+
+configcheck() {
+       ebegin "Checking configuration file (${DNSDIST_CONFFILE})"
+       $DNSDIST --check-config -C $DNSDIST_CONFFILE > /dev/null
+
+       if [ $? -ne 0 ]; then
+               $DNSDIST --check-config -C $DNSDIST_CONFFILE
+       fi
+
+       eend $? "failed, please correct errors above"
+}
+
diff --git a/net-dns/dnsdist/metadata.xml b/net-dns/dnsdist/metadata.xml
new file mode 100644 (file)
index 0000000..a9231ab
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+       <maintainer type="person">
+               <email>bgo@9dt.de</email>
+               <name>Vladimir Datsevich</name>
+       </maintainer>
+       <maintainer type="project">
+               <email>proxy-maint@gentoo.org</email>
+               <name>Proxy Maintainers</name>
+       </maintainer>
+       <longdescription lang="en">
+               dnsdist is a highly DNS-, DoS- and abuse-aware loadbalancer. Its goal in life is to route traffic to the best server, delivering top performance to legitimate users while shunting or blocking abusive traffic.
+       </longdescription>
+       <use>
+               <flag name="dnscrypt">Enable the ability to act as a DNSCrypt server</flag>
+               <flag name="luajit">Use <pkg>dev-lang/luajit</pkg> instead of <pkg>dev-lang/lua</pkg></flag>
+               <flag name="regex">Enable support for regular expression matching via <pkg>dev-libs/re2</pkg></flag>
+               <flag name="remote-logging">Enable support for remote logging via <pkg>dev-libs/protobuf</pkg></flag>
+               <flag name="ssl">Enable support for and encrypted client-server communication via <pkg>dev-libs/libsodium</pkg></flag>
+       </use>  
+</pkgmetadata>