From 354015e9ca1bec2f792504d49d3e22c5128e58cd Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 20 Feb 2014 16:15:12 -0500 Subject: [PATCH] parse introducers from RouterInfo --- RouterInfo.cpp | 21 +++++++++++++++++++++ RouterInfo.h | 12 +++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/RouterInfo.cpp b/RouterInfo.cpp index e1ae0a2d..337ae7b3 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -129,6 +129,27 @@ namespace data address.port = boost::lexical_cast(value); else if (!strcmp (key, "key")) Base64ToByteStream (value, strlen (value), address.key, 32); + else if (key[0] == 'i') + { + // introducers + size_t l = strlen(key); + unsigned char index = key[l-1]; // TODO: + key[l-1] = 0; + if (index >= address.introducers.size ()) + address.introducers.resize (index + 1); + Introducer& introducer = address.introducers.at (index); + if (!strcmp (key, "ihost")) + { + boost::system::error_code ecode; + introducer.iHost = boost::asio::ip::address::from_string (value, ecode); + } + else if (!strcmp (key, "iport")) + introducer.iPort = boost::lexical_cast(value); + else if (!strcmp (key, "itag")) + introducer.iTag = boost::lexical_cast(value); + else if (!strcmp (key, "ikey")) + Base64ToByteStream (value, strlen (value), introducer.iKey, 32); + } } m_Addresses.push_back(address); } diff --git a/RouterInfo.h b/RouterInfo.h index 3c08d8d1..be3d59a2 100644 --- a/RouterInfo.h +++ b/RouterInfo.h @@ -32,6 +32,14 @@ namespace data eTransportSSU }; + struct Introducer + { + boost::asio::ip::address iHost; + int iPort; + uint8_t iKey[32]; + uint32_t iTag; + }; + struct Address { TransportStyle transportStyle; @@ -39,7 +47,9 @@ namespace data int port; uint64_t date; uint8_t cost; - uint8_t key[32]; // into key for SSU + // SSU only + uint8_t key[32]; // intro key for SSU + std::vector introducers; }; RouterInfo (const char * filename);