Beginnings of the dialer
This commit is contained in:
parent
910c07e951
commit
466bfe3fa4
4 changed files with 29 additions and 1 deletions
3
conn/dialer.c
Normal file
3
conn/dialer.c
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/**
|
||||||
|
* Functions for handling the local dialer
|
||||||
|
*/
|
24
include/libp2p/conn/dialer.h
Normal file
24
include/libp2p/conn/dialer.h
Normal 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
|
||||||
|
};
|
|
@ -389,6 +389,7 @@ int libp2p_secio_write(struct SecureSession* session, unsigned char* bytes, size
|
||||||
left = left - written_this_time;
|
left = left - written_this_time;
|
||||||
} while (left > 0);
|
} while (left > 0);
|
||||||
// then send the actual data
|
// then send the actual data
|
||||||
|
fprintf(stderr, "About to send %lu bytes (aka %u)\n", data_length, size);
|
||||||
left = data_length;
|
left = data_length;
|
||||||
written = 0;
|
written = 0;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -42,7 +42,7 @@ int test_secio_handshake() {
|
||||||
if (!libp2p_crypto_rsa_private_key_fill_public_key(rsa_private_key))
|
if (!libp2p_crypto_rsa_private_key_fill_public_key(rsa_private_key))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
secure_session.host = "www.jmjatlanta.com";
|
secure_session.host = "10.0.1.9";
|
||||||
secure_session.port = 4001;
|
secure_session.port = 4001;
|
||||||
secure_session.traffic_type = TCP;
|
secure_session.traffic_type = TCP;
|
||||||
// connect to host
|
// connect to host
|
||||||
|
|
Loading…
Reference in a new issue