Browse Source

Merge pull request #278 from anonimal/master

Minor enhancements.
pull/281/head
EinMByte 9 years ago
parent
commit
e4f19716dd
  1. 8
      .gitignore
  2. 4
      client/ClientContext.cpp
  3. 2
      client/Daemon.cpp
  4. 6
      client/HTTPProxy.cpp
  5. 2
      client/SAM.cpp
  6. 2
      client/SAM.h
  7. 4
      client/SOCKS.cpp
  8. 2
      client/i2pcontrol/I2PControl.cpp
  9. 8
      client/i2pcontrol/I2PControl.h
  10. 4
      core/AddressBook.cpp
  11. 2
      core/Identity.h
  12. 8
      core/NetworkDatabase.cpp
  13. 14
      core/Reseed.cpp
  14. 2
      core/Reseed.h
  15. 2
      core/RouterInfo.cpp
  16. 6
      core/Streaming.cpp
  17. 6
      core/transport/NTCPSession.cpp
  18. 8
      core/transport/SSUSession.cpp
  19. 2
      core/transport/Transports.cpp
  20. 2
      core/tunnel/Tunnel.cpp
  21. 2
      core/tunnel/TunnelConfig.h
  22. 2
      core/tunnel/TunnelEndpoint.cpp
  23. 4
      core/tunnel/TunnelPool.cpp
  24. 2
      core/util/HTTP.h
  25. 12
      doc/BUILDING.md
  26. 8
      doc/BUILD_NOTES.md

8
.gitignore vendored

@ -63,6 +63,14 @@ local.properties @@ -63,6 +63,14 @@ local.properties
# PDT-specific
.buildpath
#################
## Netbeans
#################
# CMake: if "Project with Existing Sources" is properly setup, then only the following needs to be ignored:
# (e.g., don't select "Automatic" but instead select "Run Configure Script in Subfolder:" into ./build/)
build/compile_commands.json
nbproject/
#################
## Visual Studio

4
client/ClientContext.cpp

