aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-11-02 16:41:25 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-11-02 16:41:25 +0000
commit211fd52268a5ae7856273dd8d8b3b3ed427beadb (patch)
treef30b55769ea49eecf36cdf9a87ab3f2115b81565 /src/exit
parentc8f6b6ac48fea41f20b3721295d0fa064b2d129d (diff)
downloadgnunet-211fd52268a5ae7856273dd8d8b3b3ed427beadb.tar.gz
gnunet-211fd52268a5ae7856273dd8d8b3b3ed427beadb.zip
Using regex for exit/vpn
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/Makefile.am1
-rw-r--r--src/exit/gnunet-daemon-exit.c45
2 files changed, 46 insertions, 0 deletions
diff --git a/src/exit/Makefile.am b/src/exit/Makefile.am
index dd030e7a4..2da59f14a 100644
--- a/src/exit/Makefile.am
+++ b/src/exit/Makefile.am
@@ -41,4 +41,5 @@ gnunet_daemon_exit_LDADD = \
41 $(top_builddir)/src/tun/libgnunettun.la \ 41 $(top_builddir)/src/tun/libgnunettun.la \
42 $(top_builddir)/src/util/libgnunetutil.la \ 42 $(top_builddir)/src/util/libgnunetutil.la \
43 $(top_builddir)/src/mesh/libgnunetmesh.la \ 43 $(top_builddir)/src/mesh/libgnunetmesh.la \
44 $(top_builddir)/src/regex/libgnunetregex.la \
44 $(GN_LIBINTL) 45 $(GN_LIBINTL)
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 30be57845..e03a9b55c 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -42,9 +42,23 @@
42#include "gnunet_statistics_service.h" 42#include "gnunet_statistics_service.h"
43#include "gnunet_constants.h" 43#include "gnunet_constants.h"
44#include "gnunet_tun_lib.h" 44#include "gnunet_tun_lib.h"
45#include "gnunet_regex_lib.h"
45#include "exit.h" 46#include "exit.h"
46 47
47/** 48/**
49 * Maximum path compression length for mesh regex announcing for IPv4 address
50 * based regex.
51 */
52#define REGEX_MAX_PATH_LEN_IPV4 4
53
54/**
55 * Maximum path compression length for mesh regex announcing for IPv6 address
56 * based regex.
57 */
58#define REGEX_MAX_PATH_LEN_IPV6 8
59
60
61/**
48 * Information about an address. 62 * Information about an address.
49 */ 63 */
50struct SocketAddress 64struct SocketAddress
@@ -3000,6 +3014,9 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3000 char *ipv4addr; 3014 char *ipv4addr;
3001 char *ipv4mask; 3015 char *ipv4mask;
3002 char *binary; 3016 char *binary;
3017 char *regex;
3018 char ipv4regex[GNUNET_REGEX_IPV4_REGEXLEN];
3019 char ipv6regex[GNUNET_REGEX_IPV6_REGEXLEN];
3003 3020
3004 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); 3021 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
3005 if (GNUNET_YES != 3022 if (GNUNET_YES !=
@@ -3189,6 +3206,34 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3189 GNUNET_SCHEDULER_shutdown (); 3206 GNUNET_SCHEDULER_shutdown ();
3190 return; 3207 return;
3191 } 3208 }
3209
3210 /* Mesh handle acquired, now announce regular expressions matching our exit */
3211 if (GNUNET_YES == ipv4_enabled && GNUNET_YES == ipv4_exit)
3212 {
3213 GNUNET_REGEX_ipv4toregex (&exit_ipv4addr, ipv4mask, ipv4regex);
3214 GNUNET_asprintf (&regex, "%s%s%s",
3215 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
3216 "4",
3217 ipv4regex);
3218
3219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing exit regex: %s\n", regex);
3220 GNUNET_MESH_announce_regex (mesh_handle, regex, REGEX_MAX_PATH_LEN_IPV4);
3221 GNUNET_free (regex);
3222 }
3223
3224 if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit)
3225 {
3226 GNUNET_REGEX_ipv6toregex (&exit_ipv6addr, ipv6prefix, ipv6regex);
3227 GNUNET_asprintf (&regex, "%s%s%s",
3228 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
3229 "6",
3230 ipv6regex);
3231
3232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing exit regex: %s\n", regex);
3233 GNUNET_MESH_announce_regex (mesh_handle, regex, REGEX_MAX_PATH_LEN_IPV4);
3234 GNUNET_free (regex);
3235 }
3236
3192 helper_handle = GNUNET_HELPER_start (GNUNET_NO, 3237 helper_handle = GNUNET_HELPER_start (GNUNET_NO,
3193 "gnunet-helper-exit", 3238 "gnunet-helper-exit",
3194 exit_argv, 3239 exit_argv,