Compare commits
No commits in common. "d0c319a88cd1f2cb3a219420b5a0b930e72562e2" and "8d3957f3b888adcd45cd5e3bd3e850fc885c93a6" have entirely different histories.
d0c319a88c
...
8d3957f3b8
13 changed files with 26 additions and 28 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,8 +5,4 @@
|
|||
*.o
|
||||
.settings/language.settings.xml
|
||||
*.a
|
||||
*.so
|
||||
*.so.*
|
||||
test/testit_libp2p
|
||||
cscope.files
|
||||
cscope.out
|
||||
|
|
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,9 +1,9 @@
|
|||
[submodule "c-multiaddr"]
|
||||
path = c-multiaddr
|
||||
url = https://github.com/Agorise/c-multiaddr.git
|
||||
url = https://github.com/raduiliescu83/c-multiaddr.git
|
||||
[submodule "c-multihash"]
|
||||
path = c-multihash
|
||||
url = https://github.com/Agorise/c-multihash.git
|
||||
url = https://github.com/raduiliescu83/c-multihash.git
|
||||
[submodule "c-protobuf"]
|
||||
path = c-protobuf
|
||||
url = https://github.com/Agorise/c-protobuf.git
|
||||
url = https://github.com/raduiliescu83/c-protobuf.git
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 AGORISE, LTD.
|
||||
Copyright (c) 2018 AGORISE, LTD.
|
||||
An International Business Company, Cyprus Reg# ΗΕ375959
|
||||
|
||||
Contains works from BitShares Munich IVS
|
||||
|
|
17
Makefile
17
Makefile
|
@ -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
|
||||
|
||||
export DEBUG = true
|
||||
export SHARED = true
|
||||
|
||||
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
|
||||
export CFLAGS = $(INCLUDE) -Wall -O0
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
@ -15,24 +13,19 @@ endif
|
|||
|
||||
OBJS = $(shell (find $(COMPONENTS) -name *.o))
|
||||
|
||||
all: test
|
||||
|
||||
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;
|
||||
test: compile link
|
||||
cd test; make all;
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
all: test
|
||||
|
||||
clean:
|
||||
$(foreach dir,$(SUBMODULES), $(MAKE) -C $(dir) clean ;)
|
||||
$(foreach dir,$(COMPONENTS), $(MAKE) -C $(dir) 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
|
|
@ -26,6 +26,7 @@ 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;
|
||||
|
@ -165,7 +166,7 @@ int libp2p_conn_dialer_join_swarm(const struct Dialer* dialer, struct Libp2pPeer
|
|||
return 0;
|
||||
}
|
||||
// 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 {
|
||||
libp2p_logger_error("dialer", "Expected a yamux context, but got a context of type %d.\n", peer->sessionContext->default_stream->stream_type);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
struct RsaPublicKey {
|
||||
unsigned char* der;
|
||||
char* der;
|
||||
size_t der_length;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ struct RsaPrivateKey {
|
|||
unsigned long long N;
|
||||
// the keys in DER format
|
||||
// private
|
||||
unsigned char* der;
|
||||
char* der;
|
||||
size_t der_length;
|
||||
// public
|
||||
char* public_key_der;
|
||||
|
|
|
@ -256,7 +256,9 @@ 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)
|
||||
|
|
|
@ -302,6 +302,11 @@ 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,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,
|
||||
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;
|
||||
|
|
|
@ -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 = public_key->data;
|
||||
rsa_key.der = (char*)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 = private_key->data;
|
||||
rsa_key.der = (char*)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
|
||||
|
|
Loading…
Reference in a new issue