@ -154,7 +154,7 @@ namespace client @@ -154,7 +154,7 @@ namespace client
m_SamBridge->Stop ();
delete m_SamBridge;
m_SamBridge = nullptr;
LogPrint("SAM brdige stopped");
LogPrint("SAM bridge stopped");
}
if (m_BOBCommandChannel)
{
@ -316,7 +316,7 @@ namespace client @@ -316,7 +316,7 @@ namespace client
auto clientTunnel = new I2PClientTunnel(
dest, address, port, localDestination, destinationPort
);
// TODO: allow muliple tunnels on the same port (but on a different address)
// TODO: allow multiple tunnels on the same port (but on a different address)
if(m_ClientTunnels.insert(std::make_pair(port, std::unique_ptr<I2PClientTunnel>(clientTunnel))).second)
clientTunnel->Start ();
else

2
client/Daemon.cpp

@ -63,7 +63,7 @@ namespace i2p @@ -63,7 +63,7 @@ namespace i2p
if(i2p::util::config::HasArg("-install")) {
try {
i2p::util::filesystem::InstallFiles();
LogPrint("Succesfully installed all files.");
LogPrint("Successfully installed all files.");
} catch(const std::runtime_error& e) {
LogPrint(eLogError, "Failed to install: ", e.what());
return false;

6
client/HTTPProxy.cpp

@ -26,7 +26,7 @@ namespace proxy @@ -26,7 +26,7 @@ namespace proxy
GET_METHOD,
GET_HOSTNAME,
GET_HTTPV,
GET_HTTPVNL, //TODO: fallback to finding HOst: header if needed
GET_HTTPVNL, //TODO: fallback to finding Host: header if needed
DONE
};
@ -87,7 +87,7 @@ namespace proxy @@ -87,7 +87,7 @@ namespace proxy
}
/* All hope is lost beyond this point */
//TODO: handle this apropriately
//TODO: handle this appropriately
void HTTPProxyHandler::HTTPRequestFailed(/*HTTPProxyHandler::errTypes error*/)
{
static std::string response = "HTTP/1.0 500 Internal Server Error\r\nContent-type: text/html\r\nContent-length: 0\r\n";
@ -185,7 +185,7 @@ namespace proxy @@ -185,7 +185,7 @@ namespace proxy
assert(len); // This should always be called with a least a byte left to parse
while (len > 0)
{
//TODO: fallback to finding HOst: header if needed
//TODO: fallback to finding Host: header if needed
switch (m_state)
{
case GET_METHOD:

2
client/SAM.cpp

@ -296,7 +296,7 @@ namespace client @@ -296,7 +296,7 @@ namespace client
// host parameter set use that instead of loopback
host = hostitr->second;
}
// set forward addresss
// set forward address
m_udpForward = boost::asio::ip::udp::endpoint(boost::asio::ip::address::from_string(host), port);
// we are now a udp forward socket
m_SocketType = eSAMSocketTypeUDPForward;

2
client/SAM.h

@ -163,7 +163,7 @@ namespace client @@ -163,7 +163,7 @@ namespace client
void CloseSession (const std::string& id);
SAMSession * FindSession (const std::string& id) const;
// forward a datagran to a udp endpoint
// forward a datagram to a udp endpoint
void ForwardUDP(const boost::asio::ip::udp::endpoint & to_ep, const i2p::data::IdentityEx& from, const uint8_t * buff, size_t bufflen);
private:

4
client/SOCKS.cpp

@ -75,8 +75,8 @@ namespace proxy @@ -75,8 +75,8 @@ namespace proxy
SOCKS5_HOST_UNREACH = 4, // Host unreachable
SOCKS5_CONN_REFUSED = 5, // Connection refused by the peer
SOCKS5_TTL_EXPIRED = 6, // TTL Expired
SOCKS5_CMD_UNSUP = 7, // Command unsuported
SOCKS5_ADDR_UNSUP = 8, // Address type unsuported
SOCKS5_CMD_UNSUP = 7, // Command unsupported
SOCKS5_ADDR_UNSUP = 8, // Address type unsupported
SOCKS4_OK = 90, // No error for SOCKS4
SOCKS4_FAIL = 91, // Failed establishing connecting or not allowed
SOCKS4_IDENTD_MISSING = 92, // Couldn't connect to the identd server

2
client/i2pcontrol/I2PControl.cpp

@ -123,7 +123,7 @@ std::string I2PControlSession::Response::getErrorMsg() const @@ -123,7 +123,7 @@ std::string I2PControlSession::Response::getErrorMsg() const
case ErrorCode::NonexistentToken:
return "Nonexistent authentication token given.";
case ErrorCode::ExpiredToken:
return "Exipred authentication token given.";
return "Expired authentication token given.";
case ErrorCode::UnspecifiedVersion:
return "Version not specified.";
case ErrorCode::UnsupportedVersion:

8
client/i2pcontrol/I2PControl.h

@ -135,23 +135,23 @@ public: @@ -135,23 +135,23 @@ public:
std::string toJsonString() const;
/**
* Set an ouptut parameter to a specified string.
* Set an output parameter to a specified string.
* @todo escape quotes
*/
void setParam(const std::string& param, const std::string& value);
/**
* Set an ouptut parameter to a specified integer.
* Set an output parameter to a specified integer.
*/
void setParam(const std::string& param, int value);
/**
* Set an ouptut parameter to a specified double.
* Set an output parameter to a specified double.
*/
void setParam(const std::string& param, double value);
/**
* Set an ouptut parameter to a specified Json object.
* Set an output parameter to a specified Json object.
*/
void setParam(const std::string& param, const JsonObject& value);

4
core/AddressBook.cpp

@ -179,7 +179,7 @@ namespace client @@ -179,7 +179,7 @@ namespace client
}
if (m_IsDownloading)
{
LogPrint (eLogInfo, "Subscription is downloading. Waiting for temination...");
LogPrint (eLogInfo, "Subscription is downloading. Waiting for termination...");
for (int i = 0; i < 30; i++)
{
if (!m_IsDownloading)
@ -567,7 +567,7 @@ namespace client @@ -567,7 +567,7 @@ namespace client
LogPrint (eLogInfo, "No updates from ", m_Link);
}
else
LogPrint (eLogWarning, "Adressbook HTTP response ", status);
LogPrint (eLogWarning, "Addressbook HTTP response ", status);
}
else
LogPrint (eLogError, "Address ", u.host_, " not found");

2
core/Identity.h

@ -232,7 +232,7 @@ namespace data { @@ -232,7 +232,7 @@ namespace data {
IdentHash CreateRoutingKey (const IdentHash& ident);
XORMetric operator^(const IdentHash& key1, const IdentHash& key2);
// destination for delivery instuctions
// destination for delivery instructions
class RoutingDestination
{
public:

8
core/NetworkDatabase.cpp

@ -531,7 +531,7 @@ namespace data @@ -531,7 +531,7 @@ namespace data
AddRouterInfo (ident, uncompressed, uncomressedSize);
}
else
LogPrint ("Invalid RouterInfo uncomressed length ", (int)uncomressedSize);
LogPrint ("Invalid RouterInfo uncompressed length ", (int)uncomressedSize);
}
catch (CryptoPP::Exception& ex)
{
@ -598,11 +598,11 @@ namespace data @@ -598,11 +598,11 @@ namespace data
}
if (deleteDest)
// no more requests for the destinationation. delete it
// no more requests for the destination. delete it
m_Requests.RequestComplete (ident, nullptr);
}
else
// no more requests for detination possible. delete it
// no more requests for destination possible. delete it
m_Requests.RequestComplete (ident, nullptr);
}
else
@ -642,7 +642,7 @@ namespace data @@ -642,7 +642,7 @@ namespace data
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);
LogPrint ("DatabaseLookup for ", key, " received flags=", (int)flag);
uint8_t lookupType = flag & DATABASE_LOOKUP_TYPE_FLAGS_MASK;
const uint8_t * excluded = buf + 65;
uint32_t replyTunnelID = 0;

