The beginnings of "What would it look like if I used a DHT for peer discovery?"
Some checks failed
Build Tilde Friends / Build-All (push) Failing after 4m7s

This commit is contained in:
Cory McWilliams 2024-07-31 20:50:41 -04:00
parent 1bc492aef1
commit aa1ad0a080
4 changed files with 43 additions and 0 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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) \

1
deps/dht vendored Submodule

@ -0,0 +1 @@
Subproject commit 111230894416d400c9a1e038a033586bfeaafc93

34
src/dht.c Normal file
View File

@ -0,0 +1,34 @@
#include <stddef.h>
#include <stdio.h>
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include <winsock.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
#include <sys/socket.h>
#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;
}