aboutsummaryrefslogtreecommitdiff
path: root/test/test_p2p.cpp
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-13 17:59:59 -0400
committerDeterminant <[email protected]>2019-06-13 17:59:59 -0400
commit5eaa90dba2e0720abb2f8b0f858d54ae544ff4d0 (patch)
treee94076c681713e5f109ae3f70b7a63a99a8189d9 /test/test_p2p.cpp
parent76e6831168a25bc3aba8802f1586d0a0ab0dc4a2 (diff)
support unknown peer callback
Diffstat (limited to 'test/test_p2p.cpp')
-rw-r--r--test/test_p2p.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/test_p2p.cpp b/test/test_p2p.cpp
index 28bab10..85aeca1 100644
--- a/test/test_p2p.cpp
+++ b/test/test_p2p.cpp
@@ -58,6 +58,9 @@ struct Net {
net->reg_error_handler([this](const std::exception &err, bool fatal) {
fprintf(stdout, "net %lu: captured %s error during an async call: %s\n", this->id, fatal ? "fatal" : "recoverable", err.what());
});
+ net->reg_unknown_peer_handler([this](const NetAddr &addr) {
+ fprintf(stdout, "net %lu: unknown peer attempts to connnect %s\n", this->id, std::string(addr).c_str());
+ });
th = std::thread([=](){
try {
net->start();
@@ -117,7 +120,10 @@ int main(int argc, char **argv) {
auto cmd_exit = [](char *) {
for (auto &p: nets)
+ {
p.second->stop_join();
+ delete p.second;
+ }
exit(0);
};
@@ -141,7 +147,7 @@ int main(int argc, char **argv) {
auto cmd_ls = [](char *) {
for (auto &p: nets)
- fprintf(stdout, "%d\n", p.first);
+ fprintf(stdout, "%d -> %s\n", p.first, p.second->listen_addr.c_str());
};
auto cmd_del = [](char *buff) {