diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_blacklist.c')
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 2bec6cb71..628943a42 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -182,7 +182,7 @@ static struct Blacklisters *bl_tail; | |||
182 | * Hashmap of blacklisted peers. Values are of type 'char *' (transport names), | 182 | * Hashmap of blacklisted peers. Values are of type 'char *' (transport names), |
183 | * can be NULL if we have no static blacklist. | 183 | * can be NULL if we have no static blacklist. |
184 | */ | 184 | */ |
185 | static struct GNUNET_CONTAINER_MultiHashMap *blacklist; | 185 | static struct GNUNET_CONTAINER_MultiPeerMap *blacklist; |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
@@ -254,9 +254,9 @@ blacklist_cfg_iter (void *cls, const char *section, | |||
254 | char *plugs; | 254 | char *plugs; |
255 | char *pos; | 255 | char *pos; |
256 | 256 | ||
257 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string2 (option, | 257 | if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (option, |
258 | strlen (option), | 258 | strlen (option), |
259 | &peer.hashPubKey)) | 259 | &peer.public_key)) |
260 | return; | 260 | return; |
261 | 261 | ||
262 | if ((NULL == value) || (0 == strcmp(value, ""))) | 262 | if ((NULL == value) || (0 == strcmp(value, ""))) |
@@ -334,7 +334,9 @@ GST_blacklist_start (struct GNUNET_SERVER_Handle *server, | |||
334 | * @return GNUNET_OK (continue to iterate) | 334 | * @return GNUNET_OK (continue to iterate) |
335 | */ | 335 | */ |
336 | static int | 336 | static int |
337 | free_blacklist_entry (void *cls, const struct GNUNET_HashCode * key, void *value) | 337 | free_blacklist_entry (void *cls, |
338 | const struct GNUNET_PeerIdentity *key, | ||
339 | void *value) | ||
338 | { | 340 | { |
339 | char *be = value; | 341 | char *be = value; |
340 | 342 | ||
@@ -351,9 +353,9 @@ GST_blacklist_stop () | |||
351 | { | 353 | { |
352 | if (NULL != blacklist) | 354 | if (NULL != blacklist) |
353 | { | 355 | { |
354 | GNUNET_CONTAINER_multihashmap_iterate (blacklist, &free_blacklist_entry, | 356 | GNUNET_CONTAINER_multipeermap_iterate (blacklist, &free_blacklist_entry, |
355 | NULL); | 357 | NULL); |
356 | GNUNET_CONTAINER_multihashmap_destroy (blacklist); | 358 | GNUNET_CONTAINER_multipeermap_destroy (blacklist); |
357 | blacklist = NULL; | 359 | blacklist = NULL; |
358 | } | 360 | } |
359 | } | 361 | } |
@@ -617,24 +619,25 @@ void | |||
617 | GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, | 619 | GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, |
618 | const char *transport_name) | 620 | const char *transport_name) |
619 | { | 621 | { |
620 | char * transport = NULL; | 622 | char * transport = NULL; |
621 | if (NULL != transport_name) | 623 | |
622 | { | 624 | if (NULL != transport_name) |
623 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 625 | { |
624 | "Adding peer `%s' with plugin `%s' to blacklist\n", | 626 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
625 | GNUNET_i2s (peer), transport_name); | 627 | "Adding peer `%s' with plugin `%s' to blacklist\n", |
626 | transport = GNUNET_strdup (transport_name); | 628 | GNUNET_i2s (peer), transport_name); |
627 | } | 629 | transport = GNUNET_strdup (transport_name); |
628 | else | 630 | } |
629 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 631 | else |
630 | "Adding peer `%s' with all plugins to blacklist\n", | 632 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
631 | GNUNET_i2s (peer)); | 633 | "Adding peer `%s' with all plugins to blacklist\n", |
634 | GNUNET_i2s (peer)); | ||
632 | if (blacklist == NULL) | 635 | if (blacklist == NULL) |
633 | blacklist = | 636 | blacklist = |
634 | GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE, | 637 | GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE, |
635 | GNUNET_NO); | 638 | GNUNET_NO); |
636 | 639 | ||
637 | GNUNET_CONTAINER_multihashmap_put (blacklist, &peer->hashPubKey, | 640 | GNUNET_CONTAINER_multipeermap_put (blacklist, peer, |
638 | transport, | 641 | transport, |
639 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 642 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
640 | } | 643 | } |
@@ -647,10 +650,12 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, | |||
647 | * @param cls the transport name to match (const char*) | 650 | * @param cls the transport name to match (const char*) |
648 | * @param key the key (unused) | 651 | * @param key the key (unused) |
649 | * @param value the 'char *' (name of a blacklisted transport) | 652 | * @param value the 'char *' (name of a blacklisted transport) |
650 | * @return GNUNET_OK if the entry does not match, GNUNET_NO if it matches | 653 | * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches |
651 | */ | 654 | */ |
652 | static int | 655 | static int |
653 | test_blacklisted (void *cls, const struct GNUNET_HashCode * key, void *value) | 656 | test_blacklisted (void *cls, |
657 | const struct GNUNET_PeerIdentity *key, | ||
658 | void *value) | ||
654 | { | 659 | { |
655 | const char *transport_name = cls; | 660 | const char *transport_name = cls; |
656 | char *be = value; | 661 | char *be = value; |
@@ -665,10 +670,10 @@ test_blacklisted (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
665 | */ | 670 | */ |
666 | 671 | ||
667 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 672 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
668 | "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n", | 673 | "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n", |
669 | GNUNET_h2s (key), | 674 | GNUNET_i2s (key), |
670 | (NULL == transport_name) ? "unspecified" : transport_name, | 675 | (NULL == transport_name) ? "unspecified" : transport_name, |
671 | (NULL == be) ? "all plugins" : be); | 676 | (NULL == be) ? "all plugins" : be); |
672 | /* all plugins for this peer were blacklisted: disallow */ | 677 | /* all plugins for this peer were blacklisted: disallow */ |
673 | if (NULL == value) | 678 | if (NULL == value) |
674 | return GNUNET_NO; | 679 | return GNUNET_NO; |
@@ -708,7 +713,7 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
708 | * If iteration is aborted, we found a matching blacklist entry */ | 713 | * If iteration is aborted, we found a matching blacklist entry */ |
709 | if ((blacklist != NULL) && | 714 | if ((blacklist != NULL) && |
710 | (GNUNET_SYSERR == | 715 | (GNUNET_SYSERR == |
711 | GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, &peer->hashPubKey, | 716 | GNUNET_CONTAINER_multipeermap_get_multiple (blacklist, peer, |
712 | &test_blacklisted, | 717 | &test_blacklisted, |
713 | (void *) transport_name))) | 718 | (void *) transport_name))) |
714 | { | 719 | { |