aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-tng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r--src/transport/gnunet-service-tng.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index a8f70986b..95ea102df 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -2546,6 +2546,16 @@ static struct PendingAcknowledgement *pa_tail;
2546 */ 2546 */
2547static unsigned int pa_count; 2547static unsigned int pa_count;
2548 2548
2549/**
2550 * Monotonic time we use for HELLOs generated at this time. TODO: we
2551 * should increase this value from time to time (i.e. whenever a
2552 * `struct AddressListEntry` actually expires), but IF we do this, we
2553 * must also update *all* (remaining) addresses in the PEERSTORE at
2554 * that time! (So for now only increased when the peer is restarted,
2555 * which hopefully roughly matches whenever our addresses change.)
2556 */
2557static struct GNUNET_TIME_Absolute hello_mono_time;
2558
2549 2559
2550/** 2560/**
2551 * Get an offset into the transmission history buffer for `struct 2561 * Get an offset into the transmission history buffer for `struct
@@ -4657,7 +4667,7 @@ store_pi (void *cls)
4657 expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); 4667 expiration = GNUNET_TIME_relative_to_absolute (ale->expiration);
4658 GNUNET_HELLO_sign_address (ale->address, 4668 GNUNET_HELLO_sign_address (ale->address,
4659 ale->nt, 4669 ale->nt,
4660 expiration, 4670 hello_mono_time,
4661 GST_my_private_key, 4671 GST_my_private_key,
4662 &addr, 4672 &addr,
4663 &addr_len); 4673 &addr_len);
@@ -8442,19 +8452,15 @@ check_known_address (void *cls,
8442 * 8452 *
8443 * @param pid peer the @a address is for 8453 * @param pid peer the @a address is for
8444 * @param address an address to reach @a pid (presumably) 8454 * @param address an address to reach @a pid (presumably)
8445 * @param expiration when did @a pid claim @a address will become invalid
8446 */ 8455 */
8447static void 8456static void
8448start_address_validation (const struct GNUNET_PeerIdentity *pid, 8457start_address_validation (const struct GNUNET_PeerIdentity *pid,
8449 const char *address, 8458 const char *address)
8450 struct GNUNET_TIME_Absolute expiration)
8451{ 8459{
8452 struct GNUNET_TIME_Absolute now; 8460 struct GNUNET_TIME_Absolute now;
8453 struct ValidationState *vs; 8461 struct ValidationState *vs;
8454 struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL}; 8462 struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL};
8455 8463
8456 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
8457 return; /* expired */
8458 (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, 8464 (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
8459 pid, 8465 pid,
8460 &check_known_address, 8466 &check_known_address,
@@ -8479,7 +8485,8 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
8479 now = GNUNET_TIME_absolute_get (); 8485 now = GNUNET_TIME_absolute_get ();
8480 vs = GNUNET_new (struct ValidationState); 8486 vs = GNUNET_new (struct ValidationState);
8481 vs->pid = *pid; 8487 vs->pid = *pid;
8482 vs->valid_until = expiration; 8488 vs->valid_until =
8489 GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME);
8483 vs->first_challenge_use = now; 8490 vs->first_challenge_use = now;
8484 vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; 8491 vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL;
8485 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, 8492 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
@@ -8524,9 +8531,7 @@ handle_hello (void *cls,
8524 GNUNET_break (0); 8531 GNUNET_break (0);
8525 return; 8532 return;
8526 } 8533 }
8527 start_address_validation (&pr->pid, 8534 start_address_validation (&pr->pid, (const char *) record->value);
8528 (const char *) record->value,
8529 record->expiry);
8530} 8535}
8531 8536
8532 8537
@@ -8602,7 +8607,7 @@ handle_address_consider_verify (
8602 struct TransportClient *tc = cls; 8607 struct TransportClient *tc = cls;
8603 char *address; 8608 char *address;
8604 enum GNUNET_NetworkType nt; 8609 enum GNUNET_NetworkType nt;
8605 struct GNUNET_TIME_Absolute expiration; 8610 struct GNUNET_TIME_Absolute mono_time;
8606 8611
8607 (void) cls; 8612 (void) cls;
8608 // OPTIMIZE-FIXME: checking that we know this address already should 8613 // OPTIMIZE-FIXME: checking that we know this address already should
@@ -8614,13 +8619,13 @@ handle_address_consider_verify (
8614 ntohs (hdr->header.size) - sizeof (*hdr), 8619 ntohs (hdr->header.size) - sizeof (*hdr),
8615 &hdr->peer, 8620 &hdr->peer,
8616 &nt, 8621 &nt,
8617 &expiration); 8622 &mono_time);
8618 if (NULL == address) 8623 if (NULL == address)
8619 { 8624 {
8620 GNUNET_break_op (0); 8625 GNUNET_break_op (0);
8621 return; 8626 return;
8622 } 8627 }
8623 start_address_validation (&hdr->peer, address, expiration); 8628 start_address_validation (&hdr->peer, address);
8624 GNUNET_free (address); 8629 GNUNET_free (address);
8625 GNUNET_SERVICE_client_continue (tc->client); 8630 GNUNET_SERVICE_client_continue (tc->client);
8626} 8631}
@@ -8657,9 +8662,7 @@ handle_request_hello_validation (void *cls,
8657{ 8662{
8658 struct TransportClient *tc = cls; 8663 struct TransportClient *tc = cls;
8659 8664
8660 start_address_validation (&m->peer, 8665 start_address_validation (&m->peer, (const char *) &m[1]);
8661 (const char *) &m[1],
8662 GNUNET_TIME_absolute_ntoh (m->expiration));
8663 GNUNET_SERVICE_client_continue (tc->client); 8666 GNUNET_SERVICE_client_continue (tc->client);
8664} 8667}
8665 8668
@@ -8895,6 +8898,7 @@ run (void *cls,
8895 (void) cls; 8898 (void) cls;
8896 (void) service; 8899 (void) service;
8897 /* setup globals */ 8900 /* setup globals */
8901 hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c);
8898 GST_cfg = c; 8902 GST_cfg = c;
8899 backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); 8903 backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
8900 pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES); 8904 pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES);