diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_blacklist.c')
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 7720e467f..abb536414 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -161,8 +161,8 @@ static struct GNUNET_CONTAINER_MultiHashMap *blacklist; | |||
161 | * @param cls the 'struct BlacklistCheck*' | 161 | * @param cls the 'struct BlacklistCheck*' |
162 | * @param tc unused | 162 | * @param tc unused |
163 | */ | 163 | */ |
164 | static void | 164 | static void do_blacklist_check (void *cls, |
165 | do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 165 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
166 | 166 | ||
167 | 167 | ||
168 | /** | 168 | /** |
@@ -227,8 +227,7 @@ read_blacklist_file () | |||
227 | char *transport_name; | 227 | char *transport_name; |
228 | 228 | ||
229 | if (GNUNET_OK != | 229 | if (GNUNET_OK != |
230 | GNUNET_CONFIGURATION_get_value_filename (GST_cfg, | 230 | GNUNET_CONFIGURATION_get_value_filename (GST_cfg, "TRANSPORT", |
231 | "TRANSPORT", | ||
232 | "BLACKLIST_FILE", &fn)) | 231 | "BLACKLIST_FILE", &fn)) |
233 | { | 232 | { |
234 | #if DEBUG_TRANSPORT | 233 | #if DEBUG_TRANSPORT |
@@ -252,8 +251,8 @@ read_blacklist_file () | |||
252 | if (frstat.st_size == 0) | 251 | if (frstat.st_size == 0) |
253 | { | 252 | { |
254 | #if DEBUG_TRANSPORT | 253 | #if DEBUG_TRANSPORT |
255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), |
256 | _("Blacklist file `%s' is empty.\n"), fn); | 255 | fn); |
257 | #endif | 256 | #endif |
258 | GNUNET_free (fn); | 257 | GNUNET_free (fn); |
259 | return; | 258 | return; |
@@ -278,8 +277,7 @@ read_blacklist_file () | |||
278 | frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) | 277 | frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) |
279 | { | 278 | { |
280 | colon_pos = pos; | 279 | colon_pos = pos; |
281 | while ((colon_pos < frstat.st_size) && | 280 | while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') && |
282 | (data[colon_pos] != ':') && | ||
283 | (!isspace ((unsigned char) data[colon_pos]))) | 281 | (!isspace ((unsigned char) data[colon_pos]))) |
284 | colon_pos++; | 282 | colon_pos++; |
285 | if (colon_pos >= frstat.st_size) | 283 | if (colon_pos >= frstat.st_size) |
@@ -330,8 +328,8 @@ read_blacklist_file () | |||
330 | #endif | 328 | #endif |
331 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 329 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
332 | if (!isspace | 330 | if (!isspace |
333 | ((unsigned char) | 331 | ((unsigned char) enc. |
334 | enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) | 332 | encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) |
335 | { | 333 | { |
336 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 334 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
337 | _ | 335 | _ |
@@ -354,8 +352,8 @@ read_blacklist_file () | |||
354 | } | 352 | } |
355 | else | 353 | else |
356 | { | 354 | { |
357 | if (0 != memcmp (&pid, | 355 | if (0 != |
358 | &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) | 356 | memcmp (&pid, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) |
359 | { | 357 | { |
360 | entries_found++; | 358 | entries_found++; |
361 | GST_blacklist_add_peer (&pid, transport_name); | 359 | GST_blacklist_add_peer (&pid, transport_name); |
@@ -372,8 +370,7 @@ read_blacklist_file () | |||
372 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 370 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) |
373 | pos++; | 371 | pos++; |
374 | } | 372 | } |
375 | GNUNET_STATISTICS_update (GST_stats, | 373 | GNUNET_STATISTICS_update (GST_stats, "# Transport entries blacklisted", |
376 | "# Transport entries blacklisted", | ||
377 | entries_found, GNUNET_NO); | 374 | entries_found, GNUNET_NO); |
378 | GNUNET_free (data); | 375 | GNUNET_free (data); |
379 | GNUNET_free (fn); | 376 | GNUNET_free (fn); |
@@ -389,8 +386,8 @@ void | |||
389 | GST_blacklist_start (struct GNUNET_SERVER_Handle *server) | 386 | GST_blacklist_start (struct GNUNET_SERVER_Handle *server) |
390 | { | 387 | { |
391 | read_blacklist_file (); | 388 | read_blacklist_file (); |
392 | GNUNET_SERVER_disconnect_notify (server, | 389 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, |
393 | &client_disconnect_notification, NULL); | 390 | NULL); |
394 | } | 391 | } |
395 | 392 | ||
396 | 393 | ||
@@ -420,8 +417,8 @@ GST_blacklist_stop () | |||
420 | { | 417 | { |
421 | if (NULL != blacklist) | 418 | if (NULL != blacklist) |
422 | { | 419 | { |
423 | GNUNET_CONTAINER_multihashmap_iterate (blacklist, | 420 | GNUNET_CONTAINER_multihashmap_iterate (blacklist, &free_blacklist_entry, |
424 | &free_blacklist_entry, NULL); | 421 | NULL); |
425 | GNUNET_CONTAINER_multihashmap_destroy (blacklist); | 422 | GNUNET_CONTAINER_multihashmap_destroy (blacklist); |
426 | blacklist = NULL; | 423 | blacklist = NULL; |
427 | } | 424 | } |
@@ -498,12 +495,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
498 | if ((bl->bc != NULL) || (bl->waiting_for_reply != GNUNET_NO)) | 495 | if ((bl->bc != NULL) || (bl->waiting_for_reply != GNUNET_NO)) |
499 | return; /* someone else busy with this client */ | 496 | return; /* someone else busy with this client */ |
500 | bl->bc = bc; | 497 | bl->bc = bc; |
501 | bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, | 498 | bc->th = |
502 | sizeof (struct | 499 | GNUNET_SERVER_notify_transmit_ready (bl->client, |
503 | BlacklistMessage), | 500 | sizeof (struct BlacklistMessage), |
504 | GNUNET_TIME_UNIT_FOREVER_REL, | 501 | GNUNET_TIME_UNIT_FOREVER_REL, |
505 | &transmit_blacklist_message, | 502 | &transmit_blacklist_message, bc); |
506 | bc); | ||
507 | } | 503 | } |
508 | 504 | ||
509 | 505 | ||
@@ -517,14 +513,14 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
517 | * GNUNET_NO if we must shutdown the connection | 513 | * GNUNET_NO if we must shutdown the connection |
518 | */ | 514 | */ |
519 | static void | 515 | static void |
520 | confirm_or_drop_neighbour (void *cls, | 516 | confirm_or_drop_neighbour (void *cls, const struct GNUNET_PeerIdentity *peer, |
521 | const struct GNUNET_PeerIdentity *peer, int allowed) | 517 | int allowed) |
522 | { | 518 | { |
523 | if (GNUNET_OK == allowed) | 519 | if (GNUNET_OK == allowed) |
524 | return; /* we're done */ | 520 | return; /* we're done */ |
525 | GNUNET_STATISTICS_update (GST_stats, | 521 | GNUNET_STATISTICS_update (GST_stats, |
526 | gettext_noop ("# disconnects due to blacklist"), | 522 | gettext_noop ("# disconnects due to blacklist"), 1, |
527 | 1, GNUNET_NO); | 523 | GNUNET_NO); |
528 | GST_neighbours_force_disconnect (peer); | 524 | GST_neighbours_force_disconnect (peer); |
529 | } | 525 | } |
530 | 526 | ||
@@ -556,8 +552,7 @@ struct TestConnectionContext | |||
556 | * @param ats_count number of entries in ats (excluding 0-termination) | 552 | * @param ats_count number of entries in ats (excluding 0-termination) |
557 | */ | 553 | */ |
558 | static void | 554 | static void |
559 | test_connection_ok (void *cls, | 555 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, |
560 | const struct GNUNET_PeerIdentity *neighbour, | ||
561 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 556 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
562 | uint32_t ats_count) | 557 | uint32_t ats_count) |
563 | { | 558 | { |
@@ -591,8 +586,7 @@ test_connection_ok (void *cls, | |||
591 | * @param message the blacklist-init message that was sent | 586 | * @param message the blacklist-init message that was sent |
592 | */ | 587 | */ |
593 | void | 588 | void |
594 | GST_blacklist_handle_init (void *cls, | 589 | GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client, |
595 | struct GNUNET_SERVER_Client *client, | ||
596 | const struct GNUNET_MessageHeader *message) | 590 | const struct GNUNET_MessageHeader *message) |
597 | { | 591 | { |
598 | struct Blacklisters *bl; | 592 | struct Blacklisters *bl; |
@@ -629,8 +623,7 @@ GST_blacklist_handle_init (void *cls, | |||
629 | * @param message the blacklist-init message that was sent | 623 | * @param message the blacklist-init message that was sent |
630 | */ | 624 | */ |
631 | void | 625 | void |
632 | GST_blacklist_handle_reply (void *cls, | 626 | GST_blacklist_handle_reply (void *cls, struct GNUNET_SERVER_Client *client, |
633 | struct GNUNET_SERVER_Client *client, | ||
634 | const struct GNUNET_MessageHeader *message) | 627 | const struct GNUNET_MessageHeader *message) |
635 | { | 628 | { |
636 | const struct BlacklistMessage *msg = | 629 | const struct BlacklistMessage *msg = |
@@ -752,8 +745,7 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
752 | 745 | ||
753 | if ((blacklist != NULL) && | 746 | if ((blacklist != NULL) && |
754 | (GNUNET_SYSERR == | 747 | (GNUNET_SYSERR == |
755 | GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, | 748 | GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, &peer->hashPubKey, |
756 | &peer->hashPubKey, | ||
757 | &test_blacklisted, | 749 | &test_blacklisted, |
758 | (void *) transport_name))) | 750 | (void *) transport_name))) |
759 | { | 751 | { |