From 466bfe3fa46b80a7343ed44e9b1f1213dcd5665f Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 13 Feb 2017 08:47:55 -0500 Subject: [PATCH] Beginnings of the dialer --- conn/dialer.c | 3 +++ include/libp2p/conn/dialer.h | 24 ++++++++++++++++++++++++ secio/secio.c | 1 + test/test_secio.h | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 conn/dialer.c create mode 100644 include/libp2p/conn/dialer.h diff --git a/conn/dialer.c b/conn/dialer.c new file mode 100644 index 0000000..ed0dbcf --- /dev/null +++ b/conn/dialer.c @@ -0,0 +1,3 @@ +/** + * Functions for handling the local dialer + */ diff --git a/include/libp2p/conn/dialer.h b/include/libp2p/conn/dialer.h new file mode 100644 index 0000000..8d610a0 --- /dev/null +++ b/include/libp2p/conn/dialer.h @@ -0,0 +1,24 @@ +/*** + * A local dialer. Uses MultiAddr to figure out the best way to + * connect to a client. + */ + +#include "libp2p/crypto/key.h" + +struct Dialer { + /** + * These two are used to create connections + */ + char* peer_id; // the local peer ID as null terminated string + struct PrivateKey* private_key; // used to initiate secure connections, can be NULL, and connections will not be secured + + /** + * A linked list of transport dialers. A transport dialer can be selected + * based on the MultiAddr being dialed. Most common: TCP and UDP + */ + struct TransportDialer* transport_dialers; + + //TODO: See dial.go, need to implement Protector + + struct TransportDialer* fallback_dialer; // the default dialer +}; diff --git a/secio/secio.c b/secio/secio.c index ce382ca..4c00ecc 100644 --- a/secio/secio.c +++ b/secio/secio.c @@ -389,6 +389,7 @@ int libp2p_secio_write(struct SecureSession* session, unsigned char* bytes, size left = left - written_this_time; } while (left > 0); // then send the actual data + fprintf(stderr, "About to send %lu bytes (aka %u)\n", data_length, size); left = data_length; written = 0; do { diff --git a/test/test_secio.h b/test/test_secio.h index 95dce24..11cb89b 100644 --- a/test/test_secio.h +++ b/test/test_secio.h @@ -42,7 +42,7 @@ int test_secio_handshake() { if (!libp2p_crypto_rsa_private_key_fill_public_key(rsa_private_key)) goto exit; - secure_session.host = "www.jmjatlanta.com"; + secure_session.host = "10.0.1.9"; secure_session.port = 4001; secure_session.traffic_type = TCP; // connect to host