Skip to content

Commit

Permalink
Merge pull request #110 from jelu/backend
Browse files Browse the repository at this point in the history
Backends
  • Loading branch information
jelu committed Apr 11, 2018
2 parents e2878f5 + e96a9f9 commit 9048bec
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 157 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ACLOCAL_AMFLAGS = -I m4

MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
$(srcdir)/configure
$(srcdir)/configure

SUBDIRS = src

Expand Down
10 changes: 5 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
# POSSIBILITY OF SUCH DAMAGE.

AC_PREREQ(2.61)
AC_INIT([drool], [2.0.0], [admin@dns-oarc.net], [drool], [https://github.com/DNS-OARC/drool/issues])
AC_INIT([drool], [1.99.0], [admin@dns-oarc.net], [drool], [https://github.com/DNS-OARC/drool/issues])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([src/main.lua])
AC_CONFIG_MACRO_DIR([m4])

# Checks for programs.
AC_PATH_PROG([DNSJIT],[dnsjit])
if test "x$ac_cv_path_DNSJIT" = "x"; then
AC_MSG_ERROR([dnsjit was not found])
AC_MSG_ERROR([dnsjit was not found])
fi

# Output Makefiles
AC_CONFIG_FILES([
Makefile
src/Makefile
src/test/Makefile
Makefile
src/Makefile
src/test/Makefile
])
AC_OUTPUT
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
drool (1.99.0-1.~unstable+1) unstable; urgency=low

* Release 1.99.0

Alpha version using dnsjit.

-- Jerry Lundström <lundstrom.jerry@gmail.com> Wed, 11 Apr 2018 16:00:14 +0200

drool (1.1.0-1~unstable+1) unstable; urgency=low

* Release 1.1.0
Expand Down
7 changes: 5 additions & 2 deletions rpm/drool.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: drool
Version: 1.1.0
Release: 1%{?dist}
Version: 1.99.0
Release: 1.%{?dist}
Summary: DNS Replay Tool
Group: Productivity/Networking/DNS/Utilities

Expand Down Expand Up @@ -49,6 +49,9 @@ rm -rf $RPM_BUILD_ROOT


%changelog
* Wed Apr 11 2018 Jerry Lundström <lundstrom.jerry@gmail.com> 1.99.0-1.
- Release 1.99.0
* Alpha version using dnsjit
* Fri Feb 16 2018 Jerry Lundström <lundstrom.jerry@gmail.com> 1.1.0-1
- Release 1.1.0
* Rework of the timing code to make it more effective, based on
Expand Down
41 changes: 19 additions & 22 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,38 @@
# POSSIBILITY OF SUCH DAMAGE.

MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
CLEANFILES = head.lua drool drool.1 drool.conf.5
CLEANFILES = drool drool.1 drool.conf.5

SUBDIRS = test

EXTRA_DIST = drool.1.in \
drool.conf.5.in \
drool.conf.example \
head.lua.in conf.lua getopt.lua log.lua run.lua main.lua
EXTRA_DIST = drool.in \
drool.1.in \
drool.conf.5.in \
drool.conf.example

bin_SCRIPTS = drool

SOURCES = head.lua conf.lua getopt.lua log.lua run.lua main.lua
dist_pkgdata_DATA = conf.lua log.lua run.lua main.lua

man1_MANS = drool.1
man5_MANS = drool.conf.5

drool: $(SOURCES)
for file in $(SOURCES); do test -f "$$file" && cat "$$file" || cat "$(srcdir)/$$file"; done > drool
chmod +x drool

head.lua: head.lua.in Makefile
drool: drool.in Makefile
sed -e 's,[@]PACKAGE_NAME[@],$(PACKAGE_NAME),g' \
-e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
< "$(srcdir)/head.lua.in" > head.lua
-e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
< "$(srcdir)/drool.in" > drool
chmod +x drool

drool.1: drool.1.in Makefile
sed -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
< "$(srcdir)/drool.1.in" > drool.1
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
< "$(srcdir)/drool.1.in" > drool.1

drool.conf.5: drool.conf.5.in Makefile
sed -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
< "$(srcdir)/drool.conf.5.in" > drool.conf.5
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
< "$(srcdir)/drool.conf.5.in" > drool.conf.5
25 changes: 25 additions & 0 deletions src/conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,28 @@ conf:func("client_pool", function(_, option, arg1, arg2)
L:fatal("unknown client_pool option: %s", option)
end
end)
conf:func("backend", function(_, section, module)
if section == "input" then
if module == "pcapthread" then
backend.input = "pcapthread"
elseif module == "fpcap" then
backend.input = "fpcap"
elseif module == "mmpcap" then
backend.input = "mmpcap"
elseif module == "pcap" then
backend.input = "pcap"
else
L:fatal("unknown backend input: %s", module)
end
elseif section == "output" then
if module == "cpool" then
backend.output = "cpool"
elseif module == "udpcli" then
backend.output = "udpcli"
else
L:fatal("unknown backend output: %s", module)
end
else
L:fatal("unknown backend section: %s", section)
end
end)
78 changes: 66 additions & 12 deletions src/drool.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ given to disable just that.
Can be given multiple times and will be processed in the given order.
See LOGGING for more information.
.TP
\fBbackend\fR SECTION MODULE ;
Set which backend module to use for each section.
See BACKEND for more information.
.TP
\fBread\fR " FILE " ;
Read packets from PCAP file, can be given multiple times.
Each \fBread\fR counts as a context and will use the given configuration
Expand Down Expand Up @@ -137,6 +141,9 @@ will use a TCP or UDP port depending on the traffic read/captured,
The total amount of ports used will be this value * number of \fIread\fR
and \fIinput\fR * \fBcontext client_pools\fR and it is advised to keep this
within the available ports/file descriptors for the running user.
If used together with backend
.I udpcli
then this will set the number of threads to use and run one client per thread.
.TP
\fBclient_pool\fR client_ttl SECONDS_AS_FLOAT ;
Set the time a client lives for, this is used to timeout clients in case
Expand Down Expand Up @@ -172,50 +179,97 @@ example:

The following logging facilities exists:
.TP
\fBcore\fR
.B core
Log messages about initializing, configuration and start up.
.TP
\fBinput\fR
.B input
Log messages about input related tasks.
.TP
\fBprocessing\fR
.B processing
Log messages about processing related tasks.
.TP
\fBnetwork\fR
.B network
Log messages about network related tasks.
.TP
\fBall\fR
.B all
Log messages for all facilities, this is only used to configure logging.
.LP
The following logging level exists for all facilities:
.TP
\fBdebug\fR
.B debug
Log messages about the very inner workings, use with caution since it
generates a lot of messages.
.TP
\fBinfo\fR
.B info
Log messages of the informational kind that may not be interesting in normal
operation.
.TP
\fBnotice\fR
.B notice
Log messages of the informational kind that may be interesting in normal
operation.
.TP
\fBwarning\fR
.B warning
Log message of the warning kind that indicates possible disruption in
operation.
.TP
\fBcritical\fR
.B critical
Log messages of the error kind that will most likely result in termination
of operation.
This log level can not be silenced.
.TP
\fBfatal\fR
.B fatal
Log messages of the critical kind that indicates termination of operation.
This log level can not be silenced.
.TP
\fBall\fR
.B all
Log messages for all levels, this is only used to configure logging.
.SH BACKEND
Following backend modules exists, note that some modules does not work with
each other and configuration options may not be available or mean different
things.
.SS SECTION: input
.TP
.B pcapthread
Default input that uses pcap-thread helper library to read from interfaces
and PCAP files.
.TP
.B fpcap
Read input from a PCAP file using standard library function
.B fopen()
and parse the PCAP without libpcap.
Following configuration options does not work:
.B filter
and
.BR timing .
.TP
.B mmpcap
Read input from a PCAP file by mapping the whole file to memory using
.B mmap()
and parse the PCAP without libpcap.
Following configuration options does not work:
.B filter
and
.BR timing .
.TP
.B pcap
Read input from an interface or PCAP file using libpcap.
Following configuration options does not work:
.B filter
and
.BR timing .
.SS SECTION: output
.TP
.B cpool
Send queries to a target by emulating clients (a client pool).
.TP
.B udpcli
Simple and dumb UDP DNS client.
Following configuration options does not work:
.B context
and all
.B client_pool
but
.BR max_clients .
.SH SEE ALSO
drool(1)
.SH AUTHORS
Expand Down
7 changes: 7 additions & 0 deletions src/drool.conf.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
log all;
nolog network debug;

#backend input pcapthread;
#backend input fpcap;
#backend input mmpcap;
#backend input pcap;
#backend output cpool;
#backend output udpcli;

filter "udp port 53";

timing ignore;
Expand Down
47 changes: 47 additions & 0 deletions src/getopt.lua → src/drool.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
#!/usr/bin/env dnsjit

log = require("dnsjit.core.log")
clock = require("dnsjit.lib.clock")
L = log.new("drool")
conf = require("dnsjit.lib.parseconf").new()
getopt = nil

files = {}
interfaces = {}
bpf = nil
client_pools = nil
host = nil
port = nil
max_clients = nil
client_ttl = nil
skip_reply = nil
max_reuse_clients = nil
sendas = nil
timing_mode = nil
timing_arg = nil
facility_log = {
input = {},
processing = {},
network = {},
}
read_iter = 1
read_mode = false
program = "@PACKAGE_NAME@"
version = "@PACKAGE_VERSION@"
package_url = "@PACKAGE_URL@"
pkgdatadir = "@pkgdatadir@"
backend = {
input = "pcapthread",
output = "cpool",
}

io.stderr:write("<< "..program.." v"..version.." "..package_url.." >>\n")

function args()
getopt = require("dnsjit.lib.getopt").new({
{ "c", nil, "", "", "?+" },
Expand All @@ -10,6 +49,7 @@ function args()
{ "n", nil, "", "", "?" },
{ "v", nil, 0, "", "?+" },
{ "V", nil, false, "", "?" },
{ nil, "pkgdatadir", pkgdatadir, "", "?" },
})
arg = getopt:parse()

Expand Down Expand Up @@ -61,3 +101,10 @@ function args()
os.exit(0)
end
end

args()
assert(loadfile(getopt:val("pkgdatadir").."/conf.lua"))()
assert(loadfile(getopt:val("pkgdatadir").."/log.lua"))()
assert(loadfile(getopt:val("pkgdatadir").."/run.lua"))()
assert(loadfile(getopt:val("pkgdatadir").."/main.lua"))()
main()
29 changes: 0 additions & 29 deletions src/head.lua.in

This file was deleted.

Loading

0 comments on commit 9048bec

Please sign in to comment.