aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2024-03-15 07:21:59 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2024-03-15 07:21:59 +0100
commite61c68d969f826d2c69690c30230f28658369c58 (patch)
tree32fa523adc7244b383a5ebb7baf2fadc2a73de29
parentbfe72f857072846102e031e4064100921399624b (diff)
downloadgnunet-e61c68d969f826d2c69690c30230f28658369c58.tar.gz
gnunet-e61c68d969f826d2c69690c30230f28658369c58.zip
TRANSPORT(tcp): Cleanup and actually handle DISABLE_V6 setting.
-rw-r--r--src/service/transport/gnunet-communicator-tcp.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/service/transport/gnunet-communicator-tcp.c b/src/service/transport/gnunet-communicator-tcp.c
index c1e1c66c8..2ff7c4fc7 100644
--- a/src/service/transport/gnunet-communicator-tcp.c
+++ b/src/service/transport/gnunet-communicator-tcp.c
@@ -27,6 +27,7 @@
27 * - support NAT connection reversal method (#5529) 27 * - support NAT connection reversal method (#5529)
28 * - support other TCP-specific NAT traversal methods (#5531) 28 * - support other TCP-specific NAT traversal methods (#5531)
29 */ 29 */
30#include "gnunet_common.h"
30#include "platform.h" 31#include "platform.h"
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
32#include "gnunet_core_service.h" 33#include "gnunet_core_service.h"
@@ -885,28 +886,17 @@ struct GNUNET_RESOLVER_RequestHandle *resolve_request_handle;
885/** 886/**
886 * Head of DLL with addresses we like to register at NAT servcie. 887 * Head of DLL with addresses we like to register at NAT servcie.
887 */ 888 */
888struct Addresses *addrs_head; 889static struct Addresses *addrs_head;
889 890
890/** 891/**
891 * Head of DLL with addresses we like to register at NAT servcie. 892 * Head of DLL with addresses we like to register at NAT servcie.
892 */ 893 */
893struct Addresses *addrs_tail; 894static struct Addresses *addrs_tail;
894
895/**
896 * Head of DLL with ListenTasks.
897 */
898struct ListenTask *lts_head;
899
900/**
901 * Head of DLL with ListenTask.
902 */
903struct ListenTask *lts_tail;
904 895
905/** 896/**
906 * Number of addresses in the DLL for register at NAT service. 897 * Number of addresses in the DLL for register at NAT service.
907 */ 898 */
908int addrs_lens; 899static int addrs_lens;
909
910 900
911/** 901/**
912 * Database for peer's HELLOs. 902 * Database for peer's HELLOs.
@@ -914,19 +904,24 @@ int addrs_lens;
914static struct GNUNET_PEERSTORE_Handle *peerstore; 904static struct GNUNET_PEERSTORE_Handle *peerstore;
915 905
916/** 906/**
917 * A flag indicating we are already doing a shutdown. 907* A flag indicating we are already doing a shutdown.
908*/
909static int shutdown_running = GNUNET_NO;
910
911/**
912 * IPv6 disabled.
918 */ 913 */
919int shutdown_running = GNUNET_NO; 914static int disable_v6;
920 915
921/** 916/**
922 * The port the communicator should be assigned to. 917 * The port the communicator should be assigned to.
923 */ 918 */
924unsigned int bind_port; 919static unsigned int bind_port;
925 920
926/** 921/**
927 * Map of pending reversals. 922 * Map of pending reversals.
928 */ 923 */
929struct GNUNET_CONTAINER_MultiHashMap *pending_reversals; 924static struct GNUNET_CONTAINER_MultiHashMap *pending_reversals;
930 925
931/** 926/**
932 * We have been notified that our listen socket has something to 927 * We have been notified that our listen socket has something to
@@ -1921,7 +1916,8 @@ try_handle_plaintext (struct Queue *queue)
1921 if (sizeof(*tca) > queue->pread_off) 1916 if (sizeof(*tca) > queue->pread_off)
1922 { 1917 {
1923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1918 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1924 "Handling plaintext size of tca greater than pread offset.\n"); 1919 "Handling plaintext size of tca greater than pread offset.\n")
1920 ;
1925 return 0; 1921 return 0;
1926 } 1922 }
1927 if (ntohs (hdr->size) != sizeof(*tca)) 1923 if (ntohs (hdr->size) != sizeof(*tca))
@@ -2329,11 +2325,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2329 2325
2330 po = GNUNET_new (struct PortOnlyIpv4Ipv6); 2326 po = GNUNET_new (struct PortOnlyIpv4Ipv6);
2331 2327
2332 if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) || 2328 if (GNUNET_YES == disable_v6)
2333 (GNUNET_YES ==
2334 GNUNET_CONFIGURATION_get_value_yesno (cfg,
2335 COMMUNICATOR_CONFIG_SECTION,
2336 "DISABLE_V6")))
2337 { 2329 {
2338 i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); 2330 i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
2339 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4, 2331 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
@@ -2534,7 +2526,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2534 2526
2535 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 2527 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
2536 { 2528 {
2537 // colon = strrchr (cp, ':');
2538 port = extract_port (bindto); 2529 port = extract_port (bindto);
2539 2530
2540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2545,7 +2536,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2545 } 2536 }
2546 else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) 2537 else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
2547 { 2538 {
2548 // colon = strrchr (cp, ':');
2549 port = extract_port (bindto); 2539 port = extract_port (bindto);
2550 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); 2540 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port);
2551 } 2541 }
@@ -3349,11 +3339,11 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
3349 "in %s\n", 3339 "in %s\n",
3350 GNUNET_a2s (in, in_len)); 3340 GNUNET_a2s (in, in_len));
3351 3341
3352 hsh = GNUNET_CRYPTO_hash_context_start(); 3342 hsh = GNUNET_CRYPTO_hash_context_start ();
3353 GNUNET_CRYPTO_hash_context_read (hsh, address, strlen (address)); 3343 GNUNET_CRYPTO_hash_context_read (hsh, address, strlen (address));
3354 GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof (*peer)); 3344 GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof (*peer));
3355 GNUNET_CRYPTO_hash_context_finish (hsh, &queue_map_key); 3345 GNUNET_CRYPTO_hash_context_finish (hsh, &queue_map_key);
3356 queue = GNUNET_CONTAINER_multihashmap_get(queue_map, &queue_map_key); 3346 queue = GNUNET_CONTAINER_multihashmap_get (queue_map, &queue_map_key);
3357 3347
3358 if (NULL != queue) 3348 if (NULL != queue)
3359 { 3349 {
@@ -3386,6 +3376,13 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
3386 break; 3376 break;
3387 3377
3388 case AF_INET6: 3378 case AF_INET6:
3379 if (GNUNET_YES == disable_v6)
3380 {
3381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3382 "IPv6 disabled, skipping %s\n", address);
3383 GNUNET_free (in);
3384 return GNUNET_SYSERR;
3385 }
3389 v6 = (struct sockaddr_in6 *) in; 3386 v6 = (struct sockaddr_in6 *) in;
3390 if (0 == v6->sin6_port) 3387 if (0 == v6->sin6_port)
3391 { 3388 {
@@ -4064,6 +4061,15 @@ run (void *cls,
4064 { 4061 {
4065 rekey_max_bytes = REKEY_MAX_BYTES; 4062 rekey_max_bytes = REKEY_MAX_BYTES;
4066 } 4063 }
4064 disable_v6 = GNUNET_NO;
4065 if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) ||
4066 (GNUNET_YES ==
4067 GNUNET_CONFIGURATION_get_value_yesno (cfg,
4068 COMMUNICATOR_CONFIG_SECTION,
4069 "DISABLE_V6")))
4070 {
4071 disable_v6 = GNUNET_YES;
4072 }
4067 peerstore = GNUNET_PEERSTORE_connect (cfg); 4073 peerstore = GNUNET_PEERSTORE_connect (cfg);
4068 if (NULL == peerstore) 4074 if (NULL == peerstore)
4069 { 4075 {