Beginnings of the dialer

yamux
John Jones 2017-02-13 08:47:55 -05:00
parent 910c07e951
commit 466bfe3fa4
4 changed files with 29 additions and 1 deletions

3
conn/dialer.c Normal file
View File

@ -0,0 +1,3 @@
/**
* Functions for handling the local dialer
*/

View File

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

View File

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

View File

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