Browse Source

update git submodule and unbreak update

pull/8/head
Jeff Becker 8 years ago
parent
commit
bc16b8c176
  1. 2
      i2pd
  2. 32
      routerinfo.cpp

2
i2pd

@ -1 +1 @@
Subproject commit cee9f1df95045b8d972d017780a7a8a82fcfd201 Subproject commit b3ab85f3b538d0fab9194e5a33632e0e694e7705

32
routerinfo.cpp

@ -9,22 +9,34 @@ static void usage(const char * argv)
std::cout << "usage: " << argv << " [-6|-f|-p] routerinfo.dat" << std::endl; std::cout << "usage: " << argv << " [-6|-f|-p] routerinfo.dat" << std::endl;
} }
template<typename Addr>
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<typename Addr> template<typename Addr>
static void write_firewall_entry(std::ostream & o, Addr addr) static void write_firewall_entry(std::ostream & o, Addr addr)
{ {
std::string proto; std::string proto;
if(addr.transportStyle == i2p::data::RouterInfo::eTransportNTCP) { if(addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP) {
proto = "tcp"; proto = "tcp";
} else if (addr.transportStyle == i2p::data::RouterInfo::eTransportSSU) { } else if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) {
proto = "udp"; proto = "udp";
} else { } else {
// bail // bail
return; return;
} }
o << " -A OUTPUT -p " << proto; o << " -A OUTPUT -p " << proto;
o << " -d " << addr.host << " --dport " << addr.port; o << " -d " << addr->host << " --dport " << addr->port;
o << " -j ACCEPT"; o << " -j ACCEPT";
} }
@ -62,16 +74,18 @@ int main(int argc, char * argv[])
std::string fname(argv[idx]); std::string fname(argv[idx]);
i2p::data::RouterInfo ri(fname); i2p::data::RouterInfo ri(fname);
std::vector<i2p::data::RouterInfo::Address> addrs; std::vector<std::shared_ptr<const i2p::data::RouterInfo::Address> > addrs;
auto a = ri.GetNTCPAddress(!ipv6); auto a = ri.GetNTCPAddress(!ipv6);
if(a) if(a)
addrs.push_back(*a); addrs.push_back(a);
a = ri.GetSSUAddress(!ipv6); a = ri.GetSSUAddress(!ipv6);
if(a) if(a)
addrs.push_back(*a); addrs.push_back(a);
if(firewall) if(firewall)
std::cout << "# "; std::cout << "# ";
else
std::cout << "Router Hash: ";
std::cout << ri.GetIdentHashBase64() << std::endl; std::cout << ri.GetIdentHashBase64() << std::endl;
for (const auto & a : addrs) { for (const auto & a : addrs) {
@ -79,10 +93,10 @@ int main(int argc, char * argv[])
if(firewall) { if(firewall) {
write_firewall_entry(std::cout, a); write_firewall_entry(std::cout, a);
} else { } else {
std::cout << a.host; std::cout << address_style_string(a) << ": " << a->host;
if (port) if (port)
std::cout << ":" << a.port; std::cout << ":" << a->port;
} }
std::cout << std::endl; std::cout << std::endl;
} }

Loading…
Cancel
Save