[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24682 - in gnunet/src: exit include vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24682 - in gnunet/src: exit include vpn |
Date: |
Fri, 2 Nov 2012 17:41:25 +0100 |
Author: szengel
Date: 2012-11-02 17:41:25 +0100 (Fri, 02 Nov 2012)
New Revision: 24682
Modified:
gnunet/src/exit/Makefile.am
gnunet/src/exit/gnunet-daemon-exit.c
gnunet/src/include/gnunet_applications.h
gnunet/src/vpn/Makefile.am
gnunet/src/vpn/gnunet-service-vpn.c
Log:
Using regex for exit/vpn
Modified: gnunet/src/exit/Makefile.am
===================================================================
--- gnunet/src/exit/Makefile.am 2012-11-02 16:01:05 UTC (rev 24681)
+++ gnunet/src/exit/Makefile.am 2012-11-02 16:41:25 UTC (rev 24682)
@@ -41,4 +41,5 @@
$(top_builddir)/src/tun/libgnunettun.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/mesh/libgnunetmesh.la \
+ $(top_builddir)/src/regex/libgnunetregex.la \
$(GN_LIBINTL)
Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c 2012-11-02 16:01:05 UTC (rev
24681)
+++ gnunet/src/exit/gnunet-daemon-exit.c 2012-11-02 16:41:25 UTC (rev
24682)
@@ -42,9 +42,23 @@
#include "gnunet_statistics_service.h"
#include "gnunet_constants.h"
#include "gnunet_tun_lib.h"
+#include "gnunet_regex_lib.h"
#include "exit.h"
/**
+ * Maximum path compression length for mesh regex announcing for IPv4 address
+ * based regex.
+ */
+#define REGEX_MAX_PATH_LEN_IPV4 4
+
+/**
+ * Maximum path compression length for mesh regex announcing for IPv6 address
+ * based regex.
+ */
+#define REGEX_MAX_PATH_LEN_IPV6 8
+
+
+/**
* Information about an address.
*/
struct SocketAddress
@@ -3000,6 +3014,9 @@
char *ipv4addr;
char *ipv4mask;
char *binary;
+ char *regex;
+ char ipv4regex[GNUNET_REGEX_IPV4_REGEXLEN];
+ char ipv6regex[GNUNET_REGEX_IPV6_REGEXLEN];
binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
if (GNUNET_YES !=
@@ -3189,6 +3206,34 @@
GNUNET_SCHEDULER_shutdown ();
return;
}
+
+ /* Mesh handle acquired, now announce regular expressions matching our exit
*/
+ if (GNUNET_YES == ipv4_enabled && GNUNET_YES == ipv4_exit)
+ {
+ GNUNET_REGEX_ipv4toregex (&exit_ipv4addr, ipv4mask, ipv4regex);
+ GNUNET_asprintf (®ex, "%s%s%s",
+ GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+ "4",
+ ipv4regex);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing exit regex: %s\n", regex);
+ GNUNET_MESH_announce_regex (mesh_handle, regex, REGEX_MAX_PATH_LEN_IPV4);
+ GNUNET_free (regex);
+ }
+
+ if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit)
+ {
+ GNUNET_REGEX_ipv6toregex (&exit_ipv6addr, ipv6prefix, ipv6regex);
+ GNUNET_asprintf (®ex, "%s%s%s",
+ GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+ "6",
+ ipv6regex);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing exit regex: %s\n", regex);
+ GNUNET_MESH_announce_regex (mesh_handle, regex, REGEX_MAX_PATH_LEN_IPV4);
+ GNUNET_free (regex);
+ }
+
helper_handle = GNUNET_HELPER_start (GNUNET_NO,
"gnunet-helper-exit",
exit_argv,
Modified: gnunet/src/include/gnunet_applications.h
===================================================================
--- gnunet/src/include/gnunet_applications.h 2012-11-02 16:01:05 UTC (rev
24681)
+++ gnunet/src/include/gnunet_applications.h 2012-11-02 16:41:25 UTC (rev
24682)
@@ -61,7 +61,13 @@
*/
#define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17
+/**
+ * Internet exit regex prefix. Consisting of application ID, followed by
version
+ * and padding.
+ */
+#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNEX0001PADPADPA"
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am 2012-11-02 16:01:05 UTC (rev 24681)
+++ gnunet/src/vpn/Makefile.am 2012-11-02 16:41:25 UTC (rev 24682)
@@ -47,6 +47,7 @@
$(top_builddir)/src/tun/libgnunettun.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/mesh/libgnunetmesh.la \
+ $(top_builddir)/src/regex/libgnunetregex.la \
$(GN_LIBINTL)
gnunet_service_vpn_CFLAGS = \
-I$(top_srcdir)/src/exit $(CFLAGS)
Modified: gnunet/src/vpn/gnunet-service-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-service-vpn.c 2012-11-02 16:01:05 UTC (rev 24681)
+++ gnunet/src/vpn/gnunet-service-vpn.c 2012-11-02 16:41:25 UTC (rev 24682)
@@ -35,6 +35,7 @@
#include "gnunet_statistics_service.h"
#include "gnunet_constants.h"
#include "gnunet_tun_lib.h"
+#include "gnunet_regex_lib.h"
#include "vpn.h"
#include "exit.h"
@@ -807,27 +808,45 @@
}
else
{
+ char *policy;
+
switch (de->details.exit_destination.af)
{
case AF_INET:
- GNUNET_MESH_peer_request_connect_by_type (ts->tunnel,
-
GNUNET_APPLICATION_TYPE_IPV4_GATEWAY);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating tunnel to exit peer for %s\n",
- "IPv4");
- break;
+ {
+ char address[GNUNET_REGEX_IPV4_REGEXLEN];
+ GNUNET_REGEX_ipv4toregex (&de->details.exit_destination.ip.v4,
+ "255.255.255.255", address);
+ GNUNET_asprintf (&policy, "%s%s%s",
+ GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+ "4",
+ address);
+ break;
+ }
case AF_INET6:
- GNUNET_MESH_peer_request_connect_by_type (ts->tunnel,
-
GNUNET_APPLICATION_TYPE_IPV6_GATEWAY);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating tunnel to exit peer for %s\n",
- "IPv6");
+ {
+ char address[GNUNET_REGEX_IPV6_REGEXLEN];
+ GNUNET_REGEX_ipv6toregex (&de->details.exit_destination.ip.v6,
+ 128, address);
+ GNUNET_asprintf (&policy, "%s%s%s",
+ GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+ "6",
+ address);
break;
+ }
default:
GNUNET_assert (0);
break;
}
- }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting connect by string: %s\n",
policy);
+
+ GNUNET_MESH_peer_request_connect_by_string (ts->tunnel, policy);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Creating tunnel to exit peer for policy `%s'\n",
+ policy);
+ GNUNET_free (policy);
+ }
return ts;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24682 - in gnunet/src: exit include vpn,
gnunet <=