From d15ec0b93def57e5f3832f429a3b948e86a62887 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 27 Jun 2019 20:33:06 -0400 Subject: finish p2p & TLS integration and testing --- src/conn.cpp | 10 ++++++---- src/network.cpp | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index ab08399..84f08a4 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -223,9 +223,13 @@ void ConnPool::Conn::_recv_data_tls_handshake(const conn_t &conn, int, int) { /* finishing TLS handshake */ conn->send_data_func = _send_data_tls; conn->recv_data_func = _recv_data_dummy; + conn->ev_socket.del(); + conn->ev_socket.add(FdEvent::WRITE); conn->peer_cert = new X509(conn->tls->get_peer_cert()); conn->worker->enable_send_buffer(conn, conn->fd); - conn->cpool->update_conn(conn, true); + auto cpool = conn->cpool; + cpool->on_setup(conn); + cpool->update_conn(conn, true); } else { @@ -301,7 +305,6 @@ void ConnPool::accept_client(int fd, int) { SALTICIDAE_LOG_INFO("accepted %s", std::string(*conn).c_str()); auto &worker = select_worker(); conn->worker = &worker; - on_setup(conn); worker.feed(conn, client_fd); } } catch (...) { recoverable_error(std::current_exception()); } @@ -315,14 +318,13 @@ void ConnPool::conn_server(const conn_t &conn, int fd, int events) { SALTICIDAE_LOG_INFO("connected to remote %s", std::string(*conn).c_str()); auto &worker = select_worker(); conn->worker = &worker; - on_setup(conn); worker.feed(conn, fd); } else { if (events & TimedFdEvent::TIMEOUT) SALTICIDAE_LOG_INFO("%s connect timeout", std::string(*conn).c_str()); - throw SalticidaeError(SALTI_ERROR_CONNECT); + throw SalticidaeError(SALTI_ERROR_CONNECT, errno); } } catch (...) { disp_terminate(conn); diff --git a/src/network.cpp b/src/network.cpp index 74f4df9..a02ead1 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -250,8 +250,8 @@ void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, Salti void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, msgnetwork_unknown_peer_callback_t cb, void *userdata) { - self->reg_unknown_peer_handler([=](const NetAddr &addr) { - cb(&addr, userdata); + self->reg_unknown_peer_handler([=](const NetAddr &claimed_addr) { + cb(&claimed_addr, userdata); }); } -- cgit v1.2.3-70-g09d2