[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: pass section name instead o
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: pass section name instead of specific option via IPC |
Date: |
Thu, 05 Jan 2017 21:23:06 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 1b7f6ee pass section name instead of specific option via IPC
1b7f6ee is described below
commit 1b7f6eea0a06abab9b75b30f021aa6313fccfcd4
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Jan 5 21:23:02 2017 +0100
pass section name instead of specific option via IPC
---
doc/man/gnunet-nat.1 | 4 ++--
src/include/gnunet_nat_service.h | 4 ++--
src/nat/gnunet-nat.c | 14 +++++++-------
src/nat/gnunet-service-nat.c | 20 ++++++++++++++------
src/nat/nat.h | 9 ++++-----
src/nat/nat_api.c | 19 ++++++++-----------
src/transport/transport.conf.in | 13 +++++++++++++
7 files changed, 50 insertions(+), 33 deletions(-)
diff --git a/doc/man/gnunet-nat.1 b/doc/man/gnunet-nat.1
index a834a1d..01e0267 100644
--- a/doc/man/gnunet-nat.1
+++ b/doc/man/gnunet-nat.1
@@ -39,8 +39,8 @@ Assuming we are listening at ADDRESS for connection reversal
requests.
Ask the peer at ADDRESS for connection reversal, using the local address for
the target address of the reversal.
.B
-.IP "\-p ADDRESS, \-\-punch=ADDRESS"
-A hole was punched manually through the NAT. We should use ADDRESS as our
external hostname and port for advertising for incoming requests. The special
hostname 'AUTO' can be used to indicate that GNUnet should determine the
external IP address by other means (such as upnpc), and just take the port
number from ADDRESS.
+.IP "\-S NAME, \-\-section=NAME"
+Name of section in configuration file to use for additional options.
.B
.IP "\-s, \-\-stun"
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h
index 0dbc23e..6b96503 100644
--- a/src/include/gnunet_nat_service.h
+++ b/src/include/gnunet_nat_service.h
@@ -185,8 +185,8 @@ struct GNUNET_NAT_Handle;
* address_callback for any 'plausible' external address.
*
* @param cfg configuration to use
+ * @param config_section name of the configuration section for optionsx
* @param proto protocol this is about, IPPROTO_TCP or IPPROTO_UDP
- * @param hole_external hostname and port of manually punched hole in NAT,
otherwise NULL (or empty string)
* @param num_addrs number of addresses in @a addrs
* @param addrs list of local addresses packets should be redirected to
* @param addrlens actual lengths of the addresses in @a addrs
@@ -198,8 +198,8 @@ struct GNUNET_NAT_Handle;
*/
struct GNUNET_NAT_Handle *
GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *config_section,
uint8_t proto,
- const char *hole_external,
unsigned int num_addrs,
const struct sockaddr **addrs,
const socklen_t *addrlens,
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index 81e4549..4171bab 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -39,10 +39,10 @@ static int global_ret;
static struct GNUNET_NAT_AutoHandle *ah;
/**
- * External hostname and port, if user manually punched
- * the NAT.
+ * Name of section in configuration file to use for
+ * additional options.
*/
-static char *hole_external;
+static char *section_name;
/**
* Flag set to 1 if we use IPPROTO_UDP.
@@ -568,8 +568,8 @@ run (void *cls,
if (NULL != local_addr)
{
nh = GNUNET_NAT_register (c,
+ section_name,
proto,
- hole_external,
1,
(const struct sockaddr **) &local_sa,
&local_len,
@@ -698,9 +698,9 @@ main (int argc,
{'r', "remote", "ADDRESS",
gettext_noop ("which remote IP and port should be asked for connection
reversal"),
GNUNET_YES, &GNUNET_GETOPT_set_string, &remote_addr },
- {'p', "punched", NULL,
- gettext_noop ("external hostname and port of NAT, if punched manually;
use AUTO for hostname for automatic determination of the external IP"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &hole_external },
+ {'S', "section", NULL,
+ gettext_noop ("name of configuration section to find additional options,
such as manual host punching data"),
+ GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name },
{'s', "stun", NULL,
gettext_noop ("enable STUN processing"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &do_stun },
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c
index 8af27af..79f806f 100644
--- a/src/nat/gnunet-service-nat.c
+++ b/src/nat/gnunet-service-nat.c
@@ -30,8 +30,6 @@
* TODO:
* - test and document (!) ICMP based NAT traversal
* - test manual hole punching support
- * - consider passing transport plugin name instead of
- * external IP address string (more flexible!)
* - adapt existing transports to use new NAT logic
* - abandon legacy NAT code
*
@@ -186,6 +184,11 @@ struct ClientHandle
char *hole_external;
/**
+ * Name of the configuration section this client cares about.
+ */
+ char *section_name;
+
+ /**
* Task for periodically re-running the @e ext_dns DNS lookup.
*/
struct GNUNET_SCHEDULER_Task *ext_dns_task;
@@ -505,7 +508,7 @@ check_register (void *cls,
off += alen;
left -= alen;
}
- if (left != ntohs (message->hole_external_len))
+ if (left != ntohs (message->str_len))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -1575,10 +1578,14 @@ handle_register (void *cls,
off += alen;
}
- ch->hole_external
+ ch->section_name
= GNUNET_strndup (off,
- ntohs (message->hole_external_len));
- if (0 != ntohs (message->hole_external_len))
+ ntohs (message->str_len));
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ ch->section_name,
+ "HOLE_EXTERNAL",
+ &ch->hole_external))
lookup_hole_external (ch);
/* Actually send IP address list to client */
@@ -2352,6 +2359,7 @@ client_disconnect_cb (void *cls,
ch->ext_dns = NULL;
}
GNUNET_free (ch->hole_external);
+ GNUNET_free (ch->section_name);
GNUNET_free (ch);
}
diff --git a/src/nat/nat.h b/src/nat/nat.h
index af418c7..02bae71 100644
--- a/src/nat/nat.h
+++ b/src/nat/nat.h
@@ -29,6 +29,7 @@
#include "gnunet_util_lib.h"
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
@@ -111,10 +112,9 @@ struct GNUNET_NAT_RegisterMessage
/**
* Number of bytes in the string that follow which
- * specify the hostname and port of a manually punched
- * hole for this client.
+ * specifies a section name in the configuration.
*/
- uint16_t hole_external_len GNUNET_PACKED;
+ uint16_t str_len GNUNET_PACKED;
/**
* Number of addresses that this service is bound to that follow.
@@ -126,8 +126,7 @@ struct GNUNET_NAT_RegisterMessage
/* Followed by @e num_addrs addresses of type 'struct
sockaddr' */
- /* Followed by @e hole_external_len bytes giving a hostname
- and port */
+ /* Followed by @e str_len section name to use for options */
};
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index 008ad19..06b4b99 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -368,8 +368,8 @@ do_connect (void *cls)
* address_callback for any 'plausible' external address.
*
* @param cfg configuration to use
+ * @param config_section name of the configuration section for optionsx
* @param proto protocol this is about, IPPROTO_TCP or IPPROTO_UDP
- * @param hole_external hostname and port of manually punched hole in NAT,
otherwise NULL (or empty string)
* @param num_addrs number of addresses in @a addrs
* @param addrs list of local addresses packets should be redirected to
* @param addrlens actual lengths of the addresses in @a addrs
@@ -381,8 +381,8 @@ do_connect (void *cls)
*/
struct GNUNET_NAT_Handle *
GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *config_section,
uint8_t proto,
- const char *hole_external,
unsigned int num_addrs,
const struct sockaddr **addrs,
const socklen_t *addrlens,
@@ -393,17 +393,14 @@ GNUNET_NAT_register (const struct
GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_NAT_Handle *nh;
struct GNUNET_NAT_RegisterMessage *rm;
size_t len;
- size_t hole_external_len;
+ size_t str_len;
char *off;
len = 0;
for (unsigned int i=0;i<num_addrs;i++)
len += addrlens[i];
- hole_external_len
- = (NULL == hole_external)
- ? 0
- : strlen (hole_external);
- len += hole_external_len;
+ str_len = strlen (config_section) + 1;
+ len += str_len;
if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
(num_addrs > UINT16_MAX) )
{
@@ -419,7 +416,7 @@ GNUNET_NAT_register (const struct
GNUNET_CONFIGURATION_Handle *cfg,
if (NULL != reversal_callback)
rm->flags |= GNUNET_NAT_RF_REVERSAL;
rm->proto = proto;
- rm->hole_external_len = htons (hole_external_len);
+ rm->str_len = htons (str_len);
rm->num_addrs = htons ((uint16_t) num_addrs);
off = (char *) &rm[1];
for (unsigned int i=0;i<num_addrs;i++)
@@ -459,8 +456,8 @@ GNUNET_NAT_register (const struct
GNUNET_CONFIGURATION_Handle *cfg,
off += addrlens[i];
}
GNUNET_memcpy (off,
- hole_external,
- hole_external_len);
+ config_section,
+ str_len);
nh = GNUNET_new (struct GNUNET_NAT_Handle);
nh->reg = &rm->header;
diff --git a/src/transport/transport.conf.in b/src/transport/transport.conf.in
index 95e3f99..4e9f17f 100644
--- a/src/transport/transport.conf.in
+++ b/src/transport/transport.conf.in
@@ -55,6 +55,9 @@ MAX_CONNECTIONS = 128
# Enable TCP stealth?
TCP_STEALTH = NO
+# Configuration for manually punched holes in NAT.
+# HOLE_EXTERNAL = auto:2086
+
[transport-udp]
# Use PORT = 0 to autodetect a port available
PORT = 2086
@@ -69,6 +72,9 @@ BROADCAST_INTERVAL = 30 s
MAX_BPS = 1000000
TESTING_IGNORE_KEYS = ACCEPT_FROM;
+# Configuration for manually punched holes in NAT.
+# HOLE_EXTERNAL = auto:2086
+
[transport-http_client]
MAX_CONNECTIONS = 128
TESTING_IGNORE_KEYS = ACCEPT_FROM;
@@ -99,6 +105,9 @@ TESTING_IGNORE_KEYS = ACCEPT_FROM;
# Enable TCP stealth?
TCP_STEALTH = NO
+# Configuration for manually punched holes in NAT.
+# HOLE_EXTERNAL = auto:2086
+
[transport-https_client]
MAX_CONNECTIONS = 128
TESTING_IGNORE_KEYS = ACCEPT_FROM;
@@ -140,6 +149,10 @@ TESTING_IGNORE_KEYS = ACCEPT_FROM;
# Enable TCP stealth?
TCP_STEALTH = NO
+# Configuration for manually punched holes in NAT.
+# HOLE_EXTERNAL = auto:2086
+
+
[transport-wlan]
# Name of the interface in monitor mode (typically monX)
INTERFACE = mon0
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: pass section name instead of specific option via IPC,
gnunet <=