From bc16b8c176b7ffb2c9a57045b95d01358f020077 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Jan 2017 08:36:09 -0500 Subject: [PATCH] update git submodule and unbreak update --- i2pd | 2 +- routerinfo.cpp | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/i2pd b/i2pd index cee9f1d..b3ab85f 160000 --- a/i2pd +++ b/i2pd @@ -1 +1 @@ -Subproject commit cee9f1df95045b8d972d017780a7a8a82fcfd201 +Subproject commit b3ab85f3b538d0fab9194e5a33632e0e694e7705 diff --git a/routerinfo.cpp b/routerinfo.cpp index 9bc752b..572416b 100644 --- a/routerinfo.cpp +++ b/routerinfo.cpp @@ -9,22 +9,34 @@ static void usage(const char * argv) std::cout << "usage: " << argv << " [-6|-f|-p] routerinfo.dat" << std::endl; } +template +static std::string address_style_string(Addr addr) +{ + if(addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP) { + return "NTCP"; + } else if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) { + return "SSU"; + } + return "???"; + +} + template static void write_firewall_entry(std::ostream & o, Addr addr) { std::string proto; - if(addr.transportStyle == i2p::data::RouterInfo::eTransportNTCP) { + if(addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP) { proto = "tcp"; - } else if (addr.transportStyle == i2p::data::RouterInfo::eTransportSSU) { + } else if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) { proto = "udp"; } else { // bail return; } - + o << " -A OUTPUT -p " << proto; - o << " -d " << addr.host << " --dport " << addr.port; + o << " -d " << addr->host << " --dport " << addr->port; o << " -j ACCEPT"; } @@ -62,16 +74,18 @@ int main(int argc, char * argv[]) std::string fname(argv[idx]); i2p::data::RouterInfo ri(fname); - std::vector addrs; + std::vector > addrs; auto a = ri.GetNTCPAddress(!ipv6); if(a) - addrs.push_back(*a); + addrs.push_back(a); a = ri.GetSSUAddress(!ipv6); if(a) - addrs.push_back(*a); + addrs.push_back(a); if(firewall) std::cout << "# "; + else + std::cout << "Router Hash: "; std::cout << ri.GetIdentHashBase64() << std::endl; for (const auto & a : addrs) { @@ -79,10 +93,10 @@ int main(int argc, char * argv[]) if(firewall) { write_firewall_entry(std::cout, a); } else { - std::cout << a.host; + std::cout << address_style_string(a) << ": " << a->host; if (port) - std::cout << ":" << a.port; + std::cout << ":" << a->port; } std::cout << std::endl; }