diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-12 08:15:28 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-12 08:15:28 +0100 |
commit | aca54f89d9d95caf1b3535185208b83274d937a7 (patch) | |
tree | 102a406571368c8852f741da9b9c2d2105ddf4db /src/dht/gnunet-service-dht_neighbours.c | |
parent | 3ecdd45a715c745fa3fd73bb67b808425e907b75 (diff) | |
download | gnunet-aca54f89d9d95caf1b3535185208b83274d937a7.tar.gz gnunet-aca54f89d9d95caf1b3535185208b83274d937a7.zip |
consider HELLOs also from PUTs, remove exact duplicates even if block type is unknown
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 9d27d6a88..d9495ce14 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -1284,6 +1284,31 @@ get_target_peers (const struct GNUNET_HashCode *key, | |||
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | 1286 | ||
1287 | /** | ||
1288 | * If we got a HELLO, consider it for our own routing table | ||
1289 | * | ||
1290 | * @param bd block data we got | ||
1291 | */ | ||
1292 | static void | ||
1293 | hello_check (const struct GDS_DATACACHE_BlockData *bd) | ||
1294 | { | ||
1295 | struct GNUNET_PeerIdentity pid; | ||
1296 | struct GNUNET_HELLO_Builder *b; | ||
1297 | |||
1298 | if (GNUNET_BLOCK_TYPE_DHT_URL_HELLO != bd->type) | ||
1299 | return; | ||
1300 | |||
1301 | b = GNUNET_HELLO_builder_from_block (bd->data, | ||
1302 | bd->data_size); | ||
1303 | if (GNUNET_YES != disable_try_connect) | ||
1304 | GNUNET_HELLO_builder_iterate (b, | ||
1305 | &pid, | ||
1306 | &GDS_try_connect, | ||
1307 | &pid); | ||
1308 | GNUNET_HELLO_builder_free (b); | ||
1309 | } | ||
1310 | |||
1311 | |||
1287 | enum GNUNET_GenericReturnValue | 1312 | enum GNUNET_GenericReturnValue |
1288 | GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, | 1313 | GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, |
1289 | enum GNUNET_DHT_RouteOption options, | 1314 | enum GNUNET_DHT_RouteOption options, |
@@ -1318,6 +1343,9 @@ GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, | |||
1318 | GNUNET_h2s (&bd->key), | 1343 | GNUNET_h2s (&bd->key), |
1319 | (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-", | 1344 | (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-", |
1320 | (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-"); | 1345 | (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-"); |
1346 | |||
1347 | /* if we got a HELLO, consider it for our own routing table */ | ||
1348 | hello_check (bd); | ||
1321 | GNUNET_CONTAINER_bloomfilter_add (bf, | 1349 | GNUNET_CONTAINER_bloomfilter_add (bf, |
1322 | &GDS_my_identity_hash); | 1350 | &GDS_my_identity_hash); |
1323 | GNUNET_STATISTICS_update (GDS_stats, | 1351 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -2470,20 +2498,7 @@ handle_dht_p2p_result (void *cls, | |||
2470 | } | 2498 | } |
2471 | 2499 | ||
2472 | /* if we got a HELLO, consider it for our own routing table */ | 2500 | /* if we got a HELLO, consider it for our own routing table */ |
2473 | if (GNUNET_BLOCK_TYPE_DHT_URL_HELLO == bd.type) | 2501 | hello_check (&bd); |
2474 | { | ||
2475 | struct GNUNET_PeerIdentity pid; | ||
2476 | struct GNUNET_HELLO_Builder *b; | ||
2477 | |||
2478 | b = GNUNET_HELLO_builder_from_block (bd.data, | ||
2479 | bd.data_size); | ||
2480 | if (GNUNET_YES != disable_try_connect) | ||
2481 | GNUNET_HELLO_builder_iterate (b, | ||
2482 | &pid, | ||
2483 | &GDS_try_connect, | ||
2484 | &pid); | ||
2485 | GNUNET_HELLO_builder_free (b); | ||
2486 | } | ||
2487 | 2502 | ||
2488 | /* First, check if 'peer' is already on the path, and if | 2503 | /* First, check if 'peer' is already on the path, and if |
2489 | so, truncate it instead of expanding. */ | 2504 | so, truncate it instead of expanding. */ |