Compare commits

..

No commits in common. "d0c319a88cd1f2cb3a219420b5a0b930e72562e2" and "8d3957f3b888adcd45cd5e3bd3e850fc885c93a6" have entirely different histories.

13 changed files with 26 additions and 28 deletions

4
.gitignore vendored
View file

@ -5,8 +5,4 @@
*.o *.o
.settings/language.settings.xml .settings/language.settings.xml
*.a *.a
*.so
*.so.*
test/testit_libp2p test/testit_libp2p
cscope.files
cscope.out

6
.gitmodules vendored
View file

@ -1,9 +1,9 @@
[submodule "c-multiaddr"] [submodule "c-multiaddr"]
path = c-multiaddr path = c-multiaddr
url = https://github.com/Agorise/c-multiaddr.git url = https://github.com/raduiliescu83/c-multiaddr.git
[submodule "c-multihash"] [submodule "c-multihash"]
path = c-multihash path = c-multihash
url = https://github.com/Agorise/c-multihash.git url = https://github.com/raduiliescu83/c-multihash.git
[submodule "c-protobuf"] [submodule "c-protobuf"]
path = c-protobuf path = c-protobuf
url = https://github.com/Agorise/c-protobuf.git url = https://github.com/raduiliescu83/c-protobuf.git

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019 AGORISE, LTD. Copyright (c) 2018 AGORISE, LTD.
An International Business Company, Cyprus Reg# ΗΕ375959 An International Business Company, Cyprus Reg# ΗΕ375959
Contains works from BitShares Munich IVS Contains works from BitShares Munich IVS

View file

@ -1,12 +1,10 @@
SUBMODULES = c-multiaddr c-multihash c-protobuf
COMPONENTS = conn crypto db thirdparty hashmap identify net os peer record routing secio swarm utils yamux COMPONENTS = conn crypto db thirdparty hashmap identify net os peer record routing secio swarm utils yamux
export DEBUG = true export DEBUG = true
export SHARED = true
ROOT= $(shell pwd) ROOT= $(shell pwd)
export INCLUDE = -I$(ROOT)/include -I$(ROOT)/c-protobuf -I$(ROOT)/c-multihash/include -I$(ROOT)/c-multiaddr/include 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 export CFLAGS = $(INCLUDE) -Wall -O0
ifdef DEBUG ifdef DEBUG
CFLAGS += -g3 CFLAGS += -g3
@ -15,24 +13,19 @@ endif
OBJS = $(shell (find $(COMPONENTS) -name *.o)) OBJS = $(shell (find $(COMPONENTS) -name *.o))
all: test
link: compile link: compile
$(AR) rcs libp2p.a $(OBJS) $(LINKER_FLAGS) $(AR) rcs libp2p.a $(OBJS) $(LINKER_FLAGS)
#ifdef SHARED
gcc -shared -o libp2p.so $(OBJS) $(LINKER_FLAGS)
#endif
compile: compile:
$(foreach dir,$(SUBMODULES), $(MAKE) -C $(dir) all ;)
$(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) all ;) $(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) all ;)
test: link test: compile link
make -C test all; cd test; make all;
rebuild: clean all rebuild: clean all
all: test
clean: clean:
$(foreach dir,$(SUBMODULES), $(MAKE) -C $(dir) clean ;)
$(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) clean ;) $(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) clean ;)
make -C test clean make -C test clean

@ -1 +1 @@
Subproject commit b1f7d607eef3928d7153e87c2b551e0c713588df Subproject commit a271e08996337eaadede798d785d18ec9515fd42

@ -1 +1 @@
Subproject commit 3a7a71c7fdbbea60498d25a27d9fd63d57f507c0 Subproject commit bc6c0830136d39c87b9f59a335d096db882418f6

@ -1 +1 @@
Subproject commit 1472282e313d65afd2a3884bcab9df7c39928c05 Subproject commit dceaa020823be04c9ed54fec8fb8b2537f440d26

View file

