From aa1ad0a0802e9baf66f4df561ec07490c54d63f4 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 31 Jul 2024 20:50:41 -0400 Subject: [PATCH] The beginnings of "What would it look like if I used a DHT for peer discovery?" --- .gitmodules | 3 +++ GNUmakefile | 5 +++++ deps/dht | 1 + src/dht.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 160000 deps/dht create mode 100644 src/dht.c diff --git a/.gitmodules b/.gitmodules index c7527e40..3a4d75e3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "deps/openssl_src"] path = deps/openssl_src url = https://github.com/openssl/openssl.git +[submodule "deps/dht"] + path = deps/dht + url = https://github.com/jech/dht.git diff --git a/GNUmakefile b/GNUmakefile index e69eb4e2..7ad09ae0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -250,6 +250,7 @@ APP_OBJS := $(call get_objs,APP_SOURCES) $(APP_OBJS): CFLAGS += \ -Ideps/base64c/include \ -Ideps/crypt_blowfish \ + -Ideps/dht \ -Ideps/libbacktrace \ -Ideps/libsodium \ -Ideps/libsodium/src/libsodium/include \ @@ -587,6 +588,9 @@ $(MINIUNZIP_OBJS): CFLAGS += \ -Ideps/zlib \ -Wno-maybe-uninitialized +DHT_SOURCES := deps/dht/dht.c +DHT_OBJS := $(call get_objs,DHT_SOURCES) + LDFLAGS += \ -pthread \ -lm @@ -633,6 +637,7 @@ all: $(BUILD_TYPES) ALL_APP_OBJS := \ $(APP_OBJS) \ $(BLOWFISH_OBJS) \ + $(DHT_OBJS) \ $(LIBBACKTRACE_OBJS) \ $(MINIUNZIP_OBJS) \ $(PICOHTTPPARSER_OBJS) \ diff --git a/deps/dht b/deps/dht new file mode 160000 index 00000000..11123089 --- /dev/null +++ b/deps/dht @@ -0,0 +1 @@ +Subproject commit 111230894416d400c9a1e038a033586bfeaafc93 diff --git a/src/dht.c b/src/dht.c new file mode 100644 index 00000000..07a67b9d --- /dev/null +++ b/src/dht.c @@ -0,0 +1,34 @@ +#include +#include + +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#else +#include +#include +#endif + +#include "dht.h" + +int dht_sendto(int sockfd, const void *buf, int len, int flags, const struct sockaddr *to, int tolen) +{ + return -1; +} + +int dht_blacklisted(const struct sockaddr *sa, int salen) +{ + return 0; +} + +void dht_hash(void *hash_return, int hash_size, const void *v1, int len1, const void *v2, int len2, const void *v3, int len3) +{ +} + +int dht_random_bytes(void *buf, size_t size) +{ + return 0; +}