diff options
author | t3sserakt <t3ss@posteo.de> | 2023-01-27 13:11:14 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2023-01-27 13:11:14 +0100 |
commit | f5d40212ba3934b8138c6db29b0afe8b2fadd7d3 (patch) | |
tree | 4c38620b51e6f823cacb2f2fec3054405b34c206 | |
parent | 1a95d92b448b1dc77332781507cb6155b46c45b0 (diff) | |
download | gnunet-f5d40212ba3934b8138c6db29b0afe8b2fadd7d3.tar.gz gnunet-f5d40212ba3934b8138c6db29b0afe8b2fadd7d3.zip |
TNG: Fixed bug happening during check for pending validation requests after
nat reversal.
-rw-r--r-- | src/transport/gnunet-service-tng.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 5a28efb66..21aa46947 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -800,10 +800,7 @@ struct TransportDVBoxMessage | |||
800 | /** | 800 | /** |
801 | * Size this msg had initially. This is needed to calculate the hmac at the target. | 801 | * Size this msg had initially. This is needed to calculate the hmac at the target. |
802 | * The header size can not be used for that, because the box size is getting smaller at each hop. | 802 | * The header size can not be used for that, because the box size is getting smaller at each hop. |
803 | */ | 803 | * |
804 | /** | ||
805 | * The length of the struct (in bytes, including the length field itself), | ||
806 | * in big-endian format. | ||
807 | */ | 804 | */ |
808 | uint16_t orig_size GNUNET_PACKED; | 805 | uint16_t orig_size GNUNET_PACKED; |
809 | 806 | ||
@@ -10383,9 +10380,10 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address) | |||
10383 | } | 10380 | } |
10384 | /* forward suggestion for queue creation to communicator */ | 10381 | /* forward suggestion for queue creation to communicator */ |
10385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 10382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
10386 | "Request #%u for `%s' communicator to create queue to `%s'\n", | 10383 | "Request #%u for `%s' communicator to create queue to `%s' at `%s'\n", |
10387 | (unsigned int) idgen, | 10384 | (unsigned int) idgen, |
10388 | prefix, | 10385 | prefix, |
10386 | GNUNET_i2s (pid), | ||
10389 | address); | 10387 | address); |
10390 | GNUNET_free (prefix); | 10388 | GNUNET_free (prefix); |
10391 | alen = strlen (address) + 1; | 10389 | alen = strlen (address) + 1; |
@@ -10661,6 +10659,30 @@ start_dv_learn (void *cls) | |||
10661 | 10659 | ||
10662 | 10660 | ||
10663 | /** | 10661 | /** |
10662 | * Get the IP address without the port number. | ||
10663 | * | ||
10664 | * @param address The string contains a communicator prefix, IP address and port | ||
10665 | * like this 'tcp-92.68.150.1:55452'. | ||
10666 | * @return String with IP address only. | ||
10667 | */ | ||
10668 | static char * | ||
10669 | get_address_without_port (const char *address) | ||
10670 | { | ||
10671 | const char *colon; | ||
10672 | char *colon_rest; | ||
10673 | size_t colon_rest_length; | ||
10674 | char *address_without_port; | ||
10675 | |||
10676 | colon = strchr (address,':'); | ||
10677 | colon_rest = GNUNET_strndup (address, colon - address); | ||
10678 | colon_rest_length = strlen (colon_rest); | ||
10679 | address_without_port = GNUNET_strndup (&colon_rest[4], colon_rest_length - 4); | ||
10680 | GNUNET_free (colon_rest); | ||
10681 | |||
10682 | return address_without_port; | ||
10683 | } | ||
10684 | |||
10685 | /** | ||
10664 | * A new queue has been created, check if any address validation | 10686 | * A new queue has been created, check if any address validation |
10665 | * requests have been waiting for it. | 10687 | * requests have been waiting for it. |
10666 | * | 10688 | * |
@@ -10676,16 +10698,31 @@ check_validation_request_pending (void *cls, | |||
10676 | { | 10698 | { |
10677 | struct Queue *q = cls; | 10699 | struct Queue *q = cls; |
10678 | struct ValidationState *vs = value; | 10700 | struct ValidationState *vs = value; |
10701 | char *address_without_port_vs; | ||
10702 | char *address_without_port_q; | ||
10703 | int success = GNUNET_YES; | ||
10679 | 10704 | ||
10705 | address_without_port_vs = get_address_without_port (vs->address); | ||
10706 | address_without_port_q = get_address_without_port (q->address); | ||
10707 | |||
10708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
10709 | "Check validation request pending for `%s' at `%s'/`%s' (vs)/(q)\n", | ||
10710 | GNUNET_i2s (pid), | ||
10711 | address_without_port_vs, | ||
10712 | address_without_port_q); | ||
10680 | (void) pid; | 10713 | (void) pid; |
10681 | if ((GNUNET_YES == vs->awaiting_queue) && | 10714 | if ((GNUNET_YES == vs->awaiting_queue) && |
10682 | (0 == strcmp (vs->address, q->address))) | 10715 | (0 == strcmp (address_without_port_vs, address_without_port_q))) |
10683 | { | 10716 | { |
10717 | |||
10684 | vs->awaiting_queue = GNUNET_NO; | 10718 | vs->awaiting_queue = GNUNET_NO; |
10685 | validation_transmit_on_queue (q, vs); | 10719 | validation_transmit_on_queue (q, vs); |
10686 | return GNUNET_NO; | 10720 | success = GNUNET_NO; |
10687 | } | 10721 | } |
10688 | return GNUNET_OK; | 10722 | |
10723 | GNUNET_free (address_without_port_vs); | ||
10724 | GNUNET_free (address_without_port_q); | ||
10725 | return success; | ||
10689 | } | 10726 | } |
10690 | 10727 | ||
10691 | 10728 | ||