diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-02 16:41:25 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-02 16:41:25 +0000 |
commit | 211fd52268a5ae7856273dd8d8b3b3ed427beadb (patch) | |
tree | f30b55769ea49eecf36cdf9a87ab3f2115b81565 /src/vpn | |
parent | c8f6b6ac48fea41f20b3721295d0fa064b2d129d (diff) | |
download | gnunet-211fd52268a5ae7856273dd8d8b3b3ed427beadb.tar.gz gnunet-211fd52268a5ae7856273dd8d8b3b3ed427beadb.zip |
Using regex for exit/vpn
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/Makefile.am | 1 | ||||
-rw-r--r-- | src/vpn/gnunet-service-vpn.c | 43 |
2 files changed, 32 insertions, 12 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am index 453b3b908..71601383e 100644 --- a/src/vpn/Makefile.am +++ b/src/vpn/Makefile.am | |||
@@ -47,6 +47,7 @@ gnunet_service_vpn_LDADD = \ | |||
47 | $(top_builddir)/src/tun/libgnunettun.la \ | 47 | $(top_builddir)/src/tun/libgnunettun.la \ |
48 | $(top_builddir)/src/util/libgnunetutil.la \ | 48 | $(top_builddir)/src/util/libgnunetutil.la \ |
49 | $(top_builddir)/src/mesh/libgnunetmesh.la \ | 49 | $(top_builddir)/src/mesh/libgnunetmesh.la \ |
50 | $(top_builddir)/src/regex/libgnunetregex.la \ | ||
50 | $(GN_LIBINTL) | 51 | $(GN_LIBINTL) |
51 | gnunet_service_vpn_CFLAGS = \ | 52 | gnunet_service_vpn_CFLAGS = \ |
52 | -I$(top_srcdir)/src/exit $(CFLAGS) | 53 | -I$(top_srcdir)/src/exit $(CFLAGS) |
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index abdc16d79..5e1452bec 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "gnunet_statistics_service.h" | 35 | #include "gnunet_statistics_service.h" |
36 | #include "gnunet_constants.h" | 36 | #include "gnunet_constants.h" |
37 | #include "gnunet_tun_lib.h" | 37 | #include "gnunet_tun_lib.h" |
38 | #include "gnunet_regex_lib.h" | ||
38 | #include "vpn.h" | 39 | #include "vpn.h" |
39 | #include "exit.h" | 40 | #include "exit.h" |
40 | 41 | ||
@@ -807,27 +808,45 @@ create_tunnel_to_destination (struct DestinationEntry *de, | |||
807 | } | 808 | } |
808 | else | 809 | else |
809 | { | 810 | { |
811 | char *policy; | ||
812 | |||
810 | switch (de->details.exit_destination.af) | 813 | switch (de->details.exit_destination.af) |
811 | { | 814 | { |
812 | case AF_INET: | 815 | case AF_INET: |
813 | GNUNET_MESH_peer_request_connect_by_type (ts->tunnel, | 816 | { |
814 | GNUNET_APPLICATION_TYPE_IPV4_GATEWAY); | 817 | char address[GNUNET_REGEX_IPV4_REGEXLEN]; |
815 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 818 | GNUNET_REGEX_ipv4toregex (&de->details.exit_destination.ip.v4, |
816 | "Creating tunnel to exit peer for %s\n", | 819 | "255.255.255.255", address); |
817 | "IPv4"); | 820 | GNUNET_asprintf (&policy, "%s%s%s", |
818 | break; | 821 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
822 | "4", | ||
823 | address); | ||
824 | break; | ||
825 | } | ||
819 | case AF_INET6: | 826 | case AF_INET6: |
820 | GNUNET_MESH_peer_request_connect_by_type (ts->tunnel, | 827 | { |
821 | GNUNET_APPLICATION_TYPE_IPV6_GATEWAY); | 828 | char address[GNUNET_REGEX_IPV6_REGEXLEN]; |
822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 829 | GNUNET_REGEX_ipv6toregex (&de->details.exit_destination.ip.v6, |
823 | "Creating tunnel to exit peer for %s\n", | 830 | 128, address); |
824 | "IPv6"); | 831 | GNUNET_asprintf (&policy, "%s%s%s", |
832 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | ||
833 | "6", | ||
834 | address); | ||
825 | break; | 835 | break; |
836 | } | ||
826 | default: | 837 | default: |
827 | GNUNET_assert (0); | 838 | GNUNET_assert (0); |
828 | break; | 839 | break; |
829 | } | 840 | } |
830 | } | 841 | |
842 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting connect by string: %s\n", policy); | ||
843 | |||
844 | GNUNET_MESH_peer_request_connect_by_string (ts->tunnel, policy); | ||
845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
846 | "Creating tunnel to exit peer for policy `%s'\n", | ||
847 | policy); | ||
848 | GNUNET_free (policy); | ||
849 | } | ||
831 | return ts; | 850 | return ts; |
832 | } | 851 | } |
833 | 852 | ||