14
core/Reseed.cpp

@ -129,7 +129,7 @@ namespace data @@ -129,7 +129,7 @@ namespace data
int Reseeder::ReseedFromSU3 (const std::string& host, bool https)
{
std::string url = host + "i2pseeds.su3";
LogPrint (eLogInfo, "Dowloading SU3 from ", host);
LogPrint (eLogInfo, "Downloading SU3 from ", host);
std::string su3 = https ? HttpsRequest (url) : i2p::util::http::httpRequest (url);
if (su3.length () > 0)
{
@ -271,7 +271,7 @@ namespace data @@ -271,7 +271,7 @@ namespace data
s.read (localFileName, fileNameLength);
localFileName[fileNameLength] = 0;
s.seekg (extraFieldLength, std::ios::cur);
// take care about data desriptor if presented
// take care about data descriptor if presented
if (bitFlag & ZIP_BIT_FLAG_DATA_DESCRIPTOR)
{
size_t pos = s.tellg ();
@ -291,7 +291,7 @@ namespace data @@ -291,7 +291,7 @@ namespace data
s.seekg (pos, std::ios::beg); // back to compressed data
}
LogPrint (eLogDebug, "Proccessing file ", localFileName, " ", compressedSize, " bytes");
LogPrint (eLogDebug, "Processing file ", localFileName, " ", compressedSize, " bytes");
if (!compressedSize)
{
LogPrint (eLogWarning, "Unexpected size 0. Skipped");
@ -570,7 +570,7 @@ namespace data @@ -570,7 +570,7 @@ namespace data
uint8_t paddingSize = size + 1;
paddingSize &= 0x0F; // %16
if (paddingSize > 0) paddingSize = 16 - paddingSize;
memset (out + size, paddingSize, paddingSize + 1); // paddind and last byte are equal to padding size
memset (out + size, paddingSize, paddingSize + 1); // padding and last byte are equal to padding size
size += paddingSize + 1;
m_Encryption.Encrypt (out + 16, size - 16, out + 16);
return size;
@ -755,19 +755,19 @@ namespace data @@ -755,19 +755,19 @@ namespace data
// create cipher
if (cipherSuite[1] == 0x3D)
{
LogPrint (eLogInfo, "Chiper suite is RSA_WITH_AES_256_CBC_SHA256");
LogPrint (eLogInfo, "Cipher suite is RSA_WITH_AES_256_CBC_SHA256");
m_Cipher = new TlsCipher_AES_256_CBC<CryptoPP::SHA256> (keys);
}
else if (cipherSuite[1] == 0x35)
{
LogPrint (eLogInfo, "Chiper suite is RSA_WITH_AES_256_CBC_SHA");
LogPrint (eLogInfo, "Cipher suite is RSA_WITH_AES_256_CBC_SHA");
m_Cipher = new TlsCipher_AES_256_CBC<CryptoPP::SHA1> (keys);
}
else
{
// TODO:
if (cipherSuite[1] == 0x05)
LogPrint (eLogInfo, "Chiper suite is RSA_WITH_RC4_128_SHA");
LogPrint (eLogInfo, "Cipher suite is RSA_WITH_RC4_128_SHA");
m_Cipher = new TlsCipher_RC4_SHA (keys);
}
// send finished

2
core/Reseed.h

@ -24,7 +24,7 @@ namespace data @@ -24,7 +24,7 @@ namespace data
Reseeder();
~Reseeder();
bool reseedNow(); // depreacted
bool reseedNow(); // deprecated
int ReseedNowSU3 ();
void LoadCertificates ();

2
core/RouterInfo.cpp

@ -52,7 +52,7 @@ namespace data @@ -52,7 +52,7 @@ namespace data
memcpy (m_Buffer, buf, len);
m_BufferLen = len;
ReadFromBuffer (true);
// don't delete buffer until save to file
// don't delete buffer until saved to file
}
void RouterInfo::SetRouterIdentity (const IdentityEx& identity)

6
core/Streaming.cpp

@ -466,7 +466,7 @@ namespace stream @@ -466,7 +466,7 @@ namespace stream
size++; // NACK count
}
size++; // resend delay
htobuf16 (packet + size, 0); // nof flags set
htobuf16 (packet + size, 0); // no flags set
size += 2; // flags
htobuf16 (packet + size, 0); // no options
size += 2; // options size
@ -668,7 +668,7 @@ namespace stream @@ -668,7 +668,7 @@ namespace stream
m_RTO *= 2;
switch (m_NumResendAttempts)
{
case 1: // congesion avoidance
case 1: // congestion avoidance
m_WindowSize /= 2;
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE;
break;
@ -698,7 +698,7 @@ namespace stream @@ -698,7 +698,7 @@ namespace stream
{
if (m_LastReceivedSequenceNumber < 0)
{
LogPrint (eLogWarning, "SYN has not been recived after ", ACK_SEND_TIMEOUT, " milliseconds after follow on. Terminate");
LogPrint (eLogWarning, "SYN has not been received after ", ACK_SEND_TIMEOUT, " milliseconds after follow on. Terminate");
m_Status = eStreamStatusReset;
Close ();
return;

6
core/transport/NTCPSession.cpp

@ -548,7 +548,7 @@ namespace transport @@ -548,7 +548,7 @@ namespace transport
{
if (!m_NextMessage) // new message, header expected
{
// descrypt header and extract length
// decrypt header and extract length
uint8_t buf[16];
m_Decryption.Decrypt (encrypted, buf);
uint16_t dataSize = bufbe16toh (buf);
@ -586,7 +586,7 @@ namespace transport @@ -586,7 +586,7 @@ namespace transport
if (CryptoPP::Adler32().VerifyDigest (m_NextMessage->buf + m_NextMessageOffset - 4, m_NextMessage->buf, m_NextMessageOffset - 4))
m_Handler.PutNextMessage (m_NextMessage);
else
LogPrint (eLogWarning, "Incorrect adler checksum of NTCP message. Dropped");
LogPrint (eLogWarning, "Incorrect Adler checksum of NTCP message. Dropped");
m_NextMessage = nullptr;
}
return true;
@ -703,7 +703,7 @@ namespace transport @@ -703,7 +703,7 @@ namespace transport
{
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint ("No activity fo ", NTCP_TERMINATION_TIMEOUT, " seconds");
LogPrint ("No activity for ", NTCP_TERMINATION_TIMEOUT, " seconds");
//Terminate ();
m_Socket.close ();// invoke Terminate () from HandleReceive
}

8
core/transport/SSUSession.cpp

@ -517,7 +517,7 @@ namespace transport @@ -517,7 +517,7 @@ namespace transport
}
else
{
// ecrypt with Alice's intro key
// encrypt with Alice's intro key
uint8_t iv[16];
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
rnd.GenerateBlock (iv, 16); // random iv
@ -809,7 +809,7 @@ namespace transport @@ -809,7 +809,7 @@ namespace transport
{
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint ("SSU no activity fo ", SSU_TERMINATION_TIMEOUT, " seconds");
LogPrint ("SSU no activity for ", SSU_TERMINATION_TIMEOUT, " seconds");
Failed ();
}
}
@ -955,7 +955,7 @@ namespace transport @@ -955,7 +955,7 @@ namespace transport
void SSUSession::SendPeerTest (uint32_t nonce, uint32_t address, uint16_t port,
const uint8_t * introKey, bool toAddress, bool sendAddress)
// toAddress is true for Alice<->Chalie communications only
// toAddress is true for Alice<->Charlie communications only
// sendAddress is false if message comes from Alice
{
uint8_t buf[80 + 18] = {};
@ -1056,7 +1056,7 @@ namespace transport @@ -1056,7 +1056,7 @@ namespace transport
}
catch (std::exception& ex)
{
LogPrint (eLogError, "SSU send session destoriyed exception ", ex.what ());
LogPrint (eLogError, "SSU send session destroyed exception ", ex.what ());
}
LogPrint (eLogDebug, "SSU session destroyed sent");
}

2
core/transport/Transports.cpp

@ -48,7 +48,7 @@ namespace transport @@ -48,7 +48,7 @@ namespace transport
while ((num = m_QueueSize - m_Queue.size ()) > 0)
CreateDHKeysPairs (num);
std::unique_lock<std::mutex> l(m_AcquiredMutex);
m_Acquired.wait (l); // wait for element gets aquired
m_Acquired.wait (l); // wait for element gets acquired
}
}

2
core/tunnel/Tunnel.cpp

@ -547,7 +547,7 @@ namespace tunnel @@ -547,7 +547,7 @@ namespace tunnel
if (m_OutboundTunnels.size () < 5)
{
// trying to create one more oubound tunnel
// trying to create one more outbound tunnel
auto inboundTunnel = GetNextInboundTunnel ();
auto router = i2p::data::netdb.GetRandomRouter ();
if (!inboundTunnel || !router) return;

2
core/tunnel/TunnelConfig.h

@ -199,7 +199,7 @@ namespace tunnel @@ -199,7 +199,7 @@ namespace tunnel
return;
hop = hop->next;
}
// we didn't reach enpoint that mean we are last hop
// we didn't reach endpoint that mean we are last hop
s << ":me";
}

