Initial import
This commit is contained in:
2
Makefile.am
Normal file
2
Makefile.am
Normal file
@@ -0,0 +1,2 @@
|
||||
AUTOMAKE_OPTIONS=foreign
|
||||
SUBDIRS=src/ conf/
|
||||
3
conf/Makefile.am
Normal file
3
conf/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
confexampledir = $(prefix)/share/doc/ospow-dnsbl-proxy/
|
||||
confexample_DATA = dnsbl-proxy.conf.tpl
|
||||
|
||||
15
conf/dnsbl-proxy.conf.tpl
Normal file
15
conf/dnsbl-proxy.conf.tpl
Normal file
@@ -0,0 +1,15 @@
|
||||
[general]
|
||||
zone = @@ZONE@@
|
||||
port = 53
|
||||
# timeout in seconds
|
||||
timeout = 1
|
||||
# logfile or syslog:facility
|
||||
log = syslog:daemon
|
||||
# loglevel
|
||||
loglevel = INFO
|
||||
# Server list, coma separeted
|
||||
server_list = sbl-xbl.spamhaus.org, cbl.abuseat.org, dnsbl.sorbs.net, spam.spam-rbl.fr,rbl.jp,dul.ru
|
||||
# cache_timeout for cachelifetime (in seconds ...)
|
||||
cache_timeout = 3600
|
||||
# Debug = 1 for avoiding background launch ...
|
||||
debug = 0
|
||||
113
config.h.in
Normal file
113
config.h.in
Normal file
@@ -0,0 +1,113 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#undef HAVE_ARPA_NAMESER_H
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the `inet_ntoa' function. */
|
||||
#undef HAVE_INET_NTOA
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `event' library (-levent). */
|
||||
#undef HAVE_LIBEVENT
|
||||
|
||||
/* Define to 1 if you have the `resolv' library (-lresolv). */
|
||||
#undef HAVE_LIBRESOLV
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <resolv.h> header file. */
|
||||
#undef HAVE_RESOLV_H
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
33
configure.ac
Normal file
33
configure.ac
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.0])
|
||||
AC_INIT([ospow-dnsbl-proxy],[2.0], [gcolangelo@ospow.com])
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
#PKG_PROG_PKG_CONFIG(0.1)
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CC_C_O
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
AC_CONFIG_FILES([src/Makefile conf/Makefile Makefile])
|
||||
|
||||
# Checks for libraries.
|
||||
# FIXME: Replace `main' with a function in `-levent':
|
||||
AC_CHECK_LIB([event], [main])
|
||||
# FIXME: Replace `main' with a function in `-lresolv':
|
||||
AC_CHECK_LIB([resolv], [main])
|
||||
|
||||
|
||||
AC_ARG_ENABLE([static], [AC_HELP_STRING([--enable-static], [Enable static binary])],[],[enable_static=no])
|
||||
if [[ "$enable_static" = "yes" ]]; then
|
||||
CFLAGS="$CFLAGS -static"
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(glib, gthread-2.0 glib-2.0 )
|
||||
PKG_CHECK_MODULES(pcre, libpcre)
|
||||
CFLAGS="-Wall -O2 $CFLAGS $glib_CFLAGS $pcre_CFLAGS"
|
||||
LIBS="$LIBS $LDFLAGS $glib_LIBS $pcre_LIBS"
|
||||
|
||||
#AC_OUTPUT
|
||||
6
debian/README
vendored
Normal file
6
debian/README
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
The Debian Package ospow-dnsbl-proxy
|
||||
----------------------------
|
||||
|
||||
Comments regarding the Package
|
||||
|
||||
-- root <gcolangelo@ospow.com> Thu, 31 Jan 2013 19:11:47 +0100
|
||||
6
debian/README.Debian
vendored
Normal file
6
debian/README.Debian
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
ospow-dnsbl-proxy for Debian
|
||||
----------------------------
|
||||
|
||||
<possible notes regarding this package - if none, delete this file>
|
||||
|
||||
-- root <gcolangelo@ospow.com> Thu, 31 Jan 2013 19:11:47 +0100
|
||||
9
debian/README.source
vendored
Normal file
9
debian/README.source
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
ospow-dnsbl-proxy for Debian
|
||||
----------------------------
|
||||
|
||||
<this file describes information about the source package, see Debian policy
|
||||
manual section 4.14. You WILL either need to modify or delete this file>
|
||||
|
||||
|
||||
|
||||
|
||||
23
debian/changelog
vendored
Normal file
23
debian/changelog
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
ospow-dnsbl-proxy (2.3) unstable; urgency=low
|
||||
|
||||
* Correct memory leaks
|
||||
|
||||
-- Gérald COLANGELO <gcolangelo@ospow.com> Wed, 03 Apr 2013 11:01:27 +0100
|
||||
|
||||
ospow-dnsbl-proxy (2.2) unstable; urgency=low
|
||||
|
||||
* Correct bugs, lot of !
|
||||
|
||||
-- Gérald COLANGELO <gcolangelo@ospow.com> Wed, 03 Apr 2013 3:41:28 +0100
|
||||
|
||||
ospow-dnsbl-proxy (2.1) unstable; urgency=low
|
||||
|
||||
* Correct timeout bug
|
||||
|
||||
-- Gérald COLANGELO <gcolangelo@ospow.com> Thu, 07 Feb 2013 13:58:14 +0100
|
||||
|
||||
ospow-dnsbl-proxy (2.0) unstable; urgency=low
|
||||
|
||||
* New version rewritten in C.
|
||||
|
||||
-- Gérald COLANGELO <gcolangelo@ospow.com> Thu, 31 Jan 2013 19:11:47 +0100
|
||||
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
17
debian/control
vendored
Normal file
17
debian/control
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Source: ospow-dnsbl-proxy
|
||||
Section: unknown
|
||||
Priority: extra
|
||||
Maintainer: root <gcolangelo@ospow.com>
|
||||
Build-Depends: debhelper (>= 7.0.50~), autotools-dev, libevent-dev (>= 2.0.0), libglib2.0-dev (>=2.10), libpcre3-dev
|
||||
Standards-Version: 3.8.4
|
||||
Homepage: http://ospow.com
|
||||
|
||||
Package: ospow-dnsbl-proxy
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: Ospow DNSBL Proxy Server
|
||||
A lightweight, performant DNSBL Proxy Server written in C using libevent.
|
||||
Implements:
|
||||
_ A cache mechanism to avoid useless queries
|
||||
_ Direct interrogation of DNSBL servers
|
||||
_ TXT record to get where IP is listed:
|
||||
48
debian/copyright
vendored
Normal file
48
debian/copyright
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
This work was packaged for Debian by:
|
||||
|
||||
Gérald COLANGELO <gcolangelo@ospow.com> on Thu, 31 Jan 2013 19:11:47 +0100
|
||||
|
||||
Upstream Author(s):
|
||||
|
||||
Gérald COLANGELO <gcolangelo@ospow.com>
|
||||
|
||||
|
||||
Copyright:
|
||||
|
||||
<Copyright (C) 2013 Gérald COLANGELO>
|
||||
|
||||
License:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted under the terms of the BSD License.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
|
||||
On Debian systems, the complete text of the BSD License can be
|
||||
found in "/usr/share/common-licenses/BSD".
|
||||
|
||||
The Debian packaging is:
|
||||
|
||||
Copyright (C) 2013 root <gcolangelo@ospow.com>
|
||||
|
||||
# Please chose a license for your packaging work. If the program you package
|
||||
# uses a mainstream license, using the same license is the safest choice.
|
||||
# Please avoid to pick license terms that are more restrictive than the
|
||||
# packaged work, as it may make Debian's contributions unacceptable upstream.
|
||||
# If you just want it to be GPL version 3, leave the following lines in.
|
||||
|
||||
and is licensed under the GPL version 3,
|
||||
see "/usr/share/common-licenses/GPL-3".
|
||||
|
||||
# Please also look if there are files or directories which have a
|
||||
# different copyright/license attached and list them here.
|
||||
0
debian/docs
vendored
Normal file
0
debian/docs
vendored
Normal file
1
debian/files
vendored
Normal file
1
debian/files
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ospow-dnsbl-proxy_2.3_amd64.deb unknown extra
|
||||
11
debian/ospow-dnsbl-proxy.config
vendored
Executable file
11
debian/ospow-dnsbl-proxy.config
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Source debconf library.
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Zone
|
||||
db_reset dnsbl-proxy/zone
|
||||
db_input high dnsbl-proxy/zone || true
|
||||
|
||||
db_go
|
||||
|
||||
48
debian/ospow-dnsbl-proxy.debhelper.log
vendored
Normal file
48
debian/ospow-dnsbl-proxy.debhelper.log
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
dh_auto_configure
|
||||
dh_auto_build
|
||||
dh_auto_test
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
dh_auto_install
|
||||
dh_install
|
||||
dh_installdocs
|
||||
dh_installchangelogs
|
||||
dh_installexamples
|
||||
dh_installman
|
||||
dh_installcatalogs
|
||||
dh_installcron
|
||||
dh_installdebconf
|
||||
dh_installemacsen
|
||||
dh_installifupdown
|
||||
dh_installinfo
|
||||
dh_pysupport
|
||||
dh_installinit
|
||||
dh_installmenu
|
||||
dh_installmime
|
||||
dh_installmodules
|
||||
dh_installlogcheck
|
||||
dh_installlogrotate
|
||||
dh_installpam
|
||||
dh_installppp
|
||||
dh_installudev
|
||||
dh_installwm
|
||||
dh_installxfonts
|
||||
dh_installgsettings
|
||||
dh_bugfiles
|
||||
dh_ucf
|
||||
dh_lintian
|
||||
dh_gconf
|
||||
dh_icons
|
||||
dh_perl
|
||||
dh_usrlocal
|
||||
dh_link
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_strip
|
||||
dh_makeshlibs
|
||||
dh_shlibdeps
|
||||
dh_installdeb
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
dh_builddeb
|
||||
129
debian/ospow-dnsbl-proxy.init
vendored
Normal file
129
debian/ospow-dnsbl-proxy.init
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ospow-dnsbl-proxy
|
||||
# Required-Start: $network $local_fs
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: <Enter a short description of the sortware>
|
||||
# Description: <Enter a long description of the software>
|
||||
# <...>
|
||||
# <...>
|
||||
### END INIT INFO
|
||||
|
||||
# Author: root <gcolangelo@ospow.com>
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Ospow DNSBL Proxy" # Introduce a short description here
|
||||
NAME=dnsbl-proxy # Introduce the short server's name here
|
||||
DAEMON=/usr/sbin/dnsbl-proxy # Introduce the server's location here
|
||||
DAEMON_ARGS="" # Arguments to run the daemon with
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x $DAEMON ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
$DAEMON # Add code here, if necessary, that waits for the process to be ready
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
pid=$(pidof dnsbl-proxy)
|
||||
if [ -n "$pid" ] ; then
|
||||
kill $pid
|
||||
kill -9 $pid
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Function that sends a SIGHUP to the daemon/service
|
||||
#
|
||||
do_reload() {
|
||||
#
|
||||
# If the daemon can reload its configuration without
|
||||
# restarting (for example, when it is sent a SIGHUP),
|
||||
# then implement that here.
|
||||
#
|
||||
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
#reload|force-reload)
|
||||
#
|
||||
# If do_reload() is not implemented then leave this commented out
|
||||
# and leave 'force-reload' as an alias for 'restart'.
|
||||
#
|
||||
#log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
#do_reload
|
||||
#log_end_msg $?
|
||||
#;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
39
debian/ospow-dnsbl-proxy.postinst
vendored
Normal file
39
debian/ospow-dnsbl-proxy.postinst
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# postinst script for ospow-dnsbl-proxy
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
db_get dnsbl-proxy/zone
|
||||
zone=$RET
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
if [ ! -f /etc/ospow/dnsbl-proxy.conf ] ; then
|
||||
mkdir -p /etc/ospow/
|
||||
cat /usr/share/doc/ospow-dnsbl-proxy/dnsbl-proxy.conf.tpl | sed \
|
||||
-e "s/@@ZONE@@/$zone/" > /etc/ospow/dnsbl-proxy.conf;
|
||||
else
|
||||
echo "Config ever exists, skipping ...";
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
8
debian/ospow-dnsbl-proxy.postinst.debhelper
vendored
Normal file
8
debian/ospow-dnsbl-proxy.postinst.debhelper
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Automatically added by dh_installinit
|
||||
if [ -x "/etc/init.d/ospow-dnsbl-proxy" ]; then
|
||||
if [ ! -e "/etc/init/ospow-dnsbl-proxy.conf" ]; then
|
||||
update-rc.d ospow-dnsbl-proxy defaults >/dev/null
|
||||
fi
|
||||
invoke-rc.d ospow-dnsbl-proxy start || exit $?
|
||||
fi
|
||||
# End automatically added section
|
||||
11
debian/ospow-dnsbl-proxy.postrm.debhelper
vendored
Normal file
11
debian/ospow-dnsbl-proxy.postrm.debhelper
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Automatically added by dh_installinit
|
||||
if [ "$1" = "purge" ] ; then
|
||||
update-rc.d ospow-dnsbl-proxy remove >/dev/null
|
||||
fi
|
||||
# End automatically added section
|
||||
# Automatically added by dh_installdebconf
|
||||
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
db_purge
|
||||
fi
|
||||
# End automatically added section
|
||||
5
debian/ospow-dnsbl-proxy.prerm.debhelper
vendored
Normal file
5
debian/ospow-dnsbl-proxy.prerm.debhelper
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Automatically added by dh_installinit
|
||||
if [ -x "/etc/init.d/ospow-dnsbl-proxy" ]; then
|
||||
invoke-rc.d ospow-dnsbl-proxy stop || exit $?
|
||||
fi
|
||||
# End automatically added section
|
||||
1
debian/ospow-dnsbl-proxy.substvars
vendored
Normal file
1
debian/ospow-dnsbl-proxy.substvars
vendored
Normal file
@@ -0,0 +1 @@
|
||||
misc:Depends=debconf (>= 0.5) | debconf-2.0
|
||||
4
debian/ospow-dnsbl-proxy.templates
vendored
Normal file
4
debian/ospow-dnsbl-proxy.templates
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Template: dnsbl-proxy/zone
|
||||
Type: string
|
||||
Default: rbl.<yourdomain>
|
||||
Description: DNS Zone that dnsbl-proxy will serve RBL records
|
||||
1
debian/ospow-dnsbl-proxy/DEBIAN/conffiles
vendored
Normal file
1
debian/ospow-dnsbl-proxy/DEBIAN/conffiles
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/etc/init.d/ospow-dnsbl-proxy
|
||||
11
debian/ospow-dnsbl-proxy/DEBIAN/config
vendored
Executable file
11
debian/ospow-dnsbl-proxy/DEBIAN/config
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Source debconf library.
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Zone
|
||||
db_reset dnsbl-proxy/zone
|
||||
db_input high dnsbl-proxy/zone || true
|
||||
|
||||
db_go
|
||||
|
||||
15
debian/ospow-dnsbl-proxy/DEBIAN/control
vendored
Normal file
15
debian/ospow-dnsbl-proxy/DEBIAN/control
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Package: ospow-dnsbl-proxy
|
||||
Version: 2.3
|
||||
Architecture: amd64
|
||||
Maintainer: root <gcolangelo@ospow.com>
|
||||
Installed-Size: 40
|
||||
Depends: debconf (>= 0.5) | debconf-2.0
|
||||
Section: unknown
|
||||
Priority: extra
|
||||
Homepage: http://ospow.com
|
||||
Description: Ospow DNSBL Proxy Server
|
||||
A lightweight, performant DNSBL Proxy Server written in C using libevent.
|
||||
Implements:
|
||||
_ A cache mechanism to avoid useless queries
|
||||
_ Direct interrogation of DNSBL servers
|
||||
_ TXT record to get where IP is listed:
|
||||
3
debian/ospow-dnsbl-proxy/DEBIAN/md5sums
vendored
Normal file
3
debian/ospow-dnsbl-proxy/DEBIAN/md5sums
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
f1afcd98c46e319ac8b15a6c410a65e4 usr/share/doc/ospow-dnsbl-proxy/README.Debian
|
||||
65f6569564bb4943c04ebdffd0a84bfb usr/share/doc/ospow-dnsbl-proxy/changelog.gz
|
||||
92d2e00ff235a266b8e8d4e6a46e8432 usr/share/doc/ospow-dnsbl-proxy/copyright
|
||||
47
debian/ospow-dnsbl-proxy/DEBIAN/postinst
vendored
Executable file
47
debian/ospow-dnsbl-proxy/DEBIAN/postinst
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# postinst script for ospow-dnsbl-proxy
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
db_get dnsbl-proxy/zone
|
||||
zone=$RET
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
if [ ! -f /etc/ospow/dnsbl-proxy.conf ] ; then
|
||||
mkdir -p /etc/ospow/
|
||||
cat /usr/share/doc/ospow-dnsbl-proxy/dnsbl-proxy.conf.tpl | sed \
|
||||
-e "s/@@ZONE@@/$zone/" > /etc/ospow/dnsbl-proxy.conf;
|
||||
else
|
||||
echo "Config ever exists, skipping ...";
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
# Automatically added by dh_installinit
|
||||
if [ -x "/etc/init.d/ospow-dnsbl-proxy" ]; then
|
||||
if [ ! -e "/etc/init/ospow-dnsbl-proxy.conf" ]; then
|
||||
update-rc.d ospow-dnsbl-proxy defaults >/dev/null
|
||||
fi
|
||||
invoke-rc.d ospow-dnsbl-proxy start || exit $?
|
||||
fi
|
||||
# End automatically added section
|
||||
|
||||
|
||||
exit 0
|
||||
13
debian/ospow-dnsbl-proxy/DEBIAN/postrm
vendored
Executable file
13
debian/ospow-dnsbl-proxy/DEBIAN/postrm
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
# Automatically added by dh_installinit
|
||||
if [ "$1" = "purge" ] ; then
|
||||
update-rc.d ospow-dnsbl-proxy remove >/dev/null
|
||||
fi
|
||||
# End automatically added section
|
||||
# Automatically added by dh_installdebconf
|
||||
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
db_purge
|
||||
fi
|
||||
# End automatically added section
|
||||
7
debian/ospow-dnsbl-proxy/DEBIAN/prerm
vendored
Executable file
7
debian/ospow-dnsbl-proxy/DEBIAN/prerm
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
# Automatically added by dh_installinit
|
||||
if [ -x "/etc/init.d/ospow-dnsbl-proxy" ]; then
|
||||
invoke-rc.d ospow-dnsbl-proxy stop || exit $?
|
||||
fi
|
||||
# End automatically added section
|
||||
4
debian/ospow-dnsbl-proxy/DEBIAN/templates
vendored
Normal file
4
debian/ospow-dnsbl-proxy/DEBIAN/templates
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Template: dnsbl-proxy/zone
|
||||
Type: string
|
||||
Default: rbl.<yourdomain>
|
||||
Description: DNS Zone that dnsbl-proxy will serve RBL records
|
||||
129
debian/ospow-dnsbl-proxy/etc/init.d/ospow-dnsbl-proxy
vendored
Executable file
129
debian/ospow-dnsbl-proxy/etc/init.d/ospow-dnsbl-proxy
vendored
Executable file
@@ -0,0 +1,129 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ospow-dnsbl-proxy
|
||||
# Required-Start: $network $local_fs
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: <Enter a short description of the sortware>
|
||||
# Description: <Enter a long description of the software>
|
||||
# <...>
|
||||
# <...>
|
||||
### END INIT INFO
|
||||
|
||||
# Author: root <gcolangelo@ospow.com>
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Ospow DNSBL Proxy" # Introduce a short description here
|
||||
NAME=dnsbl-proxy # Introduce the short server's name here
|
||||
DAEMON=/usr/sbin/dnsbl-proxy # Introduce the server's location here
|
||||
DAEMON_ARGS="" # Arguments to run the daemon with
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x $DAEMON ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
$DAEMON # Add code here, if necessary, that waits for the process to be ready
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
pid=$(pidof dnsbl-proxy)
|
||||
if [ -n "$pid" ] ; then
|
||||
kill $pid
|
||||
kill -9 $pid
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Function that sends a SIGHUP to the daemon/service
|
||||
#
|
||||
do_reload() {
|
||||
#
|
||||
# If the daemon can reload its configuration without
|
||||
# restarting (for example, when it is sent a SIGHUP),
|
||||
# then implement that here.
|
||||
#
|
||||
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
#reload|force-reload)
|
||||
#
|
||||
# If do_reload() is not implemented then leave this commented out
|
||||
# and leave 'force-reload' as an alias for 'restart'.
|
||||
#
|
||||
#log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
#do_reload
|
||||
#log_end_msg $?
|
||||
#;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
6
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/README.Debian
vendored
Normal file
6
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/README.Debian
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
ospow-dnsbl-proxy for Debian
|
||||
----------------------------
|
||||
|
||||
<possible notes regarding this package - if none, delete this file>
|
||||
|
||||
-- root <gcolangelo@ospow.com> Thu, 31 Jan 2013 19:11:47 +0100
|
||||
BIN
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/changelog.gz
vendored
Normal file
BIN
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/changelog.gz
vendored
Normal file
Binary file not shown.
48
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/copyright
vendored
Normal file
48
debian/ospow-dnsbl-proxy/usr/share/doc/ospow-dnsbl-proxy/copyright
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
This work was packaged for Debian by:
|
||||
|
||||
Gérald COLANGELO <gcolangelo@ospow.com> on Thu, 31 Jan 2013 19:11:47 +0100
|
||||
|
||||
Upstream Author(s):
|
||||
|
||||
Gérald COLANGELO <gcolangelo@ospow.com>
|
||||
|
||||
|
||||
Copyright:
|
||||
|
||||
<Copyright (C) 2013 Gérald COLANGELO>
|
||||
|
||||
License:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted under the terms of the BSD License.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
|
||||
On Debian systems, the complete text of the BSD License can be
|
||||
found in "/usr/share/common-licenses/BSD".
|
||||
|
||||
The Debian packaging is:
|
||||
|
||||
Copyright (C) 2013 root <gcolangelo@ospow.com>
|
||||
|
||||
# Please chose a license for your packaging work. If the program you package
|
||||
# uses a mainstream license, using the same license is the safest choice.
|
||||
# Please avoid to pick license terms that are more restrictive than the
|
||||
# packaged work, as it may make Debian's contributions unacceptable upstream.
|
||||
# If you just want it to be GPL version 3, leave the following lines in.
|
||||
|
||||
and is licensed under the GPL version 3,
|
||||
see "/usr/share/common-licenses/GPL-3".
|
||||
|
||||
# Please also look if there are files or directories which have a
|
||||
# different copyright/license attached and list them here.
|
||||
13
debian/rules
vendored
Executable file
13
debian/rules
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Sample debian/rules that uses debhelper.
|
||||
# This file was originally written by Joey Hess and Craig Small.
|
||||
# As a special exception, when this file is copied by dh-make into a
|
||||
# dh-make output file, you may use that output file without restriction.
|
||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
%:
|
||||
dh $@
|
||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
||||
3.0 (native)
|
||||
BIN
src/.config.c.swp
Normal file
BIN
src/.config.c.swp
Normal file
Binary file not shown.
10
src/Makefile.am
Normal file
10
src/Makefile.am
Normal file
@@ -0,0 +1,10 @@
|
||||
sbin_PROGRAMS=dnsbl-proxy
|
||||
noinst_PROGRAMS=test_cache test_tools
|
||||
|
||||
dnsbl_proxy_SOURCES = cache.c config.c tools.c dns.c main.c
|
||||
test_cache_SOURCES = cache.c tools.c
|
||||
test_cache_CFLAGS = ${CFLAGS} -DTEST -DTEST_CACHE
|
||||
|
||||
test_tools_SOURCES = cache.c tools.c
|
||||
test_tools_CFLAGS = ${CFLAGS} -DTEST -DTEST_TOOLS
|
||||
|
||||
551
src/Makefile.in
Normal file
551
src/Makefile.in
Normal file
@@ -0,0 +1,551 @@
|
||||
# Makefile.in generated by automake 1.11.3 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
|
||||
# Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
sbin_PROGRAMS = dnsbl-proxy$(EXEEXT)
|
||||
noinst_PROGRAMS = test_cache$(EXEEXT) test_tools$(EXEEXT)
|
||||
subdir = src
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(sbindir)"
|
||||
PROGRAMS = $(noinst_PROGRAMS) $(sbin_PROGRAMS)
|
||||
am_dnsbl_proxy_OBJECTS = cache.$(OBJEXT) config.$(OBJEXT) \
|
||||
tools.$(OBJEXT) dns.$(OBJEXT) main.$(OBJEXT)
|
||||
dnsbl_proxy_OBJECTS = $(am_dnsbl_proxy_OBJECTS)
|
||||
dnsbl_proxy_LDADD = $(LDADD)
|
||||
am_test_cache_OBJECTS = test_cache-cache.$(OBJEXT) \
|
||||
test_cache-tools.$(OBJEXT)
|
||||
test_cache_OBJECTS = $(am_test_cache_OBJECTS)
|
||||
test_cache_LDADD = $(LDADD)
|
||||
test_cache_LINK = $(CCLD) $(test_cache_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
am_test_tools_OBJECTS = test_tools-cache.$(OBJEXT) \
|
||||
test_tools-tools.$(OBJEXT)
|
||||
test_tools_OBJECTS = $(am_test_tools_OBJECTS)
|
||||
test_tools_LDADD = $(LDADD)
|
||||
test_tools_LINK = $(CCLD) $(test_tools_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(dnsbl_proxy_SOURCES) $(test_cache_SOURCES) \
|
||||
$(test_tools_SOURCES)
|
||||
DIST_SOURCES = $(dnsbl_proxy_SOURCES) $(test_cache_SOURCES) \
|
||||
$(test_tools_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EXEEXT = @EXEEXT@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build_alias = @build_alias@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
glib_CFLAGS = @glib_CFLAGS@
|
||||
glib_LIBS = @glib_LIBS@
|
||||
host_alias = @host_alias@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pcre_CFLAGS = @pcre_CFLAGS@
|
||||
pcre_LIBS = @pcre_LIBS@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
dnsbl_proxy_SOURCES = cache.c config.c tools.c dns.c main.c
|
||||
test_cache_SOURCES = cache.c tools.c
|
||||
test_cache_CFLAGS = ${CFLAGS} -DTEST -DTEST_CACHE
|
||||
test_tools_SOURCES = cache.c tools.c
|
||||
test_tools_CFLAGS = ${CFLAGS} -DTEST -DTEST_TOOLS
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
||||
install-sbinPROGRAMS: $(sbin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
|
||||
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p; \
|
||||
then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
uninstall-sbinPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' `; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(sbindir)" && rm -f $$files
|
||||
|
||||
clean-sbinPROGRAMS:
|
||||
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
|
||||
dnsbl-proxy$(EXEEXT): $(dnsbl_proxy_OBJECTS) $(dnsbl_proxy_DEPENDENCIES) $(EXTRA_dnsbl_proxy_DEPENDENCIES)
|
||||
@rm -f dnsbl-proxy$(EXEEXT)
|
||||
$(LINK) $(dnsbl_proxy_OBJECTS) $(dnsbl_proxy_LDADD) $(LIBS)
|
||||
test_cache$(EXEEXT): $(test_cache_OBJECTS) $(test_cache_DEPENDENCIES) $(EXTRA_test_cache_DEPENDENCIES)
|
||||
@rm -f test_cache$(EXEEXT)
|
||||
$(test_cache_LINK) $(test_cache_OBJECTS) $(test_cache_LDADD) $(LIBS)
|
||||
test_tools$(EXEEXT): $(test_tools_OBJECTS) $(test_tools_DEPENDENCIES) $(EXTRA_test_tools_DEPENDENCIES)
|
||||
@rm -f test_tools$(EXEEXT)
|
||||
$(test_tools_LINK) $(test_tools_OBJECTS) $(test_tools_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cache-cache.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cache-tools.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tools-cache.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tools-tools.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
test_cache-cache.o: cache.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -MT test_cache-cache.o -MD -MP -MF $(DEPDIR)/test_cache-cache.Tpo -c -o test_cache-cache.o `test -f 'cache.c' || echo '$(srcdir)/'`cache.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_cache-cache.Tpo $(DEPDIR)/test_cache-cache.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cache.c' object='test_cache-cache.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -c -o test_cache-cache.o `test -f 'cache.c' || echo '$(srcdir)/'`cache.c
|
||||
|
||||
test_cache-cache.obj: cache.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -MT test_cache-cache.obj -MD -MP -MF $(DEPDIR)/test_cache-cache.Tpo -c -o test_cache-cache.obj `if test -f 'cache.c'; then $(CYGPATH_W) 'cache.c'; else $(CYGPATH_W) '$(srcdir)/cache.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_cache-cache.Tpo $(DEPDIR)/test_cache-cache.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cache.c' object='test_cache-cache.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -c -o test_cache-cache.obj `if test -f 'cache.c'; then $(CYGPATH_W) 'cache.c'; else $(CYGPATH_W) '$(srcdir)/cache.c'; fi`
|
||||
|
||||
test_cache-tools.o: tools.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -MT test_cache-tools.o -MD -MP -MF $(DEPDIR)/test_cache-tools.Tpo -c -o test_cache-tools.o `test -f 'tools.c' || echo '$(srcdir)/'`tools.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_cache-tools.Tpo $(DEPDIR)/test_cache-tools.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tools.c' object='test_cache-tools.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -c -o test_cache-tools.o `test -f 'tools.c' || echo '$(srcdir)/'`tools.c
|
||||
|
||||
test_cache-tools.obj: tools.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -MT test_cache-tools.obj -MD -MP -MF $(DEPDIR)/test_cache-tools.Tpo -c -o test_cache-tools.obj `if test -f 'tools.c'; then $(CYGPATH_W) 'tools.c'; else $(CYGPATH_W) '$(srcdir)/tools.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_cache-tools.Tpo $(DEPDIR)/test_cache-tools.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tools.c' object='test_cache-tools.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cache_CFLAGS) $(CFLAGS) -c -o test_cache-tools.obj `if test -f 'tools.c'; then $(CYGPATH_W) 'tools.c'; else $(CYGPATH_W) '$(srcdir)/tools.c'; fi`
|
||||
|
||||
test_tools-cache.o: cache.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -MT test_tools-cache.o -MD -MP -MF $(DEPDIR)/test_tools-cache.Tpo -c -o test_tools-cache.o `test -f 'cache.c' || echo '$(srcdir)/'`cache.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_tools-cache.Tpo $(DEPDIR)/test_tools-cache.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cache.c' object='test_tools-cache.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -c -o test_tools-cache.o `test -f 'cache.c' || echo '$(srcdir)/'`cache.c
|
||||
|
||||
test_tools-cache.obj: cache.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -MT test_tools-cache.obj -MD -MP -MF $(DEPDIR)/test_tools-cache.Tpo -c -o test_tools-cache.obj `if test -f 'cache.c'; then $(CYGPATH_W) 'cache.c'; else $(CYGPATH_W) '$(srcdir)/cache.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_tools-cache.Tpo $(DEPDIR)/test_tools-cache.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cache.c' object='test_tools-cache.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -c -o test_tools-cache.obj `if test -f 'cache.c'; then $(CYGPATH_W) 'cache.c'; else $(CYGPATH_W) '$(srcdir)/cache.c'; fi`
|
||||
|
||||
test_tools-tools.o: tools.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -MT test_tools-tools.o -MD -MP -MF $(DEPDIR)/test_tools-tools.Tpo -c -o test_tools-tools.o `test -f 'tools.c' || echo '$(srcdir)/'`tools.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_tools-tools.Tpo $(DEPDIR)/test_tools-tools.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tools.c' object='test_tools-tools.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -c -o test_tools-tools.o `test -f 'tools.c' || echo '$(srcdir)/'`tools.c
|
||||
|
||||
test_tools-tools.obj: tools.c
|
||||
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -MT test_tools-tools.obj -MD -MP -MF $(DEPDIR)/test_tools-tools.Tpo -c -o test_tools-tools.obj `if test -f 'tools.c'; then $(CYGPATH_W) 'tools.c'; else $(CYGPATH_W) '$(srcdir)/tools.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/test_tools-tools.Tpo $(DEPDIR)/test_tools-tools.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tools.c' object='test_tools-tools.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tools_CFLAGS) $(CFLAGS) -c -o test_tools-tools.obj `if test -f 'tools.c'; then $(CYGPATH_W) 'tools.c'; else $(CYGPATH_W) '$(srcdir)/tools.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(sbindir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-noinstPROGRAMS clean-sbinPROGRAMS \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-sbinPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-sbinPROGRAMS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-noinstPROGRAMS clean-sbinPROGRAMS ctags distclean \
|
||||
distclean-compile distclean-generic distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-sbinPROGRAMS
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
130
src/cache.c
Normal file
130
src/cache.c
Normal file
@@ -0,0 +1,130 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <event2/event_struct.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "tools.h"
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Thread Safe IT !!!!
|
||||
* Add a function for freeing memory when item removed
|
||||
*
|
||||
*/
|
||||
GHashTable *cache;
|
||||
time_t cache_timeout;
|
||||
|
||||
|
||||
record_t *get_cached_name(const char *name)
|
||||
{
|
||||
return ((record_t *) g_hash_table_lookup(cache, name));
|
||||
}
|
||||
|
||||
void set_cache_name(char *name, gboolean listed, char *server)
|
||||
{
|
||||
record_t *c;
|
||||
c = g_new0(record_t,1);
|
||||
c->listed = listed;
|
||||
c->name = g_strdup(name);
|
||||
c->server = g_strdup(server);
|
||||
c->ctime = time(NULL);
|
||||
g_hash_table_insert(cache, name , c);
|
||||
}
|
||||
|
||||
|
||||
gboolean checkCacheItem(gpointer name, gpointer value, gpointer data)
|
||||
{
|
||||
record_t *item = value;
|
||||
struct timeval *now,lifetime;
|
||||
now = (struct timeval *) data;
|
||||
timersub(now,item->ctime,&lifetime);
|
||||
if(!timercmp(&lifetime,cacheTimeout,<=)){
|
||||
g_debug("Purging entry %s %p",(char *) name,&name);
|
||||
return(TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
void dumpCacheItem(gpointer name, gpointer value, gpointer data)
|
||||
{
|
||||
record_t *item = value;
|
||||
if (item->listed)
|
||||
debug("%s on (%s).", (char *)name, item->server);
|
||||
else
|
||||
debug("%s clear.", (char *)name);
|
||||
}
|
||||
|
||||
|
||||
void cache_cleanup(struct event *timer)
|
||||
{
|
||||
int deleted = 0;
|
||||
time_t now;
|
||||
debug("Cleaning cache");
|
||||
now = time(NULL);
|
||||
deleted = g_hash_table_foreach_remove(cache, (GHRFunc) checkCacheItem, &now);
|
||||
notice("Removed %d keys (%d in cache)", deleted, g_hash_table_size(cache));
|
||||
}
|
||||
|
||||
|
||||
void cache_dump()
|
||||
{
|
||||
g_hash_table_foreach(cache, dumpCacheItem, NULL);
|
||||
}
|
||||
|
||||
void free_value(gpointer data)
|
||||
{
|
||||
record_t *r = (record_t *) data;
|
||||
if(r->name)
|
||||
g_free(r->name);
|
||||
if (r->server)
|
||||
g_free(r->server);
|
||||
g_free(r);
|
||||
}
|
||||
|
||||
void free_key(gpointer data)
|
||||
{
|
||||
if (data)
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
void cache_init(time_t timeout)
|
||||
{
|
||||
cache = g_hash_table_new_full(g_str_hash, g_str_equal, free_key, free_value);
|
||||
cache_timeout = timeout;
|
||||
}
|
||||
|
||||
void cache_destroy()
|
||||
{
|
||||
g_hash_table_destroy(cache);
|
||||
}
|
||||
|
||||
#ifdef TEST_CACHE
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int i,j;
|
||||
cache_init(1);
|
||||
for (j=0; j<4 ; j++){
|
||||
for (i=0; i< 500000; i++) {
|
||||
char *pouet;
|
||||
pouet = g_malloc(16);
|
||||
sprintf(pouet,"%.5d",i);
|
||||
set_cache_name(pouet,1,pouet);
|
||||
}
|
||||
printf("Sleeping before cleanup !\n");
|
||||
sleep(3);
|
||||
cache_cleanup(NULL);
|
||||
printf("Sleeping after cleanup !\n");
|
||||
sleep(3);
|
||||
}
|
||||
printf("Sleeping a bit again !\n");
|
||||
sleep(10);
|
||||
return(0);
|
||||
|
||||
}
|
||||
#endif
|
||||
323
src/config.c
Normal file
323
src/config.c
Normal file
@@ -0,0 +1,323 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <event2/event-config.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/dns.h>
|
||||
#include <event2/dns_struct.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "tools.h"
|
||||
#include "dns.h"
|
||||
|
||||
void free_config()
|
||||
{
|
||||
struct dnsbl_server_t **ptr;
|
||||
|
||||
/* Allocated stuff */
|
||||
g_free(config->zone);
|
||||
g_free(config->logging);
|
||||
g_free(config->server_list);
|
||||
g_regex_unref(config->zone_regex);
|
||||
|
||||
/* Free dnsbl servers */
|
||||
ptr = config->servers;
|
||||
while (*ptr) {
|
||||
struct dnsbl_server_t *srv = *ptr;
|
||||
free(srv->name);
|
||||
free(srv->fmt);
|
||||
/* free srv->evdnsBase */
|
||||
evdns_base_free(srv->evdnsBase,0);
|
||||
free(srv);
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Finish with event base */
|
||||
if( event_base_loopexit(config->event_base,NULL) < 0)
|
||||
error("abortion of event base failed !");
|
||||
|
||||
event_base_free(config->event_base);
|
||||
g_free(config);
|
||||
cache_destroy();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void sig_handler(int signum)
|
||||
{
|
||||
error("In cleanup function !");
|
||||
free_config();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int initialize_servers(char *value)
|
||||
{
|
||||
char **ptr, **ptrr;
|
||||
int nb_srv = 0, i = 0;
|
||||
|
||||
ptr = ptrr = g_strsplit(value, ",", 30);
|
||||
|
||||
while (*(ptrr++))
|
||||
nb_srv++;
|
||||
|
||||
notice("Configuring %d servers...", nb_srv);
|
||||
config->servers = g_new0(struct dnsbl_server_t *,nb_srv + 1);
|
||||
|
||||
ptrr = ptr;
|
||||
while (ptrr && *ptrr) {
|
||||
char *tmp = "%d.%d.%d.%d.";
|
||||
struct dnsbl_server_t *s;
|
||||
g_strstrip(*ptrr);
|
||||
s = config->servers[i] = g_malloc(sizeof(struct dnsbl_server_t));
|
||||
s->name = g_strdup(*ptrr);
|
||||
s->fmt = g_malloc(strlen(s->name) + strlen(tmp) + 1);
|
||||
g_sprintf(s->fmt, "%s%s", tmp, s->name);
|
||||
s->evdnsBase = NULL;
|
||||
if (config_dnsbl_server(s, config->event_base) < 0) {
|
||||
warning("NS record can't be found, server %s ignored !", s->name);
|
||||
g_free(s->fmt);
|
||||
g_free(s->name);
|
||||
g_free(s);
|
||||
} else {
|
||||
message("%s OK.", s->name);
|
||||
|
||||
i++;
|
||||
}
|
||||
ptrr++;
|
||||
}
|
||||
config->servers[i] = 0;
|
||||
config->nb_srv = i;
|
||||
notice("%d/%d DNSBL servers configured.", config->nb_srv, nb_srv);
|
||||
g_strfreev(ptr);
|
||||
return (config->nb_srv);
|
||||
}
|
||||
|
||||
void configure_logging(char *logging)
|
||||
{
|
||||
char **log;
|
||||
log = g_strsplit(logging, ":", 2);
|
||||
if (!strcmp(log[0], "syslog") && log[1]) {
|
||||
int facility;
|
||||
facility = resolve_facility(log[1]);
|
||||
if (facility < 0) {
|
||||
error("syslog facility %s isn't supported: \
|
||||
choose between mail/daemon/syslog or \
|
||||
local0 to local7", log[1]);
|
||||
exit(0);
|
||||
}
|
||||
message("Logging to syslog (facility %s)\n", log[1]);
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
openlog("ospow-dnsbl-proxy", LOG_PID, facility);
|
||||
config->logger = log2syslog;
|
||||
} else {
|
||||
message("Other logging than syslog not supported yet logging to console.");
|
||||
config->logger = log2stdout;
|
||||
|
||||
}
|
||||
free(log);
|
||||
}
|
||||
|
||||
void config_init(const char *path)
|
||||
{
|
||||
GKeyFile *kfile =NULL;
|
||||
gchar **keys = NULL;
|
||||
struct sockaddr_in sa;
|
||||
struct passwd *nobody;
|
||||
struct timeval tv;
|
||||
int i, ii = 0;
|
||||
|
||||
config = g_new0(struct config_t, 1);
|
||||
/* Set defaults that differs from NULL/0 ... */
|
||||
config->timeout = 1;
|
||||
/* We set this temporary, to get logs ... */
|
||||
config->logger = log2stdout;
|
||||
config->logging = "syslog:daemon";
|
||||
config->cache_timeout = 3600;
|
||||
config->port = 53;
|
||||
config->loglevel = G_LOG_LEVEL_INFO;
|
||||
|
||||
/* Parse our files */
|
||||
kfile = g_key_file_new();
|
||||
debug("Parsing %s", path);
|
||||
/* Load file */
|
||||
if (!g_key_file_load_from_file(kfile, path, G_KEY_FILE_NONE, NULL)) {
|
||||
error("Error while loading %s, is it a correct .ini file ?", path);
|
||||
goto cleanExit;
|
||||
}
|
||||
/* Check if general section is available */
|
||||
if (!g_key_file_has_group(kfile, "general")) {
|
||||
error("%s doesn't have [general] section, skipping ...", path);
|
||||
goto cleanExit;
|
||||
}
|
||||
/* Retrieve all keys ... */
|
||||
if (!(keys = g_key_file_get_keys(kfile, "general", NULL, NULL))) {
|
||||
error("Failed to load keys from %s", path);
|
||||
goto cleanExit;
|
||||
}
|
||||
/* Now, read the conf and store important parts */
|
||||
while (keys[ii]) {
|
||||
char *value;
|
||||
value = g_key_file_get_value(kfile, "general", keys[ii], NULL);
|
||||
if (!strcmp(keys[ii], "log"))
|
||||
config->logging = g_strdup(value);
|
||||
|
||||
/* Parse Timeout */
|
||||
else if (!strcmp(keys[ii], "timeout")) {
|
||||
config->timeout = atoi(value);
|
||||
debug("timeout is %d sec", config->timeout);
|
||||
}
|
||||
/* Parse Cache Timeout */
|
||||
else if (!strcmp(keys[ii], "cache_timeout")) {
|
||||
config->cache_timeout = atof(value);
|
||||
debug("cache timeout is %d sec", config->cache_timeout);
|
||||
|
||||
}
|
||||
/* Parse Zone */
|
||||
else if (!strcmp(keys[ii], "zone")) {
|
||||
char *begin = "(\\d{0,3}).(\\d{0,3}).(\\d{0,3}).(\\d{0,3}).";
|
||||
gchar *pattern;
|
||||
config->zone = g_strdup(value);
|
||||
pattern = g_malloc(strlen(begin) + strlen(config->zone) + 3);
|
||||
g_sprintf(pattern, "^%s%s$", begin, config->zone);
|
||||
debug("Pattern for zone is %s", pattern);
|
||||
config->zone_regex = g_regex_new(pattern, G_REGEX_CASELESS, 0, NULL);
|
||||
g_free(pattern);
|
||||
}
|
||||
/* Debug mode ?? */
|
||||
else if (!strcmp(keys[ii], "debug")) {
|
||||
config->debug = atoi(value);
|
||||
}
|
||||
/* Server list... we'll parse later ! */
|
||||
else if (!strcmp(keys[ii], "server_list")) {
|
||||
config->server_list = g_strdup(value);
|
||||
}
|
||||
/* UDP port to listen to ... */
|
||||
else if (!strcmp(keys[ii], "port")) {
|
||||
config->port = atoi(value);
|
||||
if (config->port < 0 || config->port > 65535)
|
||||
error("%d isn't a valid UDP port number.", config->port);
|
||||
} else if (!strcmp(keys[ii], "loglevel")) {
|
||||
if (!strcmp("ERROR", value)) {
|
||||
config->loglevel = LOG_ERR;
|
||||
} else if (!strcmp("WARNING", value)) {
|
||||
config->loglevel = LOG_WARNING;
|
||||
} else if (!strcmp("NOTICE", value)) {
|
||||
config->loglevel = LOG_NOTICE;
|
||||
} else if (!strcmp("INFO", value)) {
|
||||
config->loglevel = LOG_INFO;
|
||||
} else if (!strcmp("DEBUG", value)) {
|
||||
config->loglevel = LOG_DEBUG;
|
||||
|
||||
} else {
|
||||
error("Loglevel %s not supported, choose (verbosity increasing) ERROR, WARNING, NOTICE, INFO or DEBUG",
|
||||
value);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
message("Logging to level %s", value);
|
||||
}
|
||||
ii++;
|
||||
g_key_file_remove_key(kfile,"general",keys[ii],NULL);
|
||||
g_free(value);
|
||||
}
|
||||
g_key_file_remove_group(kfile,"general",NULL);
|
||||
g_strfreev(keys);
|
||||
g_key_file_free(kfile);
|
||||
|
||||
|
||||
/* Binding signal */
|
||||
signal(SIGSTOP,sig_handler);
|
||||
signal(SIGTERM,sig_handler);
|
||||
signal(SIGINT,sig_handler);
|
||||
|
||||
/* If we aren't in mode debug, daemonize */
|
||||
if (!config->debug) {
|
||||
int pid;
|
||||
/* First, change working dir */
|
||||
if (chdir("/") < 0)
|
||||
error("Failed while chdir()-ing: %s", strerror(errno));
|
||||
/* The fork() and setsid() */
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
error("Failed while fork()-ing ... ");
|
||||
else if (pid > 0) {
|
||||
exit(0);
|
||||
}
|
||||
/* We're in child */
|
||||
if (setsid() < 0)
|
||||
error("Failed while setsid()-ing ... ");
|
||||
/* Configure logging ... */
|
||||
configure_logging(config->logging);
|
||||
event_set_log_callback(logevent_logger);
|
||||
evdns_set_log_fn(logevent_logger);
|
||||
}else{
|
||||
notice("Skipping daemonization process (debug mode activated)");
|
||||
}
|
||||
/* Create event base */
|
||||
if (!(config->event_base = event_base_new()))
|
||||
error("Failed while creating event base, fatal !");
|
||||
|
||||
/* Now we initialize servers */
|
||||
if (initialize_servers(config->server_list) < 0)
|
||||
error("We don't have any working DNSBL server configured (all of them failed) ... exiting !");
|
||||
|
||||
/* Here we must have timeout and servers list set , so we can now set timeout on evdns_base */
|
||||
for (i = 0; i < config->nb_srv; i++) {
|
||||
char timeout[256];
|
||||
g_snprintf(timeout, 255, "%i", config->timeout);
|
||||
evdns_base_set_option(config->servers[i]->evdnsBase, "timeout", timeout);
|
||||
evdns_base_set_option(config->servers[i]->evdnsBase, "initial-probe-timeout", timeout);
|
||||
evdns_base_set_option(config->servers[i]->evdnsBase, "max-timeouts:", "1");
|
||||
}
|
||||
|
||||
/* Open UDP port, bind it and give it to libevent */
|
||||
if ((config->s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
fatal("Failed to create socket: %s", strerror(errno));
|
||||
}
|
||||
evutil_make_socket_nonblocking(config->s);
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons(config->port);
|
||||
sa.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind(config->s, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
|
||||
fatal("Failed to bind socket: %s", strerror(errno));
|
||||
}
|
||||
evdns_add_server_port_with_base(config->event_base, config->s, 0, dns_server_callback, NULL);
|
||||
|
||||
/* Add a timer for cache cleanup */
|
||||
config->timer_ev = event_new(config->event_base, -1, EV_PERSIST, (event_callback_fn) cache_cleanup, NULL);
|
||||
tv.tv_sec = config->cache_timeout;
|
||||
tv.tv_usec = 0;
|
||||
evtimer_add(config->timer_ev, &tv);
|
||||
/* Change user, security, security ... */
|
||||
if (config->debug == 0) {
|
||||
if (!(nobody = getpwnam("nobody"))) {
|
||||
fatal("User nobody doesn't exist, can't set{e,}uid() ! Fatal !");
|
||||
}
|
||||
if (!setegid(nobody->pw_gid) && !seteuid(nobody->pw_uid)) {
|
||||
message("Successfuly changed user to nobody");
|
||||
} else {
|
||||
fatal("Failed changing user to nobody, fatal");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
notice("DNSBL Proxy successfully launched !");
|
||||
return;
|
||||
cleanExit:
|
||||
exit(0);
|
||||
}
|
||||
6
src/config.h
Normal file
6
src/config.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef OSPOW_CONFIG_H
|
||||
#define OSPOW_CONFIG_H
|
||||
|
||||
struct config_t *config;
|
||||
|
||||
#endif
|
||||
273
src/dns.c
Normal file
273
src/dns.c
Normal file
@@ -0,0 +1,273 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#include <event2/event-config.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/dns_struct.h>
|
||||
#include <event2/dns.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "tools.h"
|
||||
|
||||
GSList *questions;
|
||||
|
||||
long int localhost = 0x0100007F;
|
||||
|
||||
float get_timespent(struct timespec b, struct timespec e)
|
||||
{
|
||||
float ret = 0;
|
||||
#ifdef TIMEMEASURE
|
||||
int tmp;
|
||||
|
||||
ret = (e.tv_nsec * .000001) - (b.tv_nsec * .000001);
|
||||
|
||||
tmp = (int)(e.tv_sec - b.tv_sec) * 1000;
|
||||
|
||||
|
||||
ret += tmp;
|
||||
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
int send_answer(struct evdns_server_request *r, int ret, void *value, struct timespec *timestamp)
|
||||
{
|
||||
struct timespec end;
|
||||
/* TTL hardcoded to 10 */
|
||||
if (value) {
|
||||
if (r->questions[0]->type == EVDNS_TYPE_A)
|
||||
evdns_server_request_add_a_reply(r, r->questions[0]->name, 1, (int *)value, 10);
|
||||
else if (strcmp(value, "")) {
|
||||
char *tmp = g_strdup(value);
|
||||
char *tmp2 = tmp;
|
||||
|
||||
do {
|
||||
if (*tmp2 == '.')
|
||||
*tmp2 = '_';
|
||||
} while (*(++tmp2));
|
||||
|
||||
tmp2 = g_malloc(sizeof(char) * 63);
|
||||
snprintf(tmp2, 63, "dnsbl: %s", tmp);
|
||||
evdns_server_request_add_reply(r, EVDNS_ANSWER_SECTION, r->questions[0]->name, EVDNS_TYPE_TXT,
|
||||
EVDNS_CLASS_INET, 10, -1, 1, tmp2);
|
||||
g_free(tmp2);
|
||||
g_free(tmp);
|
||||
}
|
||||
}
|
||||
if (evdns_server_request_respond(r, ret) < 0)
|
||||
return (-1);
|
||||
if (timestamp) {
|
||||
#ifdef TIMEMEASURE
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
#endif
|
||||
debug("time elapse after sending response: %f", get_timespent(*timestamp, end));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void dns_question_callback(int result, char type, int count, int ttl, void *addresses, void *arg)
|
||||
{
|
||||
|
||||
struct pending_request_t *pr;
|
||||
struct dnsbl_server_t *srv;
|
||||
|
||||
struct cb_datas_t *cb_data;
|
||||
cb_data = (struct cb_datas_t *)arg;
|
||||
|
||||
pr = cb_data->req;
|
||||
srv = cb_data->srv;
|
||||
pr->pending_srv--;
|
||||
debug("%p %p %p %p\n",pr->client,pr->original_ip,pr->srv,pr);
|
||||
|
||||
switch (result) {
|
||||
case DNS_ERR_NONE:
|
||||
if (count > 0) {
|
||||
pr->listed = TRUE;
|
||||
debug("[%s] %s is listed by %s", pr->client, pr->original_ip, srv->name);
|
||||
pr->srv[pr->srv_idx] = srv->name;
|
||||
pr->srv_idx++;
|
||||
break;
|
||||
}
|
||||
case DNS_ERR_NOTEXIST:
|
||||
debug("[%s] %s is not listed by %s", pr->client, pr->original_ip, srv->name);
|
||||
break;
|
||||
default:
|
||||
notice("[%s] %s failed to resolv with %s [ret:%d|type:%d|count:%d|ttl:%d]",
|
||||
pr->client, pr->original_ip, srv->name, result, type, count, ttl);
|
||||
}
|
||||
|
||||
/* We aren't waiting for any result anymore, so let's answer and cache it ! */
|
||||
if (pr->pending_srv <= 0) {
|
||||
char status[255] = "not listed";
|
||||
void *tmp = NULL;
|
||||
char *name;
|
||||
int type = pr->r->questions[0]->type;
|
||||
int err = DNS_ERR_NONE;
|
||||
#ifdef TIMEMEASURE
|
||||
struct timespec end;
|
||||
#endif
|
||||
if (pr->listed) {
|
||||
if (pr->srv_idx <= 1) {
|
||||
g_strlcpy(status, pr->srv[0], 255);
|
||||
} else {
|
||||
char *tmp1;
|
||||
tmp1 = g_strjoinv("/", pr->srv);
|
||||
/* Max length for a TXT record is 255 bytes */
|
||||
g_snprintf(status, 254, "%s", tmp1);
|
||||
g_free(tmp1);
|
||||
}
|
||||
if (type == EVDNS_TYPE_TXT) {
|
||||
tmp = (void *)status;
|
||||
} else {
|
||||
tmp = &localhost;
|
||||
}
|
||||
} else {
|
||||
err = DNS_ERR_NOTEXIST;
|
||||
}
|
||||
/* Make answer authoritative */
|
||||
name = g_strdup(pr->r->questions[0]->name);
|
||||
/* Answer */
|
||||
#ifdef TIMEMEASURE
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
#endif
|
||||
if (send_answer(pr->r, err, tmp, &pr->timestamp) < 0)
|
||||
error("Got a pb while sending answer !");
|
||||
else
|
||||
#ifdef TIMEMEASURE
|
||||
message("[%s] response sent in %4fsec : %s is %s%s", pr->client,
|
||||
get_timespent(pr->timestamp, end),
|
||||
name, pr->listed ? "listed on " : "not listed", pr->listed ? status : "");
|
||||
#else
|
||||
message("[%s] response sent: %s is %s%s", pr->client,
|
||||
name, pr->listed ? "listed on " : "not listed", pr->listed ? status : "");
|
||||
#endif
|
||||
/* Then we cache */
|
||||
debug("[%s] Adding answer to cache", pr->client);
|
||||
set_cache_name(name, pr->listed, status);
|
||||
|
||||
debug("%p %p %p %p\n",pr->client,pr->original_ip,pr->srv,pr);
|
||||
g_free(pr->client);
|
||||
g_free(pr->original_ip);
|
||||
g_free(pr->srv);
|
||||
g_free(pr);
|
||||
}
|
||||
g_free(cb_data);
|
||||
}
|
||||
|
||||
void dns_server_callback(struct evdns_server_request *r, void *data)
|
||||
{
|
||||
int i;
|
||||
struct sockaddr_in client_sa;
|
||||
GMatchInfo *match = NULL;
|
||||
char *client = NULL;
|
||||
|
||||
/* Fetch client IP */
|
||||
evdns_server_request_get_requesting_addr(r, (struct sockaddr *)&client_sa, sizeof(struct sockaddr_in));
|
||||
client = g_strdup(inet_ntoa(client_sa.sin_addr));
|
||||
|
||||
/* Won't handle multiple questions this time ... */
|
||||
// for (i=0;i<r->nquestions;i++)
|
||||
i = 0;
|
||||
do {
|
||||
record_t *cache;
|
||||
int j = 0;
|
||||
unsigned char ip[4] = { 0, 0, 0, 0 };
|
||||
struct dnsbl_server_t **ptr;
|
||||
struct pending_request_t *req;
|
||||
|
||||
message("[%s] request for %s", client, r->questions[i]->name);
|
||||
|
||||
/* Send back error if request isn't A or TXT field */
|
||||
if (r->questions[i]->type != EVDNS_TYPE_A && r->questions[i]->type != EVDNS_TYPE_TXT) {
|
||||
debug("[%s] Request type not supported %d", client, r->questions[i]->type);
|
||||
goto error;
|
||||
}
|
||||
/* Is the name ever cached ? Serve as it if it is ! */
|
||||
cache = get_cached_name(r->questions[i]->name);
|
||||
if (cache) {
|
||||
message("[%s] request hit cache ( %s %s )", client, cache->listed ? "listed by" : "unlisted",
|
||||
cache->server);
|
||||
send_answer(r, cache->listed ? DNS_ERR_NONE : DNS_ERR_NOTEXIST,
|
||||
r->questions[i]->type == EVDNS_TYPE_A ? (void *)&localhost : (void *)cache->server,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Apply a "our served zone" regexp to r->questions[i]->name,
|
||||
* if it doesn't, send error */
|
||||
if (!g_regex_match(config->zone_regex, r->questions[i]->name, 0, &match)) {
|
||||
debug("[%s] Don't know what to do with name %s !", client, r->questions[i]->name);
|
||||
g_match_info_free(match);
|
||||
goto error;;
|
||||
}
|
||||
|
||||
/* Retrieve 4 bytes of queried IP adress */
|
||||
while (g_match_info_matches(match)) {
|
||||
for (j = 1; j <= 4; j++) {
|
||||
char *tmp;
|
||||
tmp = g_match_info_fetch(match, j);
|
||||
ip[j - 1] = atoi(tmp);
|
||||
g_free(tmp);
|
||||
}
|
||||
g_match_info_next(match, NULL);
|
||||
}
|
||||
g_match_info_free(match);
|
||||
|
||||
/* Building context struct to pass to callback */
|
||||
req = g_new0(struct pending_request_t,1);
|
||||
req->r = r;
|
||||
req->client = client;
|
||||
req->original_ip = g_new0(char,16);
|
||||
req->pending_srv = config->nb_srv;
|
||||
req->srv = g_new0(char *,config->nb_srv + 1);
|
||||
req->srv_idx = 0;
|
||||
req->listed = FALSE;
|
||||
debug("%p %p %p %p\n",req->client,req->original_ip,req->srv,req);
|
||||
g_snprintf(req->original_ip, 15, "%u.%u.%u.%u", ip[3], ip[2], ip[1], ip[0]);
|
||||
|
||||
#ifdef TIMEMEASURE
|
||||
clock_gettime(CLOCK_REALTIME, &(req->timestamp));
|
||||
#endif
|
||||
|
||||
message("[%s] Dispatching query %s for %s!", client,
|
||||
r->questions[i]->type == EVDNS_TYPE_TXT ? "TXT" : "A", req->original_ip);
|
||||
|
||||
/* Now, query this is on each dnsbl servers */
|
||||
ptr = config->servers;
|
||||
do {
|
||||
char *name;
|
||||
/* prepare datas for callback */
|
||||
struct cb_datas_t *datas;
|
||||
datas = g_malloc(sizeof(struct cb_datas_t));
|
||||
datas->req = req;
|
||||
datas->srv = *ptr;
|
||||
name = g_malloc(strlen((*ptr)->fmt) + 13);
|
||||
g_sprintf(name, (*ptr)->fmt, ip[0], ip[1], ip[2], ip[3]);
|
||||
evdns_base_resolve_ipv4((*ptr)->evdnsBase, name, DNS_QUERY_NO_SEARCH,
|
||||
dns_question_callback, datas);
|
||||
g_free(name);
|
||||
} while (*(++ptr));
|
||||
|
||||
} while (0); // Only one question ...
|
||||
return;
|
||||
error:
|
||||
g_free(match);
|
||||
if (evdns_server_request_respond(r, DNS_ERR_REFUSED) < 0)
|
||||
error("Failed sending response !");
|
||||
g_free(client);
|
||||
return;
|
||||
}
|
||||
3
src/dns.h
Normal file
3
src/dns.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
void dns_question_callback(int result,char type, int count, int ttl, void *addresses, void *arg);
|
||||
void dns_server_callback(struct evdns_server_request *r, void *data);
|
||||
53
src/main.c
Normal file
53
src/main.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <event2/event-config.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/event_struct.h>
|
||||
#include <event2/dns_struct.h>
|
||||
#include <event2/dns.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "tools.h"
|
||||
#include "dns.h"
|
||||
|
||||
int sighandler(int signum, void *a)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* _ Implement signal catching to stop server
|
||||
* _ Implement pidfile.
|
||||
* _
|
||||
*/
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
if (ac == 2)
|
||||
config_init(av[1]);
|
||||
else
|
||||
config_init("/etc/ospow/dnsbl-proxy.conf");
|
||||
|
||||
cache_init(config->cache_timeout);
|
||||
|
||||
/* Set logging callback */
|
||||
//event_set_log_callback(logevent_logger);
|
||||
event_base_dispatch(config->event_base);
|
||||
|
||||
/* Ending ... */
|
||||
message("Event loop stopped ... exiting !");
|
||||
cache_destroy();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
BIN
src/test-tools
Executable file
BIN
src/test-tools
Executable file
Binary file not shown.
71
src/tests.c
Normal file
71
src/tests.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
#include <event2/event-config.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/event_struct.h>
|
||||
#include <event2/dns_struct.h>
|
||||
#include <event2/dns.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "tools.h"
|
||||
#include "dns.h"
|
||||
|
||||
|
||||
int test_cache()
|
||||
{
|
||||
struct timeval timeout;
|
||||
printf("Test cache");
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
cache_init(&timeout);
|
||||
debug("t = 0\n");
|
||||
set_cache_name("Test 1", TRUE, "test.org");
|
||||
set_cache_name("Test 2", FALSE, NULL);
|
||||
set_cache_name("Test 3", TRUE, "google.fr");
|
||||
cache_dump();
|
||||
sleep(3);
|
||||
debug("t = 3\n");
|
||||
set_cache_name("Test 4", FALSE, NULL);
|
||||
set_cache_name("Test 5", FALSE, NULL);
|
||||
sleep(2);
|
||||
debug("t = 5\n");
|
||||
cache_cleanup();
|
||||
cache_dump();
|
||||
sleep(10);
|
||||
debug("t = 15\n");
|
||||
cache_cleanup();
|
||||
cache_dump();
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_config()
|
||||
{
|
||||
debug("%d debug", G_LOG_LEVEL_DEBUG);
|
||||
message("%d info", G_LOG_LEVEL_INFO);
|
||||
error("%d error", G_LOG_LEVEL_ERROR);
|
||||
config_init("/etc/ospow/dnsbl-proxy.conf");
|
||||
debug("%d debug", G_LOG_LEVEL_DEBUG);
|
||||
message("%d info", G_LOG_LEVEL_INFO);
|
||||
error("%d error", G_LOG_LEVEL_ERROR);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
printf("taille d'1 enregistrement %d\n", sizeof(record_t));
|
||||
test_config();
|
||||
test_cache();
|
||||
}
|
||||
328
src/tools.c
Normal file
328
src/tools.c
Normal file
@@ -0,0 +1,328 @@
|
||||
#define _BSD_SOURCE
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <event2/event-config.h>
|
||||
#include <event2/event.h>
|
||||
#include <event2/dns.h>
|
||||
#include <event2/dns_struct.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define rdata_to_long(rdata) do { } while(0);
|
||||
|
||||
/* Taken "as is" from syslog.h */
|
||||
#define INTERNAL_NOPRI 0x10
|
||||
|
||||
|
||||
#ifndef TEST
|
||||
extern struct config_t *config;
|
||||
#endif
|
||||
|
||||
typedef struct _code {
|
||||
char *c_name;
|
||||
int c_val;
|
||||
} CODE;
|
||||
|
||||
CODE prioritynames[] =
|
||||
{
|
||||
{ "alert", LOG_ALERT },
|
||||
{ "crit", LOG_CRIT },
|
||||
{ "debug", LOG_DEBUG },
|
||||
{ "emerg", LOG_EMERG },
|
||||
{ "err", LOG_ERR },
|
||||
{ "error", LOG_ERR }, /* DEPRECATED */
|
||||
{ "info", LOG_INFO },
|
||||
{ "none", INTERNAL_NOPRI }, /* INTERNAL */
|
||||
{ "notice", LOG_NOTICE },
|
||||
{ "panic", LOG_EMERG }, /* DEPRECATED */
|
||||
{ "warn", LOG_WARNING }, /* DEPRECATED */
|
||||
{ "warning", LOG_WARNING },
|
||||
{ NULL, -1 }
|
||||
};
|
||||
|
||||
int resolve_facility(char *facility)
|
||||
{
|
||||
GString *string = g_string_new(facility);
|
||||
g_string_ascii_down(string);
|
||||
char *f = (char *)string->str;
|
||||
if (!strcmp("mail", f))
|
||||
return LOG_MAIL;
|
||||
if (!strcmp("daemon", f))
|
||||
return LOG_DAEMON;
|
||||
if (!strcmp("syslog", f))
|
||||
return LOG_SYSLOG;
|
||||
if (!strcmp("local0", f))
|
||||
return LOG_LOCAL0;
|
||||
if (!strcmp("local1", f))
|
||||
return LOG_LOCAL1;
|
||||
if (!strcmp("local2", f))
|
||||
return LOG_LOCAL2;
|
||||
if (!strcmp("local3", f))
|
||||
return LOG_LOCAL3;
|
||||
if (!strcmp("local4", f))
|
||||
return LOG_LOCAL4;
|
||||
if (!strcmp("local5", f))
|
||||
return LOG_LOCAL5;
|
||||
if (!strcmp("local6", f))
|
||||
return LOG_LOCAL6;
|
||||
if (!strcmp("local7", f))
|
||||
return LOG_LOCAL7;
|
||||
g_string_free(string, TRUE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void logevent_logger(int severity, const char *msg)
|
||||
{
|
||||
debug("libevent(%d): %s", severity, msg);
|
||||
}
|
||||
|
||||
|
||||
void log2stdout(int severity, const char *fmt, va_list list)
|
||||
{
|
||||
char *fmt2;
|
||||
int i=0;
|
||||
CODE *sname;
|
||||
|
||||
sname = prioritynames;
|
||||
while(sname[i].c_val != severity)
|
||||
i++;
|
||||
fmt2 = malloc(sizeof(char) * (strlen(fmt) + 50));
|
||||
sprintf(fmt2,"[%s] %s\n",
|
||||
sname[i].c_name ? sname[i].c_name : "UNKNOWN",
|
||||
fmt);
|
||||
|
||||
vprintf(fmt2,list);
|
||||
free(fmt2);
|
||||
}
|
||||
|
||||
void log2syslog(int severity, const char *fmt, va_list list)
|
||||
{
|
||||
vsyslog(severity,fmt,list);
|
||||
}
|
||||
|
||||
void dns_log(int severity, const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
#ifndef TEST
|
||||
if (!config->loglevel || severity > config->loglevel)
|
||||
goto end;
|
||||
if (config->logger)
|
||||
config->logger(severity,fmt,list);
|
||||
else
|
||||
#endif
|
||||
log2stdout(severity,fmt,list);
|
||||
end:
|
||||
va_end(list);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct sockaddr_in **get_domain_ns_fallback(char *domain)
|
||||
{
|
||||
unsigned char answer[8192];
|
||||
struct sockaddr_in **ns = NULL;
|
||||
int ii, i = 0, j = 0, ret = 0, nb_servers = 0;
|
||||
|
||||
ns_msg parser;
|
||||
ns_rr rr;
|
||||
|
||||
|
||||
debug("In %s(%s)", __FUNCTION__, domain);
|
||||
|
||||
ret = res_query(domain, C_IN, T_A, answer, 8192);
|
||||
if (ret < 0) {
|
||||
debug(" Got no result for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (ns_initparse(answer, ret, &parser) < 0) {
|
||||
debug(" Failed to ns_initparse() for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 3; ii++) {
|
||||
ret = ns_msg_count(parser, ns_s_an);
|
||||
if (ret < 0) {
|
||||
debug(" Failed to ns_msg_count() for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* We limit to 5 servers ... */
|
||||
debug(" Got %d records", ret);
|
||||
nb_servers = (ret > 5) ? 5 : ret;
|
||||
ns = calloc(nb_servers + 1, sizeof(struct sockaddr *));
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < nb_servers; i++) {
|
||||
char rName[MAXDNAME];
|
||||
|
||||
ns_parserr(&parser, ns_s_an, i, &rr);
|
||||
debug(" ns_rr_type is %d", ns_rr_type(rr));
|
||||
if (ns_rr_type(rr) == ns_t_ns) {
|
||||
if (ns_name_uncompress(ns_msg_base(parser), ns_msg_end(parser),
|
||||
ns_rr_rdata(rr), rName, MAXDNAME) >= 0) {
|
||||
/* Code below seems to create problem in a static binary :( */
|
||||
int rv;
|
||||
struct addrinfo *r;
|
||||
struct addrinfo hint;
|
||||
hint.ai_family = AF_INET;
|
||||
hint.ai_socktype = SOCK_DGRAM;
|
||||
hint.ai_protocol = 0;
|
||||
hint.ai_flags = AI_NUMERICSERV;
|
||||
/* XXX: Here, an array may be returned (Round Robin, ...) but we only deal with first element */
|
||||
if (!(rv = getaddrinfo(rName, "53", &hint, &r))) {
|
||||
struct sockaddr_in *addr;
|
||||
addr = (struct sockaddr_in *)r->ai_addr;
|
||||
ns[j] = malloc(sizeof(struct sockaddr_in));
|
||||
memcpy(ns[j], addr, sizeof(struct sockaddr_in));
|
||||
debug(" addr is %s", inet_ntoa(ns[j]->sin_addr));
|
||||
j++;
|
||||
freeaddrinfo(r);
|
||||
} else {
|
||||
debug("error while resolving %s : %s\n", rName, gai_strerror(rv));
|
||||
}
|
||||
}
|
||||
} else if (ns_rr_type(rr) == ns_t_a) {
|
||||
struct in_addr tmp;
|
||||
memcpy(&(tmp.s_addr), ns_rr_rdata(rr), ns_rr_rdlen(rr));
|
||||
debug(" addr is %s", inet_ntoa(tmp));
|
||||
|
||||
}
|
||||
}
|
||||
ns[j] = 0;
|
||||
}
|
||||
return (ns);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: review this code.
|
||||
*/
|
||||
struct sockaddr_in **get_domain_ns(char *domain)
|
||||
{
|
||||
unsigned char answer[81920];
|
||||
struct sockaddr_in **ns = NULL;
|
||||
int i = 0, j = 0, ret = 0, nb_servers = 0;
|
||||
|
||||
ns_msg parser;
|
||||
ns_rr rr;
|
||||
|
||||
res_init();
|
||||
|
||||
ret = res_query(domain, C_IN, T_NS, answer, 81920);
|
||||
if (ret < 0) {
|
||||
debug(" Got no result for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (ns_initparse(answer, ret, &parser) < 0) {
|
||||
debug(" Failed to ns_initparse() for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = ns_msg_count(parser, ns_s_an);
|
||||
if (ret < 0) {
|
||||
debug(" Failed to ns_msg_count() for %s", domain);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* We limit to 5 servers ... */
|
||||
debug(" Got %d records", ret);
|
||||
nb_servers = (ret > 5) ? 5 : ret;
|
||||
ns = calloc(nb_servers + 1, sizeof(struct sockaddr *));
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < nb_servers; i++) {
|
||||
char rName[MAXDNAME];
|
||||
|
||||
ns_parserr(&parser, ns_s_an, i, &rr);
|
||||
if (ns_rr_type(rr) == ns_t_ns) {
|
||||
if (ns_name_uncompress(ns_msg_base(parser), ns_msg_end(parser),
|
||||
ns_rr_rdata(rr), rName, MAXDNAME) >= 0) {
|
||||
/* Code below seems to create problem in a static binary :( */
|
||||
int rv;
|
||||
struct addrinfo *r;
|
||||
struct addrinfo hint;
|
||||
hint.ai_family = AF_INET;
|
||||
hint.ai_socktype = SOCK_DGRAM;
|
||||
hint.ai_protocol = 0;
|
||||
hint.ai_flags = AI_NUMERICSERV;
|
||||
/* XXX: Here, an array may be returned (Round Robin, ...) but we only deal with first element */
|
||||
if (!(rv = getaddrinfo(rName, "53", &hint, &r))) {
|
||||
struct sockaddr_in *addr;
|
||||
addr = (struct sockaddr_in *)r->ai_addr;
|
||||
ns[j] = malloc(sizeof(struct sockaddr_in));
|
||||
memcpy(ns[j], addr, sizeof(struct sockaddr_in));
|
||||
debug(" addr is %s", inet_ntoa(ns[j]->sin_addr));
|
||||
j++;
|
||||
freeaddrinfo(r);
|
||||
} else {
|
||||
debug(" error while resolving %s : %s\n", rName, gai_strerror(rv));
|
||||
}
|
||||
} else {
|
||||
debug(" ns_name_uncompres() failed");
|
||||
}
|
||||
|
||||
} else {
|
||||
debug("ns record isn't in good type");
|
||||
}
|
||||
}
|
||||
ns[j] = 0;
|
||||
return (ns);
|
||||
}
|
||||
|
||||
int config_dnsbl_server(struct dnsbl_server_t *s, struct event_base *base)
|
||||
{
|
||||
struct sockaddr_in **nameservers, **ptr;
|
||||
|
||||
ptr = nameservers = get_domain_ns(s->name);
|
||||
if (!nameservers || !(*nameservers)) {
|
||||
debug(" Failed while configuring %s.", s->name);
|
||||
return (-1);
|
||||
}
|
||||
s->evdnsBase = evdns_base_new(base, 0);
|
||||
evdns_base_search_clear(s->evdnsBase);
|
||||
while (ptr && *ptr) {
|
||||
if (!
|
||||
(evdns_base_nameserver_sockaddr_add
|
||||
(s->evdnsBase, (const struct sockaddr *)*ptr, sizeof(struct sockaddr_in), 0))) {
|
||||
debug(" registered %s successfuly.", inet_ntoa((*ptr)->sin_addr));
|
||||
} else {
|
||||
debug(" failed to register %s.", inet_ntoa((*ptr)->sin_addr));
|
||||
}
|
||||
free(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
free(nameservers);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef TEST_TOOLS
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
if (ac == 2) {
|
||||
message("Resolving %s", av[1]);
|
||||
get_domain_ns(av[1]);
|
||||
get_domain_ns_fallback(av[1]);
|
||||
} else {
|
||||
printf("usage: %s <domain>", av[0]);
|
||||
}
|
||||
return (0);
|
||||
|
||||
}
|
||||
#endif
|
||||
36
src/tools.h
Normal file
36
src/tools.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef OSPOW_TOOL_H
|
||||
#define OSPOW_TOOL_H
|
||||
|
||||
void config_init(const char *path);
|
||||
|
||||
|
||||
struct sockaddr_in **get_domain_ns(char *domain);
|
||||
int config_dnsbl_server(struct dnsbl_server_t *s, struct event_base *base);
|
||||
|
||||
void logevent_logger(int severity, const char *msg);
|
||||
void dns_log(int severity, const char *fmt, ...);
|
||||
int resolve_facility(char *facility);
|
||||
void log2stdout(int severity, const char *fmt, va_list list);
|
||||
void log2syslog(int severity, const char *fmt, va_list list);
|
||||
|
||||
record_t *get_cached_name(const char *name);
|
||||
void cache_cleanup(struct event *);
|
||||
void set_cache_name(char *name, gboolean listed, char *server);
|
||||
void cache_init(time_t timeout);
|
||||
void cache_destroy();
|
||||
|
||||
|
||||
float get_timespent(struct timespec b, struct timespec e);
|
||||
int send_answer(struct evdns_server_request *r, int ret, void *value, struct timespec *timestamp);
|
||||
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
#define message(fmt, ...) dns_log(LOG_INFO, fmt, ##__VA_ARGS__)
|
||||
#define notice(fmt, ...) dns_log(LOG_NOTICE, fmt, ##__VA_ARGS__)
|
||||
#define warning(fmt, ...) dns_log(LOG_WARNING, fmt, ##__VA_ARGS__)
|
||||
#define error(fmt, ...) dns_log(LOG_ERR, fmt, ##__VA_ARGS__)
|
||||
#define fatal(fmt, ...) do { dns_log(LOG_ERR, fmt, ##__VA_ARGS__); exit(EXIT_FAILURE); }while(0)
|
||||
#define debug(fmt, ...) dns_log(LOG_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
62
src/types.h
Normal file
62
src/types.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef OSPOW_TYPES_H
|
||||
#define OSPOW_TYPES_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *server;
|
||||
gboolean listed;
|
||||
time_t ctime;
|
||||
} record_t;
|
||||
|
||||
struct dnsbl_server_t {
|
||||
char *name;
|
||||
char *fmt;
|
||||
struct evdns_base *evdnsBase;
|
||||
} dnsbl_server_t;
|
||||
|
||||
struct config_t {
|
||||
int s;
|
||||
int port;
|
||||
struct event_base *event_base;
|
||||
struct event *timer_ev;
|
||||
char *zone;
|
||||
GRegex *zone_regex;
|
||||
char *logging;
|
||||
void (*logger) (int, const char *, va_list);
|
||||
int timeout;
|
||||
time_t cache_timeout;
|
||||
int nb_srv;
|
||||
int loglevel;
|
||||
char *server_list;
|
||||
struct dnsbl_server_t **servers;
|
||||
short debug;
|
||||
} config_t;
|
||||
|
||||
struct result_t {
|
||||
struct dnsbl_server_t *server;
|
||||
gboolean listed;
|
||||
} result_t;
|
||||
|
||||
struct pending_request_t {
|
||||
struct evdns_server_request *r;
|
||||
char *client;
|
||||
char *original_ip;
|
||||
int pending_srv;
|
||||
gboolean listed;
|
||||
char **srv;
|
||||
int srv_idx;
|
||||
struct timespec timestamp;
|
||||
char msg[255];
|
||||
} pending_request_t;
|
||||
|
||||
struct cb_datas_t {
|
||||
struct pending_request_t *req;
|
||||
struct dnsbl_server_t *srv;
|
||||
} cb_datas_t;
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user