forked from agorise/c-libp2p
Merge branch 'raduiliescu83-master'
This commit is contained in:
commit
d0c319a88c
29 changed files with 68 additions and 185 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,5 +1,3 @@
|
|||
*
|
||||
|
||||
!.gitignore
|
||||
!Makefile
|
||||
!**/
|
||||
|
@ -7,4 +5,8 @@
|
|||
*.o
|
||||
.settings/language.settings.xml
|
||||
*.a
|
||||
*.so
|
||||
*.so.*
|
||||
test/testit_libp2p
|
||||
cscope.files
|
||||
cscope.out
|
||||
|
|
9
.gitmodules
vendored
Normal file
9
.gitmodules
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
[submodule "c-multiaddr"]
|
||||
path = c-multiaddr
|
||||
url = https://github.com/Agorise/c-multiaddr.git
|
||||
[submodule "c-multihash"]
|
||||
path = c-multihash
|
||||
url = https://github.com/Agorise/c-multihash.git
|
||||
[submodule "c-protobuf"]
|
||||
path = c-protobuf
|
||||
url = https://github.com/Agorise/c-protobuf.git
|
90
Makefile
90
Makefile
|
@ -1,70 +1,38 @@
|
|||
SUBMODULES = c-multiaddr c-multihash c-protobuf
|
||||
COMPONENTS = conn crypto db thirdparty hashmap identify net os peer record routing secio swarm utils yamux
|
||||
|
||||
DEBUG = true
|
||||
export DEBUG
|
||||
export DEBUG = true
|
||||
export SHARED = true
|
||||
|
||||
LINKER_FLAGS=
|
||||
ROOT= $(shell pwd)
|
||||
export INCLUDE = -I$(ROOT)/include -I$(ROOT)/c-protobuf -I$(ROOT)/c-multihash/include -I$(ROOT)/c-multiaddr/include
|
||||
export CFLAGS = $(INCLUDE) -Wall -O0 -fPIC
|
||||
|
||||
OBJS = \
|
||||
conn/*.o \
|
||||
crypto/*.o \
|
||||
crypto/encoding/*.o \
|
||||
db/*.o \
|
||||
thirdparty/mbedtls/*.o \
|
||||
hashmap/hashmap.o \
|
||||
identify/*.o \
|
||||
net/*.o \
|
||||
os/*.o \
|
||||
peer/*.o \
|
||||
record/*.o \
|
||||
routing/*.o \
|
||||
secio/*.o \
|
||||
utils/*.o \
|
||||
swarm/*.o \
|
||||
yamux/*.o
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
link:
|
||||
ar rcs libp2p.a $(OBJS) $(LINKER_FLAGS)
|
||||
|
||||
compile:
|
||||
cd conn; make all;
|
||||
cd crypto; make all;
|
||||
cd db; make all;
|
||||
cd thirdparty; make all;
|
||||
cd hashmap; make all;
|
||||
cd identify; make all;
|
||||
cd net; make all;
|
||||
cd os; make all;
|
||||
cd peer; make all;
|
||||
cd record; make all;
|
||||
cd routing; make all;
|
||||
cd secio; make all;
|
||||
cd swarm; make all;
|
||||
cd utils; make all;
|
||||
cd yamux; make all;
|
||||
|
||||
test: compile link
|
||||
cd test; make all;
|
||||
|
||||
rebuild: clean all
|
||||
OBJS = $(shell (find $(COMPONENTS) -name *.o))
|
||||
|
||||
all: test
|
||||
|
||||
clean:
|
||||
cd conn; make clean;
|
||||
cd crypto; make clean;
|
||||
cd db; make clean;
|
||||
cd hashmap; make clean;
|
||||
cd identify; make clean;
|
||||
cd net; make clean;
|
||||
cd os; make clean;
|
||||
cd peer; make clean;
|
||||
cd thirdparty; make clean
|
||||
cd record; make clean;
|
||||
cd routing; make clean;
|
||||
cd secio; make clean;
|
||||
cd swarm; make clean;
|
||||
cd utils; make clean;
|
||||
cd test; make clean;
|
||||
cd yamux; make clean;
|
||||
rm -rf libp2p.a
|
||||
link: compile
|
||||
$(AR) rcs libp2p.a $(OBJS) $(LINKER_FLAGS)
|
||||
#ifdef SHARED
|
||||
gcc -shared -o libp2p.so $(OBJS) $(LINKER_FLAGS)
|
||||
#endif
|
||||
|
||||
compile:
|
||||
$(foreach dir,$(SUBMODULES), $(MAKE) -C $(dir) all ;)
|
||||
$(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) all ;)
|
||||
|
||||
test: link
|
||||
make -C test all;
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
clean:
|
||||
$(foreach dir,$(SUBMODULES), $(MAKE) -C $(dir) clean ;)
|
||||
$(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) clean ;)
|
||||
make -C test clean
|
||||
|
|
1
c-multiaddr
Submodule
1
c-multiaddr
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit b1f7d607eef3928d7153e87c2b551e0c713588df
|
1
c-multihash
Submodule
1
c-multihash
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 3a7a71c7fdbbea60498d25a27d9fd63d57f507c0
|
1
c-protobuf
Submodule
1
c-protobuf
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 1472282e313d65afd2a3884bcab9df7c39928c05
|
|
@ -1,13 +1,9 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = dialer.o transport_dialer.o connection.o tcp_transport_dialer.o session.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
clean:
|
||||
|
|
|
@ -26,7 +26,6 @@ struct TransportDialer* libp2p_conn_tcp_transport_dialer_new();
|
|||
* @returns a new Dialer struct
|
||||
*/
|
||||
struct Dialer* libp2p_conn_dialer_new(struct Libp2pPeer* peer, struct Peerstore* peerstore, struct RsaPrivateKey* rsa_private_key, struct SwarmContext* swarm) {
|
||||
int success = 0;
|
||||
struct Dialer* dialer = (struct Dialer*)malloc(sizeof(struct Dialer));
|
||||
if (dialer != NULL) {
|
||||
dialer->peerstore = peerstore;
|
||||
|
@ -166,7 +165,7 @@ int libp2p_conn_dialer_join_swarm(const struct Dialer* dialer, struct Libp2pPeer
|
|||
return 0;
|
||||
}
|
||||
// then get an identify
|
||||
struct Stream* identify_stream = libp2p_identify_stream_new(yamux_multistream, identify, 1);
|
||||
libp2p_identify_stream_new(yamux_multistream, identify, 1);
|
||||
}
|
||||
} else {
|
||||
libp2p_logger_error("dialer", "Expected a yamux context, but got a context of type %d.\n", peer->sessionContext->default_stream->stream_type);
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -g3
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = rsa.o sha256.o sha512.o sha1.o key.o peerutils.o ephemeral.o aes.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
cd encoding; make all;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../../include -g3 -std=c99
|
||||
LFLAGS =
|
||||
DEPS = ../../include/libp2p/crypto/encoding/base58.h ../../include/libp2p/crypto/encoding/base64.h \
|
||||
../../include/libp2p/crypto/encoding/x509.h ../../include/libp2p/crypto/encoding/base16.h \
|
||||
|
@ -7,8 +5,7 @@ DEPS = ../../include/libp2p/crypto/encoding/base58.h ../../include/libp2p/crypto
|
|||
OBJS = base58.o base64.o x509.o base16.o base32.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c99
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 -std=c99
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = datastore.o filestore.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c99
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -g3
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = hashmap.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -Werror -I../include -I../../c-protobuf -std=c11
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = identify.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c11
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
struct RsaPublicKey {
|
||||
char* der;
|
||||
unsigned char* der;
|
||||
size_t der_length;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ struct RsaPrivateKey {
|
|||
unsigned long long N;
|
||||
// the keys in DER format
|
||||
// private
|
||||
char* der;
|
||||
unsigned char* der;
|
||||
size_t der_length;
|
||||
// public
|
||||
char* public_key_der;
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = sctp.o socket.o tcp.o udp.o multistream.o protocol.o connectionstream.o stream.o server.o
|
||||
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -I../include -I../../c-protobuf
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = nodeio.o
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = utils.o memstream.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 -std=c11
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = peer.o peerstore.o providerstore.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c11
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -256,9 +256,7 @@ int libp2p_peer_protobuf_decode(unsigned char* in, size_t in_size, struct Libp2p
|
|||
int retVal = 0;
|
||||
char* buffer = NULL;
|
||||
size_t buffer_size = 0;
|
||||
struct Libp2pLinkedList* current = NULL;
|
||||
struct Libp2pLinkedList* last = NULL;
|
||||
struct MultiAddress* ma = NULL;
|
||||
|
||||
*out = libp2p_peer_new();
|
||||
if ( *out == NULL)
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = record.o message.o message_handler.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
DHT_DIR = dht
|
||||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I../../c-multiaddr/include -I$(DHT_DIR) -g3
|
||||
LFLAGS =
|
||||
DEPS = # $(DHT_DIR)/dht.h
|
||||
OBJS = kademlia.o dht.o dht_protocol.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -I$(DHT_DIR)
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -302,11 +302,6 @@ static int parse_message(const unsigned char *buf, int buflen,
|
|||
int *want_return);
|
||||
|
||||
static const unsigned char zeroes[20] = {0};
|
||||
static const unsigned char ones[20] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
static const unsigned char v4prefix[16] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0
|
||||
};
|
||||
|
|
|
@ -334,7 +334,6 @@ int libp2p_routing_dht_handle_add_provider(struct Stream* stream, struct Kademli
|
|||
int libp2p_routing_dht_handle_get_value(struct Stream* stream, struct KademliaMessage* message, struct DhtContext* dht_context,
|
||||
unsigned char** result_buffer, size_t *result_buffer_size) {
|
||||
|
||||
struct Datastore* datastore = dht_context->datastore;
|
||||
struct Filestore* filestore = dht_context->filestore;
|
||||
size_t data_size = 0;
|
||||
unsigned char* data = NULL;
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = exchange.o propose.o secio.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c99
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ int libp2p_secio_verify_signature(struct PublicKey* public_key, const unsigned c
|
|||
|
||||
if (public_key->type == KEYTYPE_RSA) {
|
||||
struct RsaPublicKey rsa_key = {0};
|
||||
rsa_key.der = (char*)public_key->data;
|
||||
rsa_key.der = public_key->data;
|
||||
rsa_key.der_length = public_key->data_size;
|
||||
return libp2p_crypto_rsa_verify(&rsa_key, in, in_length, signature);
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ int libp2p_secio_sign(struct PrivateKey* private_key, const char* in, size_t in_
|
|||
|
||||
if (private_key->type == KEYTYPE_RSA) {
|
||||
struct RsaPrivateKey rsa_key = {0};
|
||||
rsa_key.der = (char*)private_key->data;
|
||||
rsa_key.der = private_key->data;
|
||||
rsa_key.der_length = private_key->data_size;
|
||||
int retVal = libp2p_crypto_rsa_sign(&rsa_key, in, in_length, signature, signature_size);
|
||||
// debugging
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = swarm.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c99
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -I../include -I. -I../../c-multihash/include -I../../c-multiaddr/include -std=c11
|
||||
CFLAGS = $(INCLUDE) -O0 -std=c11
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS = -L../ -L../../c-multihash -L../../c-multiaddr
|
||||
LFLAGS = -L../ -L../c-multihash -L../c-multiaddr
|
||||
DEPS = crypto/test_base58.h crypto/test_rsa.h test_mbedtls.h
|
||||
OBJS = testit.o ../../c-protobuf/protobuf.o ../../c-protobuf/varint.o ../libp2p.a
|
||||
OBJS = testit.o ../c-protobuf/protobuf.o ../c-protobuf/varint.o ../libp2p.a
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -I../include -I../../c-multiaddr/include -std=c99
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = string_list.o vector.o linked_list.o logger.o urlencode.o thread_pool.o threadsafe_buffer.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c99
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O0 -Wall -Werror -I../include -I../../c-protobuf -std=c11
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
endif
|
||||
|
||||
LFLAGS =
|
||||
DEPS =
|
||||
OBJS = frame.o session.o stream.o yamux.o ../os/timespec.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -std=c11
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
|
|
Loading…
Reference in a new issue