mirror of https://github.com/PurpleI2P/i2pd.git
Jeff Becker
9 years ago
60 changed files with 1096 additions and 890 deletions
@ -1,113 +1,115 @@ |
|||||||
#include <thread> |
#include <thread> |
||||||
#include "Config.h" |
#include <clocale> |
||||||
#include "Daemon.h" |
#include "Config.h" |
||||||
#include "util.h" |
#include "Daemon.h" |
||||||
#include "Log.h" |
#include "util.h" |
||||||
|
#include "Log.h" |
||||||
#ifdef _WIN32 |
|
||||||
|
#ifdef _WIN32 |
||||||
#include "Win32/Win32Service.h" |
|
||||||
#ifdef WIN32_APP |
#include "Win32/Win32Service.h" |
||||||
#include "Win32/Win32App.h" |
#ifdef WIN32_APP |
||||||
#endif |
#include "Win32/Win32App.h" |
||||||
|
#endif |
||||||
namespace i2p |
|
||||||
{ |
namespace i2p |
||||||
namespace util |
{ |
||||||
{ |
namespace util |
||||||
bool DaemonWin32::init(int argc, char* argv[]) |
{ |
||||||
{ |
bool DaemonWin32::init(int argc, char* argv[]) |
||||||
setlocale(LC_CTYPE, ""); |
{ |
||||||
SetConsoleCP(1251); |
setlocale(LC_CTYPE, ""); |
||||||
SetConsoleOutputCP(1251); |
SetConsoleCP(1251); |
||||||
|
SetConsoleOutputCP(1251); |
||||||
if (!Daemon_Singleton::init(argc, argv)) |
setlocale(LC_ALL, "Russian"); |
||||||
return false; |
|
||||||
|
if (!Daemon_Singleton::init(argc, argv)) |
||||||
std::string serviceControl; i2p::config::GetOption("svcctl", serviceControl); |
return false; |
||||||
if (serviceControl == "install") |
|
||||||
{ |
std::string serviceControl; i2p::config::GetOption("svcctl", serviceControl); |
||||||
LogPrint(eLogInfo, "WinSVC: installing ", SERVICE_NAME, " as service"); |
if (serviceControl == "install") |
||||||
InstallService( |
{ |
||||||
SERVICE_NAME, // Name of service
|
LogPrint(eLogInfo, "WinSVC: installing ", SERVICE_NAME, " as service"); |
||||||
SERVICE_DISPLAY_NAME, // Name to display
|
InstallService( |
||||||
SERVICE_START_TYPE, // Service start type
|
SERVICE_NAME, // Name of service
|
||||||
SERVICE_DEPENDENCIES, // Dependencies
|
SERVICE_DISPLAY_NAME, // Name to display
|
||||||
SERVICE_ACCOUNT, // Service running account
|
SERVICE_START_TYPE, // Service start type
|
||||||
SERVICE_PASSWORD // Password of the account
|
SERVICE_DEPENDENCIES, // Dependencies
|
||||||
); |
SERVICE_ACCOUNT, // Service running account
|
||||||
return false; |
SERVICE_PASSWORD // Password of the account
|
||||||
} |
); |
||||||
else if (serviceControl == "remove") |
return false; |
||||||
{ |
} |
||||||
LogPrint(eLogInfo, "WinSVC: uninstalling ", SERVICE_NAME, " service"); |
else if (serviceControl == "remove") |
||||||
UninstallService(SERVICE_NAME); |
{ |
||||||
return false; |
LogPrint(eLogInfo, "WinSVC: uninstalling ", SERVICE_NAME, " service"); |
||||||
} |
UninstallService(SERVICE_NAME); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
if (isDaemon) |
if (isDaemon) |
||||||
{ |
{ |
||||||
LogPrint(eLogDebug, "Daemon: running as service"); |
LogPrint(eLogDebug, "Daemon: running as service"); |
||||||
I2PService service(SERVICE_NAME); |
I2PService service(SERVICE_NAME); |
||||||
if (!I2PService::Run(service)) |
if (!I2PService::Run(service)) |
||||||
{ |
{ |
||||||
LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError()); |
LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError()); |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
else |
else |
||||||
LogPrint(eLogDebug, "Daemon: running as user"); |
LogPrint(eLogDebug, "Daemon: running as user"); |
||||||
|
|
||||||
return true; |
return true; |
||||||
} |
} |
||||||
|
|
||||||
bool DaemonWin32::start() |
bool DaemonWin32::start() |
||||||
{ |
{ |
||||||
setlocale(LC_CTYPE, ""); |
setlocale(LC_CTYPE, ""); |
||||||
SetConsoleCP(1251); |
SetConsoleCP(1251); |
||||||
SetConsoleOutputCP(1251); |
SetConsoleOutputCP(1251); |
||||||
setlocale(LC_ALL, "Russian"); |
setlocale(LC_ALL, "Russian"); |
||||||
#ifdef WIN32_APP |
#ifdef WIN32_APP |
||||||
if (!i2p::win32::StartWin32App ()) return false; |
if (!i2p::win32::StartWin32App ()) return false; |
||||||
|
|
||||||
// override log
|
// override log
|
||||||
i2p::config::SetOption("log", std::string ("file")); |
i2p::config::SetOption("log", std::string ("file")); |
||||||
#endif |
#endif |
||||||
bool ret = Daemon_Singleton::start(); |
bool ret = Daemon_Singleton::start(); |
||||||
if (ret && i2p::log::Logger().GetLogType() == eLogFile) |
if (ret && i2p::log::Logger().GetLogType() == eLogFile) |
||||||
{ |
{ |
||||||
// TODO: find out where this garbage to console comes from
|
// TODO: find out where this garbage to console comes from
|
||||||
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE); |
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE); |
||||||
SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE); |
SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE); |
||||||
} |
} |
||||||
bool insomnia; i2p::config::GetOption("insomnia", insomnia); |
bool insomnia; i2p::config::GetOption("insomnia", insomnia); |
||||||
if (insomnia) |
if (insomnia) |
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); |
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); |
||||||
return ret; |
return ret; |
||||||
} |
} |
||||||
|
|
||||||
bool DaemonWin32::stop() |
bool DaemonWin32::stop() |
||||||
{ |
{ |
||||||
#ifdef WIN32_APP |
#ifdef WIN32_APP |
||||||
i2p::win32::StopWin32App (); |
i2p::win32::StopWin32App (); |
||||||
#endif |
#endif |
||||||
return Daemon_Singleton::stop(); |
return Daemon_Singleton::stop(); |
||||||
} |
} |
||||||
|
|
||||||
void DaemonWin32::run () |
void DaemonWin32::run () |
||||||
{ |
{ |
||||||
#ifdef WIN32_APP |
#ifdef WIN32_APP |
||||||
i2p::win32::RunWin32App (); |
i2p::win32::RunWin32App (); |
||||||
#else |
#else |
||||||
while (running) |
while (running) |
||||||
{ |
{ |
||||||
std::this_thread::sleep_for (std::chrono::seconds(1)); |
std::this_thread::sleep_for (std::chrono::seconds(1)); |
||||||
} |
} |
||||||
|
|
||||||
#endif |
#endif |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
#endif |
#endif |
||||||
|
@ -0,0 +1,108 @@ |
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2016, The PurpleI2P Project |
||||||
|
* |
||||||
|
* This file is part of Purple i2pd project and licensed under BSD3 |
||||||
|
* |
||||||
|
* See full license text in LICENSE file at top of project tree |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <inttypes.h> |
||||||
|
#include <string.h> /* memset */ |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#include "Gzip.h" |
||||||
|
|
||||||
|
namespace i2p { |
||||||
|
namespace data { |
||||||
|
const size_t GZIP_CHUNK_SIZE = 16384; |
||||||
|
|
||||||
|
GzipInflator::GzipInflator (): m_IsDirty (false) |
||||||
|
{ |
||||||
|
memset (&m_Inflator, 0, sizeof (m_Inflator)); |
||||||
|
inflateInit2 (&m_Inflator, MAX_WBITS + 16); // gzip
|
||||||
|
} |
||||||
|
|
||||||
|
GzipInflator::~GzipInflator () |
||||||
|
{ |
||||||
|
inflateEnd (&m_Inflator); |
||||||
|
} |
||||||
|
|
||||||
|
size_t GzipInflator::Inflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen) |
||||||
|
{ |
||||||
|
if (m_IsDirty) inflateReset (&m_Inflator); |
||||||
|
m_IsDirty = true; |
||||||
|
m_Inflator.next_in = const_cast<uint8_t *>(in); |
||||||
|
m_Inflator.avail_in = inLen; |
||||||
|
m_Inflator.next_out = out; |
||||||
|
m_Inflator.avail_out = outLen; |
||||||
|
int err; |
||||||
|
if ((err = inflate (&m_Inflator, Z_NO_FLUSH)) == Z_STREAM_END) { |
||||||
|
return outLen - m_Inflator.avail_out; |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
void GzipInflator::Inflate (const uint8_t * in, size_t inLen, std::ostream& os) |
||||||
|
{ |
||||||
|
m_IsDirty = true; |
||||||
|
uint8_t * out = new uint8_t[GZIP_CHUNK_SIZE]; |
||||||
|
m_Inflator.next_in = const_cast<uint8_t *>(in); |
||||||
|
m_Inflator.avail_in = inLen; |
||||||
|
int ret; |
||||||
|
do { |
||||||
|
m_Inflator.next_out = out; |
||||||
|
m_Inflator.avail_out = GZIP_CHUNK_SIZE; |
||||||
|
ret = inflate (&m_Inflator, Z_NO_FLUSH); |
||||||
|
if (ret < 0) { |
||||||
|
inflateEnd (&m_Inflator); |
||||||
|
os.setstate(std::ios_base::failbit); |
||||||
|
break; |
||||||
|
} |
||||||
|
os.write ((char *)out, GZIP_CHUNK_SIZE - m_Inflator.avail_out); |
||||||
|
} while (!m_Inflator.avail_out); // more data to read
|
||||||
|
delete[] out; |
||||||
|
} |
||||||
|
|
||||||
|
void GzipInflator::Inflate (std::istream& in, std::ostream& out) |
||||||
|
{ |
||||||
|
uint8_t * buf = new uint8_t[GZIP_CHUNK_SIZE]; |
||||||
|
while (!in.eof ()) |
||||||
|
{ |
||||||
|
in.read ((char *) buf, GZIP_CHUNK_SIZE); |
||||||
|
Inflate (buf, in.gcount (), out); |
||||||
|
} |
||||||
|
delete[] buf; |
||||||
|
} |
||||||
|
|
||||||
|
GzipDeflator::GzipDeflator (): m_IsDirty (false) |
||||||
|
{ |
||||||
|
memset (&m_Deflator, 0, sizeof (m_Deflator)); |
||||||
|
deflateInit2 (&m_Deflator, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); // 15 + 16 sets gzip
|
||||||
|
} |
||||||
|
|
||||||
|
GzipDeflator::~GzipDeflator () |
||||||
|
{ |
||||||
|
deflateEnd (&m_Deflator); |
||||||
|
} |
||||||
|
|
||||||
|
void GzipDeflator::SetCompressionLevel (int level) |
||||||
|
{ |
||||||
|
deflateParams (&m_Deflator, level, Z_DEFAULT_STRATEGY); |
||||||
|
} |
||||||
|
|
||||||
|
size_t GzipDeflator::Deflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen) |
||||||
|
{ |
||||||
|
if (m_IsDirty) deflateReset (&m_Deflator); |
||||||
|
m_IsDirty = true; |
||||||
|
m_Deflator.next_in = const_cast<uint8_t *>(in); |
||||||
|
m_Deflator.avail_in = inLen; |
||||||
|
m_Deflator.next_out = out; |
||||||
|
m_Deflator.avail_out = outLen; |
||||||
|
int err; |
||||||
|
if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END) { |
||||||
|
return outLen - m_Deflator.avail_out; |
||||||
|
} /* else */ |
||||||
|
return 0; |
||||||
|
} |
||||||
|
} // data
|
||||||
|
} // i2p
|
@ -0,0 +1,44 @@ |
|||||||
|
#ifndef GZIP_H__ |
||||||
|
#define GZIP_H__ |
||||||
|
|
||||||
|
#include <zlib.h> |
||||||
|
|
||||||
|
namespace i2p { |
||||||
|
namespace data { |
||||||
|
class GzipInflator |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
GzipInflator (); |
||||||
|
~GzipInflator (); |
||||||
|
|
||||||
|
size_t Inflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen); |
||||||
|
/** @note @a os failbit will be set in case of error */ |
||||||
|
void Inflate (const uint8_t * in, size_t inLen, std::ostream& os); |
||||||
|
void Inflate (std::istream& in, std::ostream& out); |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
z_stream m_Inflator; |
||||||
|
bool m_IsDirty; |
||||||
|
}; |
||||||
|
|
||||||
|
class GzipDeflator |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
GzipDeflator (); |
||||||
|
~GzipDeflator (); |
||||||
|
|
||||||
|
void SetCompressionLevel (int level); |
||||||
|
size_t Deflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen); |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
z_stream m_Deflator; |
||||||
|
bool m_IsDirty; |
||||||
|
}; |
||||||
|
} // data
|
||||||
|
} // i2p
|
||||||
|
|
||||||
|
#endif /* GZIP_H__ */ |
@ -1,32 +1,21 @@ |
|||||||
#ifndef HTTP_PROXY_H__ |
#ifndef HTTP_PROXY_H__ |
||||||
#define HTTP_PROXY_H__ |
#define HTTP_PROXY_H__ |
||||||
|
|
||||||
#include <memory> |
namespace i2p { |
||||||
#include <set> |
namespace proxy { |
||||||
#include <boost/asio.hpp> |
class HTTPProxy: public i2p::client::TCPIPAcceptor |
||||||
#include <mutex> |
|
||||||
#include "I2PService.h" |
|
||||||
#include "Destination.h" |
|
||||||
|
|
||||||
namespace i2p |
|
||||||
{ |
|
||||||
namespace proxy |
|
||||||
{ |
|
||||||
class HTTPProxyServer: public i2p::client::TCPIPAcceptor |
|
||||||
{ |
{ |
||||||
public: |
public: |
||||||
|
|
||||||
HTTPProxyServer(const std::string& address, int port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr); |
HTTPProxy(const std::string& address, int port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr); |
||||||
~HTTPProxyServer() {}; |
~HTTPProxy() {}; |
||||||
|
|
||||||
protected: |
protected: |
||||||
// Implements TCPIPAcceptor
|
// Implements TCPIPAcceptor
|
||||||
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket); |
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket); |
||||||
const char* GetName() { return "HTTP Proxy"; } |
const char* GetName() { return "HTTP Proxy"; } |
||||||
}; |
}; |
||||||
|
} // http
|
||||||
typedef HTTPProxyServer HTTPProxy; |
} // i2p
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#endif |
#endif |
||||||
|
@ -1,42 +1,47 @@ |
|||||||
USE_WIN32_APP=yes |
USE_WIN32_APP=yes |
||||||
CXX = g++ |
CXX = g++ |
||||||
WINDRES = windres |
WINDRES = windres |
||||||
CXXFLAGS = -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN |
CXXFLAGS = -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN |
||||||
NEEDED_CXXFLAGS = -std=c++11 |
NEEDED_CXXFLAGS = -std=c++11 |
||||||
BOOST_SUFFIX = -mt |
BOOST_SUFFIX = -mt |
||||||
INCFLAGS = -I/usr/include/ -I/usr/local/include/ |
INCFLAGS = -I/usr/include/ -I/usr/local/include/ |
||||||
LDFLAGS = -Wl,-rpath,/usr/local/lib \
|
LDFLAGS = -Wl,-rpath,/usr/local/lib \
|
||||||
-L/usr/local/lib \
|
-L/usr/local/lib |
||||||
-L/c/dev/openssl \
|
|
||||||
-L/c/dev/boost/lib |
# UPNP Support
|
||||||
LDLIBS = \
|
ifeq ($(USE_UPNP),yes) |
||||||
-Wl,-Bstatic -lboost_system$(BOOST_SUFFIX) \
|
CXXFLAGS += -DUSE_UPNP -DMINIUPNP_STATICLIB |
||||||
-Wl,-Bstatic -lboost_date_time$(BOOST_SUFFIX) \
|
LDLIBS = -Wl,-Bstatic -lminiupnpc |
||||||
-Wl,-Bstatic -lboost_filesystem$(BOOST_SUFFIX) \
|
endif |
||||||
-Wl,-Bstatic -lboost_program_options$(BOOST_SUFFIX) \
|
|
||||||
-Wl,-Bstatic -lssl \
|
LDLIBS += \
|
||||||
-Wl,-Bstatic -lcrypto \
|
-Wl,-Bstatic -lboost_system$(BOOST_SUFFIX) \
|
||||||
-Wl,-Bstatic -lz \
|
-Wl,-Bstatic -lboost_date_time$(BOOST_SUFFIX) \
|
||||||
-Wl,-Bstatic -lwsock32 \
|
-Wl,-Bstatic -lboost_filesystem$(BOOST_SUFFIX) \
|
||||||
-Wl,-Bstatic -lws2_32 \
|
-Wl,-Bstatic -lboost_program_options$(BOOST_SUFFIX) \
|
||||||
-Wl,-Bstatic -lgdi32 \
|
-Wl,-Bstatic -lssl \
|
||||||
-Wl,-Bstatic -liphlpapi \
|
-Wl,-Bstatic -lcrypto \
|
||||||
-static-libgcc -static-libstdc++ \
|
-Wl,-Bstatic -lz \
|
||||||
-Wl,-Bstatic -lstdc++ \
|
-Wl,-Bstatic -lwsock32 \
|
||||||
-Wl,-Bstatic -lpthread |
-Wl,-Bstatic -lws2_32 \
|
||||||
|
-Wl,-Bstatic -lgdi32 \
|
||||||
ifeq ($(USE_WIN32_APP), yes) |
-Wl,-Bstatic -liphlpapi \
|
||||||
CXXFLAGS += -DWIN32_APP |
-static-libgcc -static-libstdc++ \
|
||||||
LDFLAGS += -mwindows -s |
-Wl,-Bstatic -lstdc++ \
|
||||||
DAEMON_RC += Win32/Resource.rc |
-Wl,-Bstatic -lpthread |
||||||
DAEMON_OBJS += $(patsubst %.rc,obj/%.o,$(DAEMON_RC)) |
|
||||||
endif |
ifeq ($(USE_WIN32_APP), yes) |
||||||
|
CXXFLAGS += -DWIN32_APP |
||||||
ifeq ($(USE_AESNI),1) |
LDFLAGS += -mwindows -s |
||||||
CPU_FLAGS = -maes -DAESNI |
DAEMON_RC += Win32/Resource.rc |
||||||
else |
DAEMON_OBJS += $(patsubst %.rc,obj/%.o,$(DAEMON_RC)) |
||||||
CPU_FLAGS = -msse |
endif |
||||||
endif |
|
||||||
|
ifeq ($(USE_AESNI),yes) |
||||||
obj/%.o : %.rc |
CPU_FLAGS = -maes -DAESNI |
||||||
$(WINDRES) -i $< -o $@ |
else |
||||||
|
CPU_FLAGS = -msse |
||||||
|
endif |
||||||
|
|
||||||
|
obj/%.o : %.rc |
||||||
|
$(WINDRES) -i $< -o $@ |
||||||
|
@ -0,0 +1,90 @@ |
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2016, The PurpleI2P Project |
||||||
|
* |
||||||
|
* This file is part of Purple i2pd project and licensed under BSD3 |
||||||
|
* |
||||||
|
* See full license text in LICENSE file at top of project tree |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef TAG_H__ |
||||||
|
#define TAG_H__ |
||||||
|
|
||||||
|
#include <string.h> /* memcpy */ |
||||||
|
|
||||||
|
#include "Base.h" |
||||||
|
|
||||||
|
namespace i2p { |
||||||
|
namespace data { |
||||||
|
template<int sz> |
||||||
|
class Tag |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
Tag (const uint8_t * buf) { memcpy (m_Buf, buf, sz); }; |
||||||
|
Tag (const Tag<sz>& ) = default; |
||||||
|
#ifndef _WIN32 // FIXME!!! msvs 2013 can't compile it
|
||||||
|
Tag (Tag<sz>&& ) = default; |
||||||
|
#endif |
||||||
|
Tag () = default; |
||||||
|
|
||||||
|
Tag<sz>& operator= (const Tag<sz>& ) = default; |
||||||
|
#ifndef _WIN32 |
||||||
|
Tag<sz>& operator= (Tag<sz>&& ) = default; |
||||||
|
#endif |
||||||
|
|
||||||
|
uint8_t * operator()() { return m_Buf; }; |
||||||
|
const uint8_t * operator()() const { return m_Buf; }; |
||||||
|
|
||||||
|
operator uint8_t * () { return m_Buf; }; |
||||||
|
operator const uint8_t * () const { return m_Buf; }; |
||||||
|
|
||||||
|
const uint64_t * GetLL () const { return ll; }; |
||||||
|
|
||||||
|
bool operator== (const Tag<sz>& other) const { return !memcmp (m_Buf, other.m_Buf, sz); }; |
||||||
|
bool operator< (const Tag<sz>& other) const { return memcmp (m_Buf, other.m_Buf, sz) < 0; }; |
||||||
|
|
||||||
|
bool IsZero () const |
||||||
|
{ |
||||||
|
for (int i = 0; i < sz/8; i++) |
||||||
|
if (ll[i]) return false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
std::string ToBase64 () const |
||||||
|
{ |
||||||
|
char str[sz*2]; |
||||||
|
int l = i2p::data::ByteStreamToBase64 (m_Buf, sz, str, sz*2); |
||||||
|
str[l] = 0; |
||||||
|
return std::string (str); |
||||||
|
} |
||||||
|
|
||||||
|
std::string ToBase32 () const |
||||||
|
{ |
||||||
|
char str[sz*2]; |
||||||
|
int l = i2p::data::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); |
||||||
|
} |
||||||
|
|
||||||
|
void FromBase64 (const std::string& s) |
||||||
|
{ |
||||||
|
i2p::data::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz); |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
union // 8 bytes alignment
|
||||||
|
{ |
||||||
|
uint8_t m_Buf[sz]; |
||||||
|
uint64_t ll[sz/8]; |
||||||
|
}; |
||||||
|
}; |
||||||
|
} // data
|
||||||
|
} // i2p
|
||||||
|
|
||||||
|
#endif /* TAG_H__ */ |
@ -1,13 +1,16 @@ |
|||||||
diff --git a/Makefile b/Makefile
|
diff --git a/Makefile b/Makefile
|
||||||
index 2e86fd8..c1037af 100644
|
index fe8ae7e..fc8abda 100644
|
||||||
--- a/Makefile
|
--- a/Makefile
|
||||||
+++ b/Makefile
|
+++ b/Makefile
|
||||||
@@ -9,7 +9,7 @@ DEPS := obj/make.dep
|
@@ -9,9 +9,9 @@ DEPS := obj/make.dep
|
||||||
|
|
||||||
include filelist.mk |
include filelist.mk |
||||||
|
|
||||||
-USE_AESNI := yes
|
-USE_AESNI := yes
|
||||||
+USE_AESNI := no
|
+USE_AESNI := no
|
||||||
USE_STATIC := no |
USE_STATIC := no |
||||||
|
-USE_UPNP := no
|
||||||
|
+USE_UPNP := yes
|
||||||
|
|
||||||
ifeq ($(UNAME),Darwin) |
ifeq ($(UNAME),Darwin) |
||||||
|
DAEMON_SRC += DaemonLinux.cpp |
@ -1 +1 @@ |
|||||||
0001-disable-aesni-by-default.patch |
01-tune-build-opts.patch |
||||||
|
@ -1,7 +1,33 @@ |
|||||||
[IRC] |
[IRC] |
||||||
type = client |
type = client |
||||||
|
address = 127.0.0.1 |
||||||
port = 6668 |
port = 6668 |
||||||
destination = irc.postman.i2p |
destination = irc.postman.i2p |
||||||
|
destinationport = 6667 |
||||||
keys = irc-keys.dat |
keys = irc-keys.dat |
||||||
|
|
||||||
|
#[SMTP] |
||||||
|
#type = client |
||||||
|
#address = 127.0.0.1 |
||||||
|
#port = 7659 |
||||||
|
#destination = smtp.postman.i2p |
||||||
|
#destinationport = 25 |
||||||
|
#keys = smtp-keys.dat |
||||||
|
|
||||||
|
#[POP3] |
||||||
|
#type = client |
||||||
|
#address = 127.0.0.1 |
||||||
|
#port = 7660 |
||||||
|
#destination = pop.postman.i2p |
||||||
|
#destinationport = 110 |
||||||
|
#keys = pop3-keys.dat |
||||||
|
|
||||||
|
#[MTN] |
||||||
|
#type = client |
||||||
|
#address = 127.0.0.1 |
||||||
|
#port = 8998 |
||||||
|
#destination = mtn.i2p-projekt.i2p |
||||||
|
#destinationport = 4691 |
||||||
|
#keys = mtn-keys.dat |
||||||
|
|
||||||
# see more examples in /usr/share/doc/i2pd/configuration.md.gz |
# see more examples in /usr/share/doc/i2pd/configuration.md.gz |
||||||
|
@ -0,0 +1,5 @@ |
|||||||
|
<!DOCTYPE RCC><RCC version="1.0"> |
||||||
|
<qresource prefix="/"> |
||||||
|
<file>images/icon.png</file> |
||||||
|
</qresource> |
||||||
|
</RCC> |
@ -1,192 +1,128 @@ |
|||||||
#------------------------------------------------- |
QT += core gui |
||||||
# |
|
||||||
# Project created by QtCreator 2016-06-14T04:53:04 |
|
||||||
# |
|
||||||
#------------------------------------------------- |
|
||||||
|
|
||||||
QT += core gui |
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
||||||
|
|
||||||
TARGET = i2pd_qt |
TARGET = i2pd_qt |
||||||
TEMPLATE = app |
TEMPLATE = app |
||||||
QMAKE_CXXFLAGS *= -std=c++11 |
QMAKE_CXXFLAGS *= -std=c++11 |
||||||
|
DEFINES += USE_UPNP |
||||||
|
|
||||||
|
# change to your own path, where you will store all needed libraries with 'git clone' commands below. |
||||||
|
MAIN_PATH = /path/to/libraries |
||||||
|
|
||||||
# git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git |
# git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git |
||||||
# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git |
# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git |
||||||
|
# git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git |
||||||
# git clone https://github.com/PurpleI2P/android-ifaddrs.git |
# git clone https://github.com/PurpleI2P/android-ifaddrs.git |
||||||
# change to your own |
|
||||||
BOOST_PATH = /mnt/media/android/Boost-for-Android-Prebuilt |
BOOST_PATH = $$MAIN_PATH/Boost-for-Android-Prebuilt |
||||||
OPENSSL_PATH = /mnt/media/android/OpenSSL-for-Android-Prebuilt |
OPENSSL_PATH = $$MAIN_PATH/OpenSSL-for-Android-Prebuilt |
||||||
IFADDRS_PATH = /mnt/media/android/android-ifaddrs |
MINIUPNP_PATH = $$MAIN_PATH/MiniUPnP-for-Android-Prebuilt |
||||||
|
IFADDRS_PATH = $$MAIN_PATH/android-ifaddrs |
||||||
|
|
||||||
# Steps in Android SDK manager: |
# Steps in Android SDK manager: |
||||||
# 1) Check Extras/Google Support Library https://developer.android.com/topic/libraries/support-library/setup.html |
# 1) Check Extras/Google Support Library https://developer.android.com/topic/libraries/support-library/setup.html |
||||||
# 2) Check API 11 |
# 2) Check API 11 |
||||||
# Finally, click Install. |
# Finally, click Install. |
||||||
|
|
||||||
SOURCES += DaemonQT.cpp\ |
SOURCES += DaemonQT.cpp mainwindow.cpp \ |
||||||
mainwindow.cpp \ |
../../HTTPServer.cpp ../../I2PControl.cpp ../../Daemon.cpp ../../Config.cpp \ |
||||||
../../HTTPServer.cpp ../../I2PControl.cpp ../../UPnP.cpp ../../Daemon.cpp ../../Config.cpp \ |
../../AddressBook.cpp ../../api.cpp ../../Base.cpp ../../BOB.cpp ../../ClientContext.cpp \ |
||||||
../../AddressBook.cpp \ |
../../Crypto.cpp ../../Datagram.cpp ../../Destination.cpp ../../Family.cpp ../../FS.cpp \ |
||||||
../../api.cpp \ |
../../Garlic.cpp ../../HTTP.cpp ../../HTTPProxy.cpp ../../I2CP.cpp ../../I2NPProtocol.cpp \ |
||||||
../../Base.cpp \ |
../../I2PEndian.cpp ../../I2PService.cpp ../../I2PTunnel.cpp ../../Identity.cpp \ |
||||||
../../BOB.cpp \ |
../../LeaseSet.cpp ../../Log.cpp ../../NetDb.cpp ../../NetDbRequests.cpp \ |
||||||
../../ClientContext.cpp \ |
../../NTCPSession.cpp ../../Profiling.cpp ../../Reseed.cpp ../../RouterContext.cpp \ |
||||||
../../Crypto.cpp \ |
../../RouterInfo.cpp ../../SAM.cpp ../../Signature.cpp ../../SOCKS.cpp ../../SSU.cpp \ |
||||||
../../Datagram.cpp \ |
../../SSUData.cpp ../../SSUSession.cpp ../../Streaming.cpp ../../TransitTunnel.cpp \ |
||||||
../../Destination.cpp \ |
../../Transports.cpp ../../Tunnel.cpp ../../TunnelEndpoint.cpp ../../TunnelGateway.cpp \ |
||||||
../../Family.cpp \ |
../../TunnelPool.cpp ../../UPnP.cpp ../../util.cpp ../../Gzip.cpp ../../i2pd.cpp |
||||||
../../FS.cpp \ |
|
||||||
../../Garlic.cpp \ |
|
||||||
../../HTTP.cpp \ |
|
||||||
../../HTTPProxy.cpp \ |
|
||||||
../../I2CP.cpp \ |
|
||||||
../../I2NPProtocol.cpp \ |
|
||||||
../../I2PEndian.cpp \ |
|
||||||
../../I2PService.cpp \ |
|
||||||
../../I2PTunnel.cpp \ |
|
||||||
../../Identity.cpp \ |
|
||||||
../../LeaseSet.cpp \ |
|
||||||
../../Log.cpp \ |
|
||||||
../../NetDb.cpp \ |
|
||||||
../../NetDbRequests.cpp \ |
|
||||||
../../NTCPSession.cpp \ |
|
||||||
../../Profiling.cpp \ |
|
||||||
../../Reseed.cpp \ |
|
||||||
../../RouterContext.cpp \ |
|
||||||
../../RouterInfo.cpp \ |
|
||||||
../../SAM.cpp \ |
|
||||||
../../Signature.cpp \ |
|
||||||
../../SOCKS.cpp \ |
|
||||||
../../SSU.cpp \ |
|
||||||
../../SSUData.cpp \ |
|
||||||
../../SSUSession.cpp \ |
|
||||||
../../Streaming.cpp \ |
|
||||||
../../TransitTunnel.cpp \ |
|
||||||
../../Transports.cpp \ |
|
||||||
../../Tunnel.cpp \ |
|
||||||
../../TunnelEndpoint.cpp \ |
|
||||||
../../TunnelGateway.cpp \ |
|
||||||
../../TunnelPool.cpp \ |
|
||||||
../../util.cpp \ |
|
||||||
../../i2pd.cpp \ |
|
||||||
$$IFADDRS_PATH/ifaddrs.c |
|
||||||
|
|
||||||
HEADERS += DaemonQT.h mainwindow.h \ |
HEADERS += DaemonQT.h mainwindow.h \ |
||||||
../../HTTPServer.h ../../I2PControl.h ../../UPnP.h ../../Daemon.h ../../Config.h \ |
../../HTTPServer.h ../../I2PControl.h ../../UPnP.h ../../Daemon.h ../../Config.h \ |
||||||
../../AddressBook.h \ |
../../AddressBook.h ../../api.h ../../Base.h ../../BOB.h ../../ClientContext.h \ |
||||||
../../api.h \ |
../../Crypto.h ../../Datagram.h ../../Destination.h ../../Family.h ../../FS.h \ |
||||||
../../Base.h \ |
../../Garlic.h ../../HTTP.h ../../HTTPProxy.h ../../I2CP.h ../../I2NPProtocol.h \ |
||||||
../../BOB.h \ |
../../I2PEndian.h ../../I2PService.h ../../I2PTunnel.h ../../Identity.h ../../LeaseSet.h \ |
||||||
../../ClientContext.h \ |
../../LittleBigEndian.h ../../Log.h ../../NetDb.h ../../NetDbRequests.h ../../NTCPSession.h \ |
||||||
../../Crypto.h \ |
../../Profiling.h ../../Queue.h ../../Reseed.h ../../RouterContext.h ../../RouterInfo.h \ |
||||||
../../Datagram.h \ |
../../SAM.h ../../Signature.h ../../SOCKS.h ../../SSU.h ../../SSUData.h ../../SSUSession.h \ |
||||||
../../Destination.h \ |
../../Streaming.h ../../Timestamp.h ../../TransitTunnel.h ../../Transports.h \ |
||||||
../../Family.h \ |
../../TransportSession.h ../../Tunnel.h ../../TunnelBase.h ../../TunnelConfig.h \ |
||||||
../../FS.h \ |
../../TunnelEndpoint.h ../../TunnelGateway.h ../../TunnelPool.h ../../UPnP.h \ |
||||||
../../Garlic.h \ |
../../util.h ../../version.h ..//../Gzip.h ../../Tag.h |
||||||
../../HTTP.h \ |
|
||||||
../../HTTPProxy.h \ |
FORMS += mainwindow.ui |
||||||
../../I2CP.h \ |
|
||||||
../../I2NPProtocol.h \ |
|
||||||
../../I2PEndian.h \ |
|
||||||
../../I2PService.h \ |
|
||||||
../../I2PTunnel.h \ |
|
||||||
../../Identity.h \ |
|
||||||
../../LeaseSet.h \ |
|
||||||
../../LittleBigEndian.h \ |
|
||||||
../../Log.h \ |
|
||||||
../../NetDb.h \ |
|
||||||
../../NetDbRequests.h \ |
|
||||||
../../NTCPSession.h \ |
|
||||||
../../Profiling.h \ |
|
||||||
../../Queue.h \ |
|
||||||
../../Reseed.h \ |
|
||||||
../../RouterContext.h \ |
|
||||||
../../RouterInfo.h \ |
|
||||||
../../SAM.h \ |
|
||||||
../../Signature.h \ |
|
||||||
../../SOCKS.h \ |
|
||||||
../../SSU.h \ |
|
||||||
../../SSUData.h \ |
|
||||||
../../SSUSession.h \ |
|
||||||
../../Streaming.h \ |
|
||||||
../../Timestamp.h \ |
|
||||||
../../TransitTunnel.h \ |
|
||||||
../../Transports.h \ |
|
||||||
../../TransportSession.h \ |
|
||||||
../../Tunnel.h \ |
|
||||||
../../TunnelBase.h \ |
|
||||||
../../TunnelConfig.h \ |
|
||||||
../../TunnelEndpoint.h \ |
|
||||||
../../TunnelGateway.h \ |
|
||||||
../../TunnelPool.h \ |
|
||||||
../../util.h \ |
|
||||||
../../version.h \ |
|
||||||
$$IFADDRS_PATH/ifaddrs.h |
|
||||||
|
|
||||||
FORMS += mainwindow.ui |
|
||||||
|
|
||||||
CONFIG += mobility |
CONFIG += mobility |
||||||
|
|
||||||
MOBILITY = |
MOBILITY = |
||||||
|
|
||||||
LIBS += -lz |
LIBS += -lz |
||||||
|
|
||||||
android { |
android { |
||||||
message("Using Android settings") |
message("Using Android settings") |
||||||
DEFINES += ANDROID=1 |
DEFINES += ANDROID=1 |
||||||
DEFINES += __ANDROID__ |
DEFINES += __ANDROID__ |
||||||
INCLUDEPATH += $$BOOST_PATH/boost_1_53_0/include \ |
|
||||||
$$OPENSSL_PATH/openssl-1.0.2/include \ |
INCLUDEPATH += $$BOOST_PATH/boost_1_53_0/include \ |
||||||
$$IFADDRS_PATH |
$$OPENSSL_PATH/openssl-1.0.2/include \ |
||||||
DISTFILES += \ |
$$MINIUPNP_PATH/miniupnp-2.0/include \ |
||||||
android/AndroidManifest.xml |
$$IFADDRS_PATH |
||||||
|
DISTFILES += android/AndroidManifest.xml |
||||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android |
|
||||||
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android |
||||||
equals(ANDROID_TARGET_ARCH, armeabi-v7a){ |
|
||||||
|
SOURCES += $$IFADDRS_PATH/ifaddrs.c |
||||||
DEFINES += ANDROID_ARM7A |
HEADERS += $$IFADDRS_PATH/ifaddrs.h |
||||||
|
|
||||||
# http://stackoverflow.com/a/30235934/529442 |
equals(ANDROID_TARGET_ARCH, armeabi-v7a){ |
||||||
LIBS += -L$$BOOST_PATH/boost_1_53_0/armeabi-v7a/lib \ |
DEFINES += ANDROID_ARM7A |
||||||
-lboost_system-gcc-mt-1_53 \ |
# http://stackoverflow.com/a/30235934/529442 |
||||||
-lboost_date_time-gcc-mt-1_53 \ |
LIBS += -L$$BOOST_PATH/boost_1_53_0/armeabi-v7a/lib \ |
||||||
-lboost_filesystem-gcc-mt-1_53 \ |
-lboost_system-gcc-mt-1_53 -lboost_date_time-gcc-mt-1_53 \ |
||||||
-lboost_program_options-gcc-mt-1_53 \ |
-lboost_filesystem-gcc-mt-1_53 -lboost_program_options-gcc-mt-1_53 \ |
||||||
-L$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/ -lcrypto -lssl |
-L$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/ -lcrypto -lssl \ |
||||||
|
-L$$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/ -lminiupnpc |
||||||
PRE_TARGETDEPS += $$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libcrypto.a \ |
|
||||||
$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libssl.a |
PRE_TARGETDEPS += $$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libcrypto.a \ |
||||||
|
$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libssl.a |
||||||
DEPENDPATH += $$OPENSSL_PATH/openssl-1.0.2/include |
DEPENDPATH += $$OPENSSL_PATH/openssl-1.0.2/include |
||||||
|
|
||||||
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libcrypto_1_0_0.so \ |
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libcrypto_1_0_0.so \ |
||||||
$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libssl_1_0_0.so |
$$OPENSSL_PATH/openssl-1.0.2/armeabi-v7a/lib/libssl_1_0_0.so \ |
||||||
} |
$$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/libminiupnpc.so |
||||||
equals(ANDROID_TARGET_ARCH, x86){ |
} |
||||||
# http://stackoverflow.com/a/30235934/529442 |
|
||||||
LIBS += -L$$BOOST_PATH/boost_1_53_0/x86/lib \ |
equals(ANDROID_TARGET_ARCH, x86){ |
||||||
-lboost_system-gcc-mt-1_53 \ |
# http://stackoverflow.com/a/30235934/529442 |
||||||
-lboost_date_time-gcc-mt-1_53 \ |
LIBS += -L$$BOOST_PATH/boost_1_53_0/x86/lib \ |
||||||
-lboost_filesystem-gcc-mt-1_53 \ |
-lboost_system-gcc-mt-1_53 -lboost_date_time-gcc-mt-1_53 \ |
||||||
-lboost_program_options-gcc-mt-1_53 \ |
-lboost_filesystem-gcc-mt-1_53 -lboost_program_options-gcc-mt-1_53 \ |
||||||
-L$$OPENSSL_PATH/openssl-1.0.2/x86/lib/ -lcrypto -lssl |
-L$$OPENSSL_PATH/openssl-1.0.2/x86/lib/ -lcrypto -lssl \ |
||||||
|
-L$$MINIUPNP_PATH/miniupnp-2.0/x86/lib/ -lminiupnpc |
||||||
PRE_TARGETDEPS += $$OPENSSL_PATH/openssl-1.0.2/x86/lib/libcrypto.a \ |
|
||||||
$$OPENSSL_PATH/openssl-1.0.2/x86/lib/libssl.a |
PRE_TARGETDEPS += $$OPENSSL_PATH/openssl-1.0.2/x86/lib/libcrypto.a \ |
||||||
|
$$OPENSSL_PATH/openssl-1.0.2/x86/lib/libssl.a |
||||||
DEPENDPATH += $$OPENSSL_PATH/openssl-1.0.2/include |
|
||||||
|
DEPENDPATH += $$OPENSSL_PATH/openssl-1.0.2/include |
||||||
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/openssl-1.0.2/x86/lib/libcrypto_1_0_0.so \ |
|
||||||
$$OPENSSL_PATH/openssl-1.0.2/x86/lib/libssl_1_0_0.so |
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/openssl-1.0.2/x86/lib/libcrypto_1_0_0.so \ |
||||||
} |
$$OPENSSL_PATH/openssl-1.0.2/x86/lib/libssl_1_0_0.so \ |
||||||
|
$$MINIUPNP_PATH/miniupnp-2.0/x86/lib/libminiupnpc.so |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
linux:!android { |
linux:!android { |
||||||
message("Using Linux settings") |
message("Using Linux settings") |
||||||
LIBS += -lcrypto -lssl -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread |
LIBS += -lcrypto -lssl -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread -lminiupnpc |
||||||
} |
} |
||||||
|
|
||||||
|
!android:!symbian:!maemo5:!simulator { |
||||||
|
message("Build with a system tray icon") |
||||||
|
# see also http://doc.qt.io/qt-4.8/qt-desktop-systray-systray-pro.html for example on wince* |
||||||
|
#sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS i2pd_qt.pro resources images |
||||||
|
RESOURCES = i2pd.qrc |
||||||
|
QT += xml |
||||||
|
#INSTALLS += sources |
||||||
|
} |
||||||
|
After Width: | Height: | Size: 8.5 KiB |
@ -0,0 +1,45 @@ |
|||||||
|
#include <cassert> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include "../Base.h" |
||||||
|
|
||||||
|
using namespace i2p::data; |
||||||
|
|
||||||
|
int main() { |
||||||
|
const char *in = "test"; |
||||||
|
size_t in_len = strlen(in); |
||||||
|
char out[16]; |
||||||
|
|
||||||
|
/* bytes -> b64 */ |
||||||
|
assert(ByteStreamToBase64(NULL, 0, NULL, 0) == 0); |
||||||
|
assert(ByteStreamToBase64(NULL, 0, out, sizeof(out)) == 0); |
||||||
|
|
||||||
|
assert(Base64EncodingBufferSize(2) == 4); |
||||||
|
assert(Base64EncodingBufferSize(4) == 8); |
||||||
|
assert(Base64EncodingBufferSize(6) == 8); |
||||||
|
assert(Base64EncodingBufferSize(7) == 12); |
||||||
|
assert(Base64EncodingBufferSize(9) == 12); |
||||||
|
assert(Base64EncodingBufferSize(10) == 16); |
||||||
|
assert(Base64EncodingBufferSize(12) == 16); |
||||||
|
assert(Base64EncodingBufferSize(13) == 20); |
||||||
|
|
||||||
|
assert(ByteStreamToBase64((uint8_t *) in, in_len, out, sizeof(out)) == 8); |
||||||
|
assert(memcmp(out, "dGVzdA==", 8) == 0); |
||||||
|
|
||||||
|
/* b64 -> bytes */ |
||||||
|
assert(Base64ToByteStream(NULL, 0, NULL, 0) == 0); |
||||||
|
assert(Base64ToByteStream(NULL, 0, (uint8_t *) out, sizeof(out)) == 0); |
||||||
|
|
||||||
|
in = "dGVzdA=="; /* valid b64 */ |
||||||
|
assert(Base64ToByteStream(in, strlen(in), (uint8_t *) out, sizeof(out)) == 4); |
||||||
|
assert(memcmp(out, "test", 4) == 0); |
||||||
|
|
||||||
|
in = "dGVzdA="; /* invalid b64 : not padded */ |
||||||
|
assert(Base64ToByteStream(in, strlen(in), (uint8_t *) out, sizeof(out)) == 0); |
||||||
|
|
||||||
|
in = "dG/z.A=="; /* invalid b64 : char not from alphabet */ |
||||||
|
// assert(Base64ToByteStream(in, strlen(in), (uint8_t *) out, sizeof(out)) == 0);
|
||||||
|
// ^^^ fails, current implementation not checks acceptable symbols
|
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
Loading…
Reference in new issue