diff --git a/AddressBook.cpp b/AddressBook.cpp index 938c7d31..ab39c952 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Identity.h" #include "Log.h" @@ -215,7 +215,7 @@ namespace client auto pos = address.find(".b32.i2p"); if (pos != std::string::npos) { - Base32ToByteStream (address.c_str(), pos, ident, 32); + i2p::util::Base32ToByteStream (address.c_str(), pos, ident, 32); return true; } else diff --git a/AddressBook.h b/AddressBook.h index 64c4cc3a..6521953d 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -8,7 +8,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Identity.h" #include "Log.h" diff --git a/Daemon.cpp b/Daemon.cpp index 2de1033d..124f60cc 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -3,7 +3,6 @@ #include "Daemon.h" #include "Log.h" -#include "base64.h" #include "version.h" #include "transport/Transports.h" #include "transport/NTCPSession.h" diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 16ace2d8..e5d23c3d 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "Log.h" #include "Tunnel.h" #include "TransitTunnel.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 9e209f47..b59d0985 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -7,7 +7,6 @@ #include "RouterContext.h" #include "NetDb.h" #include "Tunnel.h" -#include "base64.h" #include "transport/Transports.h" #include "Garlic.h" #include "I2NPProtocol.h" diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 50ecd27c..a7e6a29b 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -1,5 +1,4 @@ #include -#include "base64.h" #include "Log.h" #include "Destination.h" #include "ClientContext.h" diff --git a/Identity.cpp b/Identity.cpp index 6f17eca6..0d1a37db 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "CryptoConst.h" #include "ElGamal.h" #include "RouterContext.h" @@ -237,7 +237,7 @@ namespace data size_t IdentityEx::FromBase64(const std::string& s) { uint8_t buf[1024]; - auto len = Base64ToByteStream (s.c_str(), s.length(), buf, 1024); + auto len = i2p::util::Base64ToByteStream (s.c_str(), s.length(), buf, 1024); return FromBuffer (buf, len); } @@ -246,7 +246,7 @@ namespace data uint8_t buf[1024]; char str[1536]; size_t l = ToBuffer (buf, 1024); - size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, str, 1536); + size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, str, 1536); str[l1] = 0; return std::string (str); } @@ -420,7 +420,7 @@ namespace data size_t PrivateKeys::FromBase64(const std::string& s) { uint8_t * buf = new uint8_t[s.length ()]; - size_t l = i2p::data::Base64ToByteStream (s.c_str (), s.length (), buf, s.length ()); + size_t l = i2p::util::Base64ToByteStream (s.c_str (), s.length (), buf, s.length ()); size_t ret = FromBuffer (buf, l); delete[] buf; return ret; @@ -431,7 +431,7 @@ namespace data uint8_t * buf = new uint8_t[GetFullLen ()]; char * str = new char[GetFullLen ()*2]; size_t l = ToBuffer (buf, GetFullLen ()); - size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, str, GetFullLen ()*2); + size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, str, GetFullLen ()*2); str[l1] = 0; delete[] buf; std::string ret(str); diff --git a/Identity.h b/Identity.h index 4502448b..7f36545d 100644 --- a/Identity.h +++ b/Identity.h @@ -5,7 +5,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "ElGamal.h" #include "Signature.h" @@ -51,7 +51,7 @@ namespace data std::string ToBase64 () const { char str[sz*2]; - int l = i2p::data::ByteStreamToBase64 (m_Buf, sz, str, sz*2); + int l = i2p::util::ByteStreamToBase64 (m_Buf, sz, str, sz*2); str[l] = 0; return std::string (str); } @@ -59,19 +59,19 @@ namespace data std::string ToBase32 () const { char str[sz*2]; - int l = i2p::data::ByteStreamToBase32 (m_Buf, sz, str, sz*2); + int l = i2p::util::ByteStreamToBase32 (m_Buf, sz, str, sz*2); str[l] = 0; return std::string (str); } void FromBase32 (const std::string& s) { - i2p::data::Base32ToByteStream (s.c_str (), s.length (), m_Buf, sz); + i2p::util::Base32ToByteStream (s.c_str (), s.length (), m_Buf, sz); } void FromBase64 (const std::string& s) { - i2p::data::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz); + i2p::util::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz); } private: diff --git a/NetDb.cpp b/NetDb.cpp index cbaebd0c..45236f40 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "Log.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" @@ -263,7 +263,7 @@ namespace data } // list of chars might appear in base64 string - const char * chars = GetBase64SubstitutionTable (); // 64 bytes + const char * chars = i2p::util::GetBase64SubstitutionTable (); // 64 bytes boost::filesystem::path suffix; for (int i = 0; i < 64; i++) { @@ -544,7 +544,7 @@ namespace data { const uint8_t * buf = msg->GetPayload (); char key[48]; - int l = i2p::data::ByteStreamToBase64 (buf, 32, key, 48); + int l = i2p::util::ByteStreamToBase64 (buf, 32, key, 48); key[l] = 0; int num = buf[32]; // num LogPrint ("DatabaseSearchReply for ", key, " num=", num); @@ -613,7 +613,7 @@ namespace data { const uint8_t * router = buf + 33 + i*32; char peerHash[48]; - int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48); + int l1 = i2p::util::ByteStreamToBase64 (router, 32, peerHash, 48); peerHash[l1] = 0; LogPrint (i,": ", peerHash); @@ -639,7 +639,7 @@ namespace data return; } char key[48]; - int l = i2p::data::ByteStreamToBase64 (buf, 32, key, 48); + int l = i2p::util::ByteStreamToBase64 (buf, 32, key, 48); key[l] = 0; uint8_t flag = buf[64]; LogPrint ("DatabaseLookup for ", key, " recieved flags=", (int)flag); diff --git a/Profiling.cpp b/Profiling.cpp index 87ba687d..f2d1269b 100644 --- a/Profiling.cpp +++ b/Profiling.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Profiling.h" @@ -52,7 +52,7 @@ namespace data LogPrint (eLogError, "Failed to create directory ", path); return; } - const char * chars = GetBase64SubstitutionTable (); // 64 bytes + const char * chars = i2p::util::GetBase64SubstitutionTable (); // 64 bytes for (int i = 0; i < 64; i++) { auto path1 = path / (std::string ("p") + chars[i]); diff --git a/RouterInfo.cpp b/RouterInfo.cpp index 2954139c..b394d09d 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -6,7 +6,7 @@ #include #include #include "CryptoConst.h" -#include "base64.h" +#include "util/base64.h" #include "util/Timestamp.h" #include "Log.h" #include "RouterInfo.h" @@ -176,7 +176,7 @@ namespace data else if (!strcmp (key, "mtu")) address.mtu = boost::lexical_cast(value); else if (!strcmp (key, "key")) - Base64ToByteStream (value, strlen (value), address.key, 32); + i2p::util::Base64ToByteStream (value, strlen (value), address.key, 32); else if (!strcmp (key, "caps")) ExtractCaps (value); else if (key[0] == 'i') @@ -199,7 +199,7 @@ namespace data else if (!strcmp (key, "itag")) introducer.iTag = boost::lexical_cast(value); else if (!strcmp (key, "ikey")) - Base64ToByteStream (value, strlen (value), introducer.iKey, 32); + i2p::util::Base64ToByteStream (value, strlen (value), introducer.iKey, 32); } } if (isValidAddress) @@ -344,7 +344,7 @@ namespace data WriteString ("ikey" + boost::lexical_cast(i), properties); properties << '='; char value[64]; - size_t l = ByteStreamToBase64 (introducer.iKey, 32, value, 64); + size_t l = i2p::util::ByteStreamToBase64 (introducer.iKey, 32, value, 64); value[l] = 0; WriteString (value, properties); properties << ';'; @@ -373,7 +373,7 @@ namespace data WriteString ("key", properties); properties << '='; char value[64]; - size_t l = ByteStreamToBase64 (address.key, 32, value, 64); + size_t l = i2p::util::ByteStreamToBase64 (address.key, 32, value, 64); value[l] = 0; WriteString (value, properties); properties << ';'; diff --git a/SAM.cpp b/SAM.cpp index 9014f373..e74ca25a 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -4,7 +4,7 @@ #include #endif #include -#include "base64.h" +#include "util/base64.h" #include "Identity.h" #include "Log.h" #include "Destination.h" @@ -319,7 +319,7 @@ namespace client uint8_t buf[1024]; char priv[1024]; size_t l = m_Session->localDestination->GetPrivateKeys ().ToBuffer (buf, 1024); - size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, priv, 1024); + size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, priv, 1024); priv[l1] = 0; #ifdef _MSC_VER size_t l2 = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_SESSION_CREATE_REPLY_OK, priv); @@ -632,7 +632,7 @@ namespace client // send remote peer address uint8_t ident[1024]; size_t l = stream->GetRemoteIdentity ().ToBuffer (ident, 1024); - size_t l1 = i2p::data::ByteStreamToBase64 (ident, l, (char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE); + size_t l1 = i2p::util::ByteStreamToBase64 (ident, l, (char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE); m_StreamBuffer[l1] = '\n'; HandleI2PReceive (boost::system::error_code (), l1 +1); // we send identity like it has been received from stream } diff --git a/filelist.mk b/filelist.mk index cac86830..2b28c081 100644 --- a/filelist.mk +++ b/filelist.mk @@ -1,12 +1,12 @@ COMMON_SRC = \ transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ transport/SSUData.cpp transport/Transports.cpp \ - util/util.cpp \ + util/util.cpp util/base64.cpp \ CryptoConst.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ Log.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ RouterContext.cpp RouterInfo.cpp Signature.cpp Streaming.cpp Identity.cpp \ TransitTunnel.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \ - TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp base64.cpp + TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp ifeq ($(UNAME),Darwin) diff --git a/transport/NTCPSession.cpp b/transport/NTCPSession.cpp index c3d64221..85b62252 100644 --- a/transport/NTCPSession.cpp +++ b/transport/NTCPSession.cpp @@ -3,9 +3,9 @@ #include "I2PEndian.h" #include #include -#include "base64.h" +#include "util/base64.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "CryptoConst.h" #include "I2NPProtocol.h" #include "RouterContext.h" diff --git a/transport/SSU.cpp b/transport/SSU.cpp index f294db17..651ff93e 100644 --- a/transport/SSU.cpp +++ b/transport/SSU.cpp @@ -1,7 +1,7 @@ #include #include #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" #include "SSU.h" diff --git a/transport/SSUData.cpp b/transport/SSUData.cpp index 02473db4..2f661e68 100644 --- a/transport/SSUData.cpp +++ b/transport/SSUData.cpp @@ -1,7 +1,7 @@ #include #include #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "NetDb.h" #include "SSU.h" #include "SSUData.h" diff --git a/transport/SSUSession.cpp b/transport/SSUSession.cpp index 8f2c2d66..e56f67ea 100644 --- a/transport/SSUSession.cpp +++ b/transport/SSUSession.cpp @@ -3,7 +3,7 @@ #include #include "CryptoConst.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "RouterContext.h" #include "Transports.h" #include "SSU.h" diff --git a/base64.cpp b/util/base64.cpp similarity index 99% rename from base64.cpp rename to util/base64.cpp index cc0c7c21..8ccae845 100644 --- a/base64.cpp +++ b/util/base64.cpp @@ -3,7 +3,7 @@ namespace i2p { -namespace data +namespace util { static void iT64Build(void); diff --git a/base64.h b/util/base64.h similarity index 99% rename from base64.h rename to util/base64.h index 3c1ecb76..689c35ab 100644 --- a/base64.h +++ b/util/base64.h @@ -6,7 +6,7 @@ namespace i2p { -namespace data +namespace util {