diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2015-06-21 18:14:58 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2015-06-21 18:14:58 +0000 |
commit | 1cfcc6a13f75ff69ec6ab851a471f1939cb5f295 (patch) | |
tree | 55400e04802501961a9181b3c94d7bb7d605dc70 | |
parent | 13d57af5209744c385c6cff56fd0e2fd95eee900 (diff) |
dos2unix
-rw-r--r-- | contrib/gnunet_pyexpect.py.in | 166 | ||||
-rw-r--r-- | contrib/terminate.py.in | 84 | ||||
-rw-r--r-- | m4/ac_define_dir.m4 | 70 | ||||
-rw-r--r-- | src/consensus/consensus-simulation.py | 206 | ||||
-rw-r--r-- | src/dns/Makefile.am | 252 | ||||
-rw-r--r-- | src/integration-tests/gnunet_pyexpect.py.in | 166 | ||||
-rw-r--r-- | src/nat/test_stun.c | 1028 | ||||
-rw-r--r-- | src/nat/test_stun.h | 216 |
8 files changed, 1094 insertions, 1094 deletions
diff --git a/contrib/gnunet_pyexpect.py.in b/contrib/gnunet_pyexpect.py.in index f8b7cc88f3..b03bcc5570 100644 --- a/contrib/gnunet_pyexpect.py.in +++ b/contrib/gnunet_pyexpect.py.in @@ -1,83 +1,83 @@ -#!@PYTHON@
-# This file is part of GNUnet.
-# (C) 2010 Christian Grothoff (and other contributing authors)
-#
-# GNUnet is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 2, or (at your
-# option) any later version.
-#
-# GNUnet is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNUnet; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# Testcase for gnunet-peerinfo
-from __future__ import print_function
-import os
-import re
-import subprocess
-import sys
-import shutil
-import time
-
-class pexpect (object):
- def __init__ (self):
- super (pexpect, self).__init__ ()
-
- def spawn (self, stdin, arglist, *pargs, **kwargs):
- env = kwargs.pop ('env', None)
- if env is None:
- env = os.environ.copy ()
- # This messes up some testcases, disable log redirection
- env.pop ('GNUNET_FORCE_LOGFILE', None)
- self.proc = subprocess.Popen (arglist, *pargs, env=env, **kwargs)
- if self.proc is None:
- print ("Failed to spawn a process {0}".format (arglist))
- sys.exit (1)
- if stdin is not None:
- self.stdo, self.stde = self.proc.communicate (stdin)
- else:
- self.stdo, self.stde = self.proc.communicate ()
- return self.proc
-
- def expect (self, s, r, flags=0):
- stream = self.stdo if s == 'stdout' else self.stde
- if isinstance (r, str):
- if r == "EOF":
- if len (stream) == 0:
- return True
- else:
- print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream)))
- sys.exit (2)
- raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r))
- m = r.search (stream.decode(), flags)
- if not m:
- print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream))
- sys.exit (2)
- stream = stream[m.end ():]
- if s == 'stdout':
- self.stdo = stream
- else:
- self.stde = stream
- return m
-
- def read (self, s, size=-1):
- stream = self.stdo if s == 'stdout' else self.stde
- result = ""
- if size < 0:
- result = stream
- new_stream = ""
- else:
- result = stream[0:size]
- new_stream = stream[size:]
- if s == 'stdout':
- self.stdo = new_stream
- else:
- self.stde = new_stream
- return result
+#!@PYTHON@ +# This file is part of GNUnet. +# (C) 2010 Christian Grothoff (and other contributing authors) +# +# GNUnet is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 2, or (at your +# option) any later version. +# +# GNUnet is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNUnet; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +# Testcase for gnunet-peerinfo +from __future__ import print_function +import os +import re +import subprocess +import sys +import shutil +import time + +class pexpect (object): + def __init__ (self): + super (pexpect, self).__init__ () + + def spawn (self, stdin, arglist, *pargs, **kwargs): + env = kwargs.pop ('env', None) + if env is None: + env = os.environ.copy () + # This messes up some testcases, disable log redirection + env.pop ('GNUNET_FORCE_LOGFILE', None) + self.proc = subprocess.Popen (arglist, *pargs, env=env, **kwargs) + if self.proc is None: + print ("Failed to spawn a process {0}".format (arglist)) + sys.exit (1) + if stdin is not None: + self.stdo, self.stde = self.proc.communicate (stdin) + else: + self.stdo, self.stde = self.proc.communicate () + return self.proc + + def expect (self, s, r, flags=0): + stream = self.stdo if s == 'stdout' else self.stde + if isinstance (r, str): + if r == "EOF": + if len (stream) == 0: + return True + else: + print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream))) + sys.exit (2) + raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r)) + m = r.search (stream.decode(), flags) + if not m: + print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream)) + sys.exit (2) + stream = stream[m.end ():] + if s == 'stdout': + self.stdo = stream + else: + self.stde = stream + return m + + def read (self, s, size=-1): + stream = self.stdo if s == 'stdout' else self.stde + result = "" + if size < 0: + result = stream + new_stream = "" + else: + result = stream[0:size] + new_stream = stream[size:] + if s == 'stdout': + self.stdo = new_stream + else: + self.stde = new_stream + return result diff --git a/contrib/terminate.py.in b/contrib/terminate.py.in index 14c79c10d0..aeaaa15014 100644 --- a/contrib/terminate.py.in +++ b/contrib/terminate.py.in @@ -20,45 +20,45 @@ # Utility module that implements safe process termination for W32. # For other platforms it's equivalent to Popen.kill () # Requires pywin32 on W32. -
-import sys
-import os
-import subprocess
-if os.name == 'nt':
- import win32api
- import win32process
-
-class dummyobj (object):
- pass
-
-def safe_terminate_process_by_pid (pid, code):
- if os.name == 'nt':
- p = dummyobj ()
- p._handle = win32api.OpenProcess (2 | 1024 | 8 | 32 | 16, 0, pid)
- result = safe_terminate_process (p, code)
- win32api.CloseHandle (p._handle)
- return result
- else:
- return os.kill (int (pid), SIGKILL)
-
-def safe_terminate_process (proc, code):
- if os.name == 'nt':
- cp = win32api.GetCurrentProcess ()
- result = False
- dupproc = win32api.DuplicateHandle (cp, proc._handle, cp, 2 | 1024 | 8 | 32 | 16, 0, 0)
- try:
- exitcode = win32process.GetExitCodeProcess (dupproc)
- if exitcode == 0x103:
- kernel32 = win32api.GetModuleHandle ("kernel32")
- exitprocess = win32api.GetProcAddress (kernel32, "ExitProcess")
- th, tid = win32process.CreateRemoteThread (dupproc, None, 0, exitprocess, code, 0)
- win32api.CloseHandle (th)
- result = True
- else:
- result = True
- # except failed to get exit code? failed to get module handle?
- finally:
- win32api.CloseHandle (dupproc)
- return result
- else:
- return proc.kill ()
+ +import sys +import os +import subprocess +if os.name == 'nt': + import win32api + import win32process + +class dummyobj (object): + pass + +def safe_terminate_process_by_pid (pid, code): + if os.name == 'nt': + p = dummyobj () + p._handle = win32api.OpenProcess (2 | 1024 | 8 | 32 | 16, 0, pid) + result = safe_terminate_process (p, code) + win32api.CloseHandle (p._handle) + return result + else: + return os.kill (int (pid), SIGKILL) + +def safe_terminate_process (proc, code): + if os.name == 'nt': + cp = win32api.GetCurrentProcess () + result = False + dupproc = win32api.DuplicateHandle (cp, proc._handle, cp, 2 | 1024 | 8 | 32 | 16, 0, 0) + try: + exitcode = win32process.GetExitCodeProcess (dupproc) + if exitcode == 0x103: + kernel32 = win32api.GetModuleHandle ("kernel32") + exitprocess = win32api.GetProcAddress (kernel32, "ExitProcess") + th, tid = win32process.CreateRemoteThread (dupproc, None, 0, exitprocess, code, 0) + win32api.CloseHandle (th) + result = True + else: + result = True + # except failed to get exit code? failed to get module handle? + finally: + win32api.CloseHandle (dupproc) + return result + else: + return proc.kill () diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4 index f7e028fca2..c4f07c50b3 100644 --- a/m4/ac_define_dir.m4 +++ b/m4/ac_define_dir.m4 @@ -1,35 +1,35 @@ -dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
-dnl
-dnl This macro _AC_DEFINEs VARNAME to the expansion of the DIR
-dnl variable, taking care of fixing up ${prefix} and such.
-dnl
-dnl VARNAME is offered as both a C preprocessor symbol, and an output
-dnl variable.
-dnl
-dnl Note that the 3 argument form is only supported with autoconf 2.13
-dnl and later (i.e. only where _AC_DEFINE supports 3 arguments).
-dnl
-dnl Examples:
-dnl
-dnl AC_DEFINE_DIR(DATADIR, datadir)
-dnl AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries])
-dnl
-dnl @category Misc
-dnl @author Stepan Kasal <kasal@ucw.cz>
-dnl @author Andreas Schwab <schwab@suse.de>
-dnl @author Guido Draheim <guidod@gmx.de>
-dnl @author Alexandre Oliva
-dnl @version 2005-01-17
-dnl @license AllPermissive
-
-AC_DEFUN([AC_DEFINE_DIR], [
- prefix_NONE=
- exec_prefix_NONE=
- test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
- test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
- eval ac_define_dir="\"[$]$2\""
- AC_SUBST($1, "$ac_define_dir")
- AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
- test "$prefix_NONE" && prefix=NONE
- test "$exec_prefix_NONE" && exec_prefix=NONE
-])
+dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) +dnl +dnl This macro _AC_DEFINEs VARNAME to the expansion of the DIR +dnl variable, taking care of fixing up ${prefix} and such. +dnl +dnl VARNAME is offered as both a C preprocessor symbol, and an output +dnl variable. +dnl +dnl Note that the 3 argument form is only supported with autoconf 2.13 +dnl and later (i.e. only where _AC_DEFINE supports 3 arguments). +dnl +dnl Examples: +dnl +dnl AC_DEFINE_DIR(DATADIR, datadir) +dnl AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries]) +dnl +dnl @category Misc +dnl @author Stepan Kasal <kasal@ucw.cz> +dnl @author Andreas Schwab <schwab@suse.de> +dnl @author Guido Draheim <guidod@gmx.de> +dnl @author Alexandre Oliva +dnl @version 2005-01-17 +dnl @license AllPermissive + +AC_DEFUN([AC_DEFINE_DIR], [ + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix + eval ac_define_dir="\"[$]$2\"" + AC_SUBST($1, "$ac_define_dir") + AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE +]) diff --git a/src/consensus/consensus-simulation.py b/src/consensus/consensus-simulation.py index 930dfee62b..3bc4ab652a 100644 --- a/src/consensus/consensus-simulation.py +++ b/src/consensus/consensus-simulation.py @@ -1,103 +1,103 @@ -#!/usr/bin/python
-# This file is part of GNUnet
-# (C) 2013 Christian Grothoff (and other contributing authors)
-#
-# GNUnet is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 2, or (at your
-# option) any later version.
-#
-# GNUnet is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNUnet; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import argparse
-import random
-from math import ceil,log,floor
-
-def bsc(n):
- """ count the bits set in n"""
- l = n.bit_length()
- c = 0
- x = 1
- for _ in range(0, l):
- if n & x:
- c = c + 1
- x = x << 1
- return c
-
-def simulate(k, n, verbose):
- assert k < n
- largest_arc = int(2**ceil(log(n, 2))) / 2
- num_ghosts = (2 * largest_arc) - n
- if verbose:
- print "we have", num_ghosts, "ghost peers"
- # n.b. all peers with idx<k are evil
- peers = range(n)
- info = [1 << x for x in xrange(n)]
- def done_p():
- for x in xrange(k, n):
- if bsc(info[x]) < n-k:
- return False
- return True
- rounds = 0
- while not done_p():
- if verbose:
- print "-- round --"
- arc = 1
- while arc <= largest_arc:
- if verbose:
- print "-- subround --"
- new_info = [x for x in info]
- for peer_physical in xrange(n):
- peer_logical = peers[peer_physical]
- peer_type = None
- partner_logical = (peer_logical + arc) % n
- partner_physical = peers.index(partner_logical)
- if peer_physical < k or partner_physical < k:
- if verbose:
- print "bad peer in connection", peer_physical, "--", partner_physical
- continue
- if peer_logical & arc == 0:
- # we are outgoing
- if verbose:
- print peer_physical, "connects to", partner_physical
- peer_type = "outgoing"
- if peer_logical < num_ghosts:
- # we have a ghost, check if the peer who connects
- # to our ghost is actually outgoing
- ghost_partner_logical = (peer_logical - arc) % n
- if ghost_partner_logical & arc == 0:
- peer_type = peer_type + ", ghost incoming"
- new_info[peer_physical] = new_info[peer_physical] | info[peer_physical] | info[partner_physical]
- new_info[partner_physical] = new_info[partner_physical] | info[peer_physical] | info[partner_physical]
- else:
- peer_type = "incoming"
- if verbose > 1:
- print "type of", str(peer_physical) + ":", peer_type
- info = new_info
- arc = arc << 1;
- rounds = rounds + 1
- random.shuffle(peers)
- return rounds
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser()
- parser.add_argument("k", metavar="k", type=int, help="#(bad peers)")
- parser.add_argument("n", metavar="n", type=int, help="#(all peers)")
- parser.add_argument("r", metavar="r", type=int, help="#(rounds)")
- parser.add_argument('--verbose', '-v', action='count')
-
- args = parser.parse_args()
- sum = 0.0;
- for n in xrange (0, args.r):
- sum += simulate(args.k, args.n, args.verbose)
- print sum / args.r;
-
-
+#!/usr/bin/python +# This file is part of GNUnet +# (C) 2013 Christian Grothoff (and other contributing authors) +# +# GNUnet is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 2, or (at your +# option) any later version. +# +# GNUnet is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNUnet; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import argparse +import random +from math import ceil,log,floor + +def bsc(n): + """ count the bits set in n""" + l = n.bit_length() + c = 0 + x = 1 + for _ in range(0, l): + if n & x: + c = c + 1 + x = x << 1 + return c + +def simulate(k, n, verbose): + assert k < n + largest_arc = int(2**ceil(log(n, 2))) / 2 + num_ghosts = (2 * largest_arc) - n + if verbose: + print "we have", num_ghosts, "ghost peers" + # n.b. all peers with idx<k are evil + peers = range(n) + info = [1 << x for x in xrange(n)] + def done_p(): + for x in xrange(k, n): + if bsc(info[x]) < n-k: + return False + return True + rounds = 0 + while not done_p(): + if verbose: + print "-- round --" + arc = 1 + while arc <= largest_arc: + if verbose: + print "-- subround --" + new_info = [x for x in info] + for peer_physical in xrange(n): + peer_logical = peers[peer_physical] + peer_type = None + partner_logical = (peer_logical + arc) % n + partner_physical = peers.index(partner_logical) + if peer_physical < k or partner_physical < k: + if verbose: + print "bad peer in connection", peer_physical, "--", partner_physical + continue + if peer_logical & arc == 0: + # we are outgoing + if verbose: + print peer_physical, "connects to", partner_physical + peer_type = "outgoing" + if peer_logical < num_ghosts: + # we have a ghost, check if the peer who connects + # to our ghost is actually outgoing + ghost_partner_logical = (peer_logical - arc) % n + if ghost_partner_logical & arc == 0: + peer_type = peer_type + ", ghost incoming" + new_info[peer_physical] = new_info[peer_physical] | info[peer_physical] | info[partner_physical] + new_info[partner_physical] = new_info[partner_physical] | info[peer_physical] | info[partner_physical] + else: + peer_type = "incoming" + if verbose > 1: + print "type of", str(peer_physical) + ":", peer_type + info = new_info + arc = arc << 1; + rounds = rounds + 1 + random.shuffle(peers) + return rounds + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("k", metavar="k", type=int, help="#(bad peers)") + parser.add_argument("n", metavar="n", type=int, help="#(all peers)") + parser.add_argument("r", metavar="r", type=int, help="#(rounds)") + parser.add_argument('--verbose', '-v', action='count') + + args = parser.parse_args() + sum = 0.0; + for n in xrange (0, args.r): + sum += simulate(args.k, args.n, args.verbose) + print sum / args.r; + + diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am index e2f9a07833..a8ff4265db 100644 --- a/src/dns/Makefile.am +++ b/src/dns/Makefile.am @@ -1,126 +1,126 @@ -# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include
-
-if MINGW
- WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
-endif
-
-if USE_COVERAGE
- AM_CFLAGS = --coverage -O0
-endif
-
-pkgcfgdir= $(pkgdatadir)/config.d/
-
-libexecdir= $(pkglibdir)/libexec/
-
-plugindir = $(libdir)/gnunet
-
-pkgcfg_DATA = \
- dns.conf
-
-if LINUX
-HIJACKBIN = gnunet-helper-dns
-install-exec-hook:
- $(top_srcdir)/src/dns/install-dns-helper.sh $(libexecdir) $(GNUNETDNS_GROUP) $(SUDO_BINARY) || true
-else
-install-exec-hook:
-endif
-
-lib_LTLIBRARIES = \
- libgnunetdnsparser.la \
- libgnunetdnsstub.la \
- libgnunetdns.la
-
-libexec_PROGRAMS = \
- gnunet-service-dns $(HIJACKBIN)
-
-noinst_PROGRAMS = \
- gnunet-dns-monitor gnunet-dns-redirector
-
-plugin_LTLIBRARIES = \
- libgnunet_plugin_block_dns.la
-
-if LINUX
-check_SCRIPTS = \
- test_gnunet_dns.sh
-endif
-
-check_PROGRAMS = \
- test_hexcoder
-
-gnunet_helper_dns_SOURCES = \
- gnunet-helper-dns.c
-
-
-gnunet_dns_monitor_SOURCES = \
- gnunet-dns-monitor.c
-gnunet_dns_monitor_LDADD = \
- libgnunetdnsparser.la \
- libgnunetdns.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL)
-
-gnunet_dns_redirector_SOURCES = \
- gnunet-dns-redirector.c
-gnunet_dns_redirector_LDADD = \
- libgnunetdnsparser.la \
- libgnunetdns.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL)
-
-gnunet_service_dns_SOURCES = \
- gnunet-service-dns.c
-gnunet_service_dns_LDADD = \
- libgnunetdnsstub.la \
- $(top_builddir)/src/tun/libgnunettun.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL)
-
-libgnunetdnsparser_la_SOURCES = \
- dnsparser.c
-libgnunetdnsparser_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
- -lidn
-libgnunetdnsparser_la_LDFLAGS = \
- $(GN_LIB_LDFLAGS) \
- -version-info 1:0:1
-
-libgnunetdnsstub_la_SOURCES = \
- dnsstub.c
-libgnunetdnsstub_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
-libgnunetdnsstub_la_LDFLAGS = \
- $(GN_LIB_LDFLAGS) \
- -version-info 0:0:0
-
-libgnunetdns_la_SOURCES = \
- dns_api.c dns.h
-libgnunetdns_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
-libgnunetdns_la_LDFLAGS = \
- $(GN_LIB_LDFLAGS) \
- -version-info 0:0:0
-
-libgnunet_plugin_block_dns_la_SOURCES = \
- plugin_block_dns.c
-libgnunet_plugin_block_dns_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la
-libgnunet_plugin_block_dns_la_LDFLAGS = \
- $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS)
-
-
-if ENABLE_TEST_RUN
-AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
-TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
-endif
-
-EXTRA_DIST = \
- $(check_SCRIPTS)
-
-
-test_hexcoder_SOURCES = \
- test_hexcoder.c
-test_hexcoder_LDADD = \
- libgnunetdnsparser.la \
- $(top_builddir)/src/util/libgnunetutil.la
+# This Makefile.am is in the public domain +AM_CPPFLAGS = -I$(top_srcdir)/src/include + +if MINGW + WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols +endif + +if USE_COVERAGE + AM_CFLAGS = --coverage -O0 +endif + +pkgcfgdir= $(pkgdatadir)/config.d/ + +libexecdir= $(pkglibdir)/libexec/ + +plugindir = $(libdir)/gnunet + +pkgcfg_DATA = \ + dns.conf + +if LINUX +HIJACKBIN = gnunet-helper-dns +install-exec-hook: + $(top_srcdir)/src/dns/install-dns-helper.sh $(libexecdir) $(GNUNETDNS_GROUP) $(SUDO_BINARY) || true +else +install-exec-hook: +endif + +lib_LTLIBRARIES = \ + libgnunetdnsparser.la \ + libgnunetdnsstub.la \ + libgnunetdns.la + +libexec_PROGRAMS = \ + gnunet-service-dns $(HIJACKBIN) + +noinst_PROGRAMS = \ + gnunet-dns-monitor gnunet-dns-redirector + +plugin_LTLIBRARIES = \ + libgnunet_plugin_block_dns.la + +if LINUX +check_SCRIPTS = \ + test_gnunet_dns.sh +endif + +check_PROGRAMS = \ + test_hexcoder + +gnunet_helper_dns_SOURCES = \ + gnunet-helper-dns.c + + +gnunet_dns_monitor_SOURCES = \ + gnunet-dns-monitor.c +gnunet_dns_monitor_LDADD = \ + libgnunetdnsparser.la \ + libgnunetdns.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) + +gnunet_dns_redirector_SOURCES = \ + gnunet-dns-redirector.c +gnunet_dns_redirector_LDADD = \ + libgnunetdnsparser.la \ + libgnunetdns.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) + +gnunet_service_dns_SOURCES = \ + gnunet-service-dns.c +gnunet_service_dns_LDADD = \ + libgnunetdnsstub.la \ + $(top_builddir)/src/tun/libgnunettun.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) + +libgnunetdnsparser_la_SOURCES = \ + dnsparser.c +libgnunetdnsparser_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \ + -lidn +libgnunetdnsparser_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) \ + -version-info 1:0:1 + +libgnunetdnsstub_la_SOURCES = \ + dnsstub.c +libgnunetdnsstub_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la $(XLIB) +libgnunetdnsstub_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) \ + -version-info 0:0:0 + +libgnunetdns_la_SOURCES = \ + dns_api.c dns.h +libgnunetdns_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la $(XLIB) +libgnunetdns_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) \ + -version-info 0:0:0 + +libgnunet_plugin_block_dns_la_SOURCES = \ + plugin_block_dns.c +libgnunet_plugin_block_dns_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la +libgnunet_plugin_block_dns_la_LDFLAGS = \ + $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS) + + +if ENABLE_TEST_RUN +AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; +TESTS = $(check_PROGRAMS) $(check_SCRIPTS) +endif + +EXTRA_DIST = \ + $(check_SCRIPTS) + + +test_hexcoder_SOURCES = \ + test_hexcoder.c +test_hexcoder_LDADD = \ + libgnunetdnsparser.la \ + $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/integration-tests/gnunet_pyexpect.py.in b/src/integration-tests/gnunet_pyexpect.py.in index 9e5c83fa37..3ca3c0a69c 100644 --- a/src/integration-tests/gnunet_pyexpect.py.in +++ b/src/integration-tests/gnunet_pyexpect.py.in @@ -1,83 +1,83 @@ -#!@PYTHON@
-# This file is part of GNUnet.
-# (C) 2010 Christian Grothoff (and other contributing authors)
-#
-# GNUnet is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 2, or (at your
-# option) any later version.
-#
-# GNUnet is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNUnet; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# Testcase for gnunet-peerinfo
-from __future__ import print_function
-import os
-import re
-import subprocess
-import sys
-import shutil
-import time
-
-class pexpect (object):
- def __init__ (self):
- super (pexpect, self).__init__ ()
-
- def spawn (self, stdin, arglist, *pargs, **kwargs):
- env = kwargs.pop ('env', None)
- if env is None:
- env = os.environ.copy ()
- # This messes up some testcases, disable log redirection
- env.pop ('GNUNET_FORCE_LOGFILE', None)
- self.proc = subprocess.Popen (arglist, *pargs, env=env, **kwargs)
- if self.proc is None:
- print ("Failed to spawn a process {0}".format (arglist))
- sys.exit (1)
- if stdin is not None:
- self.stdo, self.stde = self.proc.communicate (stdin)
- else:
- self.stdo, self.stde = self.proc.communicate ()
- return self.proc
-
- def expect (self, s, r, flags=0):
- stream = self.stdo if s == 'stdout' else self.stde
- if isinstance (r, str):
- if r == "EOF":
- if len (stream) == 0:
- return True
- else:
- print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream)))
- sys.exit (2)
- raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r))
- m = r.search (stream, flags)
- if not m:
- print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream))
- sys.exit (2)
- stream = stream[m.end ():]
- if s == 'stdout':
- self.stdo = stream
- else:
- self.stde = stream
- return m
-
- def read (self, s, size=-1):
- stream = self.stdo if s == 'stdout' else self.stde
- result = ""
- if size < 0:
- result = stream
- new_stream = ""
- else:
- result = stream[0:size]
- new_stream = stream[size:]
- if s == 'stdout':
- self.stdo = new_stream
- else:
- self.stde = new_stream
- return result
+#!@PYTHON@ +# This file is part of GNUnet. +# (C) 2010 Christian Grothoff (and other contributing authors) +# +# GNUnet is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 2, or (at your +# option) any later version. +# +# GNUnet is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNUnet; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +# Testcase for gnunet-peerinfo +from __future__ import print_function +import os +import re +import subprocess +import sys +import shutil +import time + +class pexpect (object): + def __init__ (self): + super (pexpect, self).__init__ () + + def spawn (self, stdin, arglist, *pargs, **kwargs): + env = kwargs.pop ('env', None) + if env is None: + env = os.environ.copy () + # This messes up some testcases, disable log redirection + env.pop ('GNUNET_FORCE_LOGFILE', None) + self.proc = subprocess.Popen (arglist, *pargs, env=env, **kwargs) + if self.proc is None: + print ("Failed to spawn a process {0}".format (arglist)) + sys.exit (1) + if stdin is not None: + self.stdo, self.stde = self.proc.communicate (stdin) + else: + self.stdo, self.stde = self.proc.communicate () + return self.proc + + def expect (self, s, r, flags=0): + stream = self.stdo if s == 'stdout' else self.stde + if isinstance (r, str): + if r == "EOF": + if len (stream) == 0: + return True + else: + print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream))) + sys.exit (2) + raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r)) + m = r.search (stream, flags) + if not m: + print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream)) + sys.exit (2) + stream = stream[m.end ():] + if s == 'stdout': + self.stdo = stream + else: + self.stde = stream + return m + + def read (self, s, size=-1): + stream = self.stdo if s == 'stdout' else self.stde + result = "" + if size < 0: + result = stream + new_stream = "" + else: + result = stream[0:size] + new_stream = stream[size:] + if s == 'stdout': + self.stdo = new_stream + else: + self.stde = new_stream + return result diff --git a/src/nat/test_stun.c b/src/nat/test_stun.c index adb485e99c..8448f7f853 100644 --- a/src/nat/test_stun.c +++ b/src/nat/test_stun.c @@ -1,514 +1,514 @@ -/*
- This file is part of GNUnet.
- Copyright (C) 2009, 2015 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * Testcase for STUN server resolution
- *
- * @file nat/test_stun.c
- * @brief Testcase for STUN library
- * @author Bruno Souza Cabral
- * @autor Mark Spencer (Original code borrowed from Asterisk)
- *
- */
-
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_scheduler_lib.h"
-#include "gnunet_nat_lib.h"
-
-
-#include "test_stun.h"
-
-
-/**
- * The port the test service is running on (default 7895)
- */
-static unsigned long port = 7895;
-
-static int ret = 1;
-
-/**
- * The listen socket of the service for IPv4
- */
-static struct GNUNET_NETWORK_Handle *lsock4;
-
-
-/**
- * The listen task ID for IPv4
- */
-static struct GNUNET_SCHE |