2
core/tunnel/TunnelEndpoint.cpp

@ -106,7 +106,7 @@ namespace tunnel @@ -106,7 +106,7 @@ namespace tunnel
{
if (msgID) // msgID is presented, assume message is fragmented
{
if (!isFollowOnFragment) // create new incomlete message
if (!isFollowOnFragment) // create new incomplete message
{
m.nextFragmentNum = 1;
auto ret = m_IncompleteMessages.insert (std::pair<uint32_t, TunnelMessageBlockEx>(msgID, m));

4
core/tunnel/TunnelPool.cpp

@ -32,12 +32,12 @@ namespace tunnel @@ -32,12 +32,12 @@ namespace tunnel
if (m_NumInboundHops > size)
{
m_NumInboundHops = size;
LogPrint (eLogInfo, "Inbound tunnel length has beed adjusted to ", size, " for explicit peers");
LogPrint (eLogInfo, "Inbound tunnel length has been adjusted to ", size, " for explicit peers");
}
if (m_NumOutboundHops > size)
{
m_NumOutboundHops = size;
LogPrint (eLogInfo, "Outbound tunnel length has beed adjusted to ", size, " for explicit peers");
LogPrint (eLogInfo, "Outbound tunnel length has been adjusted to ", size, " for explicit peers");
}
m_NumInboundTunnels = 1;
m_NumOutboundTunnels = 1;

2
core/util/HTTP.h

@ -74,7 +74,7 @@ public: @@ -74,7 +74,7 @@ public:
std::string toString() const;
/**
* @return the message associated with the satus of this response, or the
* @return the message associated with the status of this response, or the
* empty string if the status number is invalid
*/
std::string getStatusMessage() const;

12
doc/BUILDING.md

@ -3,9 +3,15 @@ Building @@ -3,9 +3,15 @@ Building
On Ubuntu/Debian based
* sudo apt-get install libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libcrypto++-dev libboost-date-time-dev
* $ cd i2pd/build
* $ cmake ..
* $ make
On Arch Linux
* sudo pacman -Syu cmake boost crypto++
Then, build:
$ cd i2pd/build
$ cmake ../
$ make
Then, run it:

8
doc/BUILD_NOTES.md

@ -13,6 +13,14 @@ Required "-dev" packages: @@ -13,6 +13,14 @@ Required "-dev" packages:
Optional packages:
* libboost-test-dev
Arch
----
Required packages:
*cmake
*boost
*crypto++
FreeBSD
-------

Loading…
Cancel
Save