diff options
-rw-r--r-- | include/salticidae/network.h | 8 | ||||
-rw-r--r-- | src/network.cpp | 4 | ||||
-rw-r--r-- | test/test_p2p.cpp | 2 | ||||
-rw-r--r-- | test/test_p2p_tls.cpp | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/include/salticidae/network.h b/include/salticidae/network.h index bece509..12392b2 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -298,7 +298,7 @@ class PeerNetwork: public MsgNetwork<OpcodeType> { using conn_t = ArcObj<Conn>; using peer_callback_t = std::function<void(const conn_t &peer_conn, bool connected)>; - using unknown_peer_callback_t = std::function<void(const NetAddr &claimed_addr)>; + using unknown_peer_callback_t = std::function<void(const NetAddr &claimed_addr, const X509 *cert)>; private: class Peer { @@ -779,8 +779,8 @@ void PeerNetwork<O, _, __>::ping_handler(MsgPing &&msg, const conn_t &conn) { pinfo_ulock_t __g(pid2peer_lock); if (!known_peers.count(msg.claimed_addr)) { - this->user_tcall->async_call([this, addr=msg.claimed_addr](ThreadCall::Handle &) { - if (unknown_peer_cb) unknown_peer_cb(addr); + this->user_tcall->async_call([this, addr=msg.claimed_addr, conn](ThreadCall::Handle &) { + if (unknown_peer_cb) unknown_peer_cb(addr, conn->get_peer_cert()); }); this->disp_terminate(conn); return; @@ -1269,7 +1269,7 @@ void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, Salti typedef void (*peernetwork_peer_callback_t)(const peernetwork_conn_t *, bool connected, void *userdata); void peernetwork_reg_peer_handler(peernetwork_t *self, peernetwork_peer_callback_t cb, void *userdata); -typedef void (*peernetwork_unknown_peer_callback_t)(const netaddr_t *, void *userdata); +typedef void (*peernetwork_unknown_peer_callback_t)(const netaddr_t *, const x509_t *, void *userdata); void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, peernetwork_unknown_peer_callback_t cb, void *userdata); /* ClientNetwork */ diff --git a/src/network.cpp b/src/network.cpp index adcac99..78f653b 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -262,8 +262,8 @@ void peernetwork_reg_peer_handler(peernetwork_t *self, void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, peernetwork_unknown_peer_callback_t cb, void *userdata) { - self->reg_unknown_peer_handler([=](const NetAddr &claimed_addr) { - cb(&claimed_addr, userdata); + self->reg_unknown_peer_handler([=](const NetAddr &claimed_addr, const salticidae::X509 *cert) { + cb(&claimed_addr, cert, userdata); }); } diff --git a/test/test_p2p.cpp b/test/test_p2p.cpp index 5fc930a..3a30ed2 100644 --- a/test/test_p2p.cpp +++ b/test/test_p2p.cpp @@ -93,7 +93,7 @@ struct Net { connected ? "connected to" : "disconnected from", std::string(conn->get_peer_addr()).c_str()); }); - net->reg_unknown_peer_handler([this](const NetAddr &claimed_addr) { + net->reg_unknown_peer_handler([this](const NetAddr &claimed_addr, const salticidae::X509 *) { fprintf(stdout, "net %lu: unknown peer %s attempts to connnect\n", this->id, std::string(claimed_addr).c_str()); }); diff --git a/test/test_p2p_tls.cpp b/test/test_p2p_tls.cpp index fa0487d..f814643 100644 --- a/test/test_p2p_tls.cpp +++ b/test/test_p2p_tls.cpp @@ -119,7 +119,7 @@ struct Net { std::string(conn->get_peer_addr()).c_str(), salticidae::get_hash(conn->get_peer_cert()->get_der()).to_hex().c_str()); }); - net->reg_unknown_peer_handler([this](const NetAddr &claimed_addr) { + net->reg_unknown_peer_handler([this](const NetAddr &claimed_addr, const salticidae::X509 *) { fprintf(stdout, "net %lu: unknown peer %s attempts to connnect\n", this->id, std::string(claimed_addr).c_str()); }); |