Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add blacklist callback.

  • Loading branch information...
commit 5e1819d191d77948c9ee3e7f7b5a56522276c2ff 1 parent 9eb0aae
@jech authored
Showing with 18 additions and 0 deletions.
  1. +6 −0 README
  2. +8 −0 dht-example.c
  3. +3 −0  dht.c
  4. +1 −0  dht.h
View
6 README
@@ -157,6 +157,12 @@ of the search.
In the case of DHT_EVENT_VALUES, data is a list of nodes in ``compact''
format -- 6 or 18 bytes per node. Its length in bytes is in data_len.
+* dht_blacklisted
+
+This is a function that takes an IP address and returns true if this
+address should be silently ignored. Do not use this feature unless you
+really must -- Kademlia supposes transitive reachability.
+
* dht_hash
This should compute a reasonably strong cryptographic hash of the passed
View
8 dht-example.c
@@ -409,6 +409,14 @@ main(int argc, char **argv)
exit(1);
}
+/* Functions called by the DHT. */
+
+int
+dht_blacklisted(const struct sockaddr *sa, int salen)
+{
+ return 0;
+}
+
/* We need to provide a reasonably strong cryptographic hashing function.
Here's how we'd do it if we had RSA's MD5 code. */
#if 0
View
3  dht.c
@@ -689,6 +689,9 @@ node_blacklisted(const struct sockaddr *sa, int salen)
if(salen > sizeof(struct sockaddr_storage))
abort();
+ if(dht_blacklisted(sa, salen))
+ return 1;
+
for(i = 0; i < DHT_MAX_BLACKLISTED; i++) {
if(memcmp(&blacklist[i], sa, salen) == 0)
return 1;
View
1  dht.h
@@ -50,6 +50,7 @@ int dht_get_nodes(struct sockaddr_in *sin, int *num,
int dht_uninit(void);
/* This must be provided by the user. */
+int dht_blacklisted(const struct sockaddr *sa, int salen);
void dht_hash(void *hash_return, int hash_size,
const void *v1, int len1,
const void *v2, int len2,
Please sign in to comment.
Something went wrong with that request. Please try again.