@ -26,6 +26,7 @@ struct TransportDialer* libp2p_conn_tcp_transport_dialer_new();
* @returns a new Dialer struct * @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) { 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)); struct Dialer* dialer = (struct Dialer*)malloc(sizeof(struct Dialer));
if (dialer != NULL) { if (dialer != NULL) {
dialer->peerstore = peerstore; dialer->peerstore = peerstore;
@ -165,7 +166,7 @@ int libp2p_conn_dialer_join_swarm(const struct Dialer* dialer, struct Libp2pPeer
return 0; return 0;
} }
// then get an identify // then get an identify
libp2p_identify_stream_new(yamux_multistream, identify, 1); struct Stream* identify_stream = libp2p_identify_stream_new(yamux_multistream, identify, 1);
} }
} else { } else {
libp2p_logger_error("dialer", "Expected a yamux context, but got a context of type %d.\n", peer->sessionContext->default_stream->stream_type); libp2p_logger_error("dialer", "Expected a yamux context, but got a context of type %d.\n", peer->sessionContext->default_stream->stream_type);

View file

@ -4,7 +4,7 @@
#include <stddef.h> #include <stddef.h>
struct RsaPublicKey { struct RsaPublicKey {
unsigned char* der; char* der;
size_t der_length; size_t der_length;
}; };
@ -20,7 +20,7 @@ struct RsaPrivateKey {
unsigned long long N; unsigned long long N;
// the keys in DER format // the keys in DER format
// private // private
unsigned char* der; char* der;
size_t der_length; size_t der_length;
// public // public
char* public_key_der; char* public_key_der;

View file

@ -256,7 +256,9 @@ int libp2p_peer_protobuf_decode(unsigned char* in, size_t in_size, struct Libp2p
int retVal = 0; int retVal = 0;
char* buffer = NULL; char* buffer = NULL;
size_t buffer_size = 0; size_t buffer_size = 0;
struct Libp2pLinkedList* current = NULL;
struct Libp2pLinkedList* last = NULL; struct Libp2pLinkedList* last = NULL;
struct MultiAddress* ma = NULL;
*out = libp2p_peer_new(); *out = libp2p_peer_new();
if ( *out == NULL) if ( *out == NULL)

View file

@ -302,6 +302,11 @@ static int parse_message(const unsigned char *buf, int buflen,
int *want_return); int *want_return);
static const unsigned char zeroes[20] = {0}; 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] = { static const unsigned char v4prefix[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0
}; };

View file

@ -334,6 +334,7 @@ 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, 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) { unsigned char** result_buffer, size_t *result_buffer_size) {
struct Datastore* datastore = dht_context->datastore;
struct Filestore* filestore = dht_context->filestore; struct Filestore* filestore = dht_context->filestore;
size_t data_size = 0; size_t data_size = 0;
unsigned char* data = NULL; unsigned char* data = NULL;

View file

@ -314,7 +314,7 @@ int libp2p_secio_verify_signature(struct PublicKey* public_key, const unsigned c
if (public_key->type == KEYTYPE_RSA) { if (public_key->type == KEYTYPE_RSA) {
struct RsaPublicKey rsa_key = {0}; struct RsaPublicKey rsa_key = {0};
rsa_key.der = public_key->data; rsa_key.der = (char*)public_key->data;
rsa_key.der_length = public_key->data_size; rsa_key.der_length = public_key->data_size;
return libp2p_crypto_rsa_verify(&rsa_key, in, in_length, signature); 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) { if (private_key->type == KEYTYPE_RSA) {
struct RsaPrivateKey rsa_key = {0}; struct RsaPrivateKey rsa_key = {0};
rsa_key.der = private_key->data; rsa_key.der = (char*)private_key->data;
rsa_key.der_length = private_key->data_size; rsa_key.der_length = private_key->data_size;
int retVal = libp2p_crypto_rsa_sign(&rsa_key, in, in_length, signature, signature_size); int retVal = libp2p_crypto_rsa_sign(&rsa_key, in, in_length, signature, signature_size);
// debugging // debugging