aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-25 12:51:21 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-25 12:51:21 +0000
commitccf6004e61a5379954aed85be6ed49ab7e886a7d (patch)
tree31b63266ea85235a126aa618126e2f836eb4eef2 /src/exit
parent182fae1b29eafe14018d45beb9613725651a779c (diff)
downloadgnunet-ccf6004e61a5379954aed85be6ed49ab7e886a7d.tar.gz
gnunet-ccf6004e61a5379954aed85be6ed49ab7e886a7d.zip
ensure binding multiple ports to the same service descriptor works (again) with the correct mapping of ports
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-daemon-exit.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index aa96583c0..496ca25f8 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -154,12 +154,6 @@ struct LocalService
154 struct GNUNET_CADET_Port *port; 154 struct GNUNET_CADET_Port *port;
155 155
156 /** 156 /**
157 * Port I am listening on within GNUnet for this service, in host
158 * byte order. (as we may redirect ports).
159 */
160 uint16_t my_port;
161
162 /**
163 * #GNUNET_YES if this is a UDP service, otherwise TCP. 157 * #GNUNET_YES if this is a UDP service, otherwise TCP.
164 */ 158 */
165 int16_t is_udp; 159 int16_t is_udp;
@@ -836,31 +830,33 @@ store_service (int proto,
836 uint16_t destination_port, 830 uint16_t destination_port,
837 struct LocalService *service) 831 struct LocalService *service)
838{ 832{
839 char key[sizeof (struct GNUNET_HashCode) + sizeof (uint16_t)]; 833 struct GNUNET_HashCode cadet_port;
840 834
835 service->name = GNUNET_strdup (name);
841 GNUNET_TUN_service_name_to_hash (name, 836 GNUNET_TUN_service_name_to_hash (name,
842 &service->descriptor); 837 &service->descriptor);
843 service->name = GNUNET_strdup (name); 838 GNUNET_TUN_compute_service_cadet_port (&service->descriptor,
844 GNUNET_memcpy (&key[0], 839 destination_port,
845 &destination_port, 840 &cadet_port);
846 sizeof (uint16_t)); 841 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
847 GNUNET_memcpy (&key[sizeof(uint16_t)], 842 "Opening CADET port %s for SERVICE exit %s on port %u\n",
848 &service->descriptor, 843 GNUNET_h2s (&cadet_port),
849 sizeof (struct GNUNET_HashCode)); 844 name,
845 (unsigned int) destination_port);
850 service->port = GNUNET_CADET_open_port (cadet_handle, 846 service->port = GNUNET_CADET_open_port (cadet_handle,
851 &service->descriptor, 847 &cadet_port,
852 &new_service_channel, 848 &new_service_channel,
853 service); 849 service);
854 service->is_udp = (IPPROTO_UDP == proto); 850 service->is_udp = (IPPROTO_UDP == proto);
855 if (GNUNET_OK != 851 if (GNUNET_OK !=
856 GNUNET_CONTAINER_multihashmap_put (services, 852 GNUNET_CONTAINER_multihashmap_put (services,
857 (struct GNUNET_HashCode *) key, 853 &cadet_port,
858 service, 854 service,
859 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 855 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
860 { 856 {
861 free_service_record (NULL, 857 GNUNET_CADET_close_port (service->port);
862 (struct GNUNET_HashCode *) key, 858 GNUNET_free_non_null (service->name);
863 service); 859 GNUNET_free (service);
864 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 860 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
865 _("Got duplicate service records for `%s:%u'\n"), 861 _("Got duplicate service records for `%s:%u'\n"),
866 name, 862 name,
@@ -3322,8 +3318,8 @@ add_services (int proto,
3322 GNUNET_assert (slen >= 8); 3318 GNUNET_assert (slen >= 8);
3323 n = GNUNET_strndup (name, slen - 8 /* remove .gnunet. */); 3319 n = GNUNET_strndup (name, slen - 8 /* remove .gnunet. */);
3324 3320
3325 for (redirect = strtok (cpy, " "); redirect != NULL; 3321 for (redirect = strtok (cpy, " ;"); redirect != NULL;
3326 redirect = strtok (NULL, " ")) 3322 redirect = strtok (NULL, " ;"))
3327 { 3323 {
3328 if (NULL == (hostname = strstr (redirect, ":"))) 3324 if (NULL == (hostname = strstr (redirect, ":")))
3329 { 3325 {
@@ -3368,7 +3364,6 @@ add_services (int proto,
3368 3364
3369 serv = GNUNET_new (struct LocalService); 3365 serv = GNUNET_new (struct LocalService);
3370 serv->address.proto = proto; 3366 serv->address.proto = proto;
3371 serv->my_port = (uint16_t) local_port;
3372 serv->address.port = remote_port; 3367 serv->address.port = remote_port;
3373 if (0 == strcmp ("localhost4", 3368 if (0 == strcmp ("localhost4",
3374 hostname)) 3369 hostname))