Browse Source

use uint16_t for ports

Signed-off-by: r4sas <r4sas@i2pmail.org>
pull/1938/head
R4SAS 2 years ago
parent
commit
03cc6e0524
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 18
      libi2pd/Destination.cpp
  2. 18
      libi2pd/Destination.h
  3. 26
      libi2pd_client/BOB.cpp
  4. 20
      libi2pd_client/BOB.h
  5. 26
      libi2pd_client/ClientContext.cpp
  6. 2
      libi2pd_client/HTTPProxy.cpp
  7. 6
      libi2pd_client/HTTPProxy.h
  8. 2
      libi2pd_client/I2CP.cpp
  9. 4
      libi2pd_client/I2CP.h
  10. 6
      libi2pd_client/I2PService.cpp
  11. 10
      libi2pd_client/I2PService.h
  12. 20
      libi2pd_client/I2PTunnel.cpp
  13. 24
      libi2pd_client/I2PTunnel.h
  14. 4
      libi2pd_client/SAM.cpp
  15. 6
      libi2pd_client/SAM.h
  16. 2
      libi2pd_client/SOCKS.cpp
  17. 4
      libi2pd_client/SOCKS.h

18
libi2pd/Destination.cpp

@ -1111,7 +1111,7 @@ namespace client
} }
} }
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, int port) void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, uint16_t port)
{ {
if (!streamRequestComplete) if (!streamRequestComplete)
{ {
@ -1141,7 +1141,7 @@ namespace client
} }
} }
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port) void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, uint16_t port)
{ {
if (!streamRequestComplete) if (!streamRequestComplete)
{ {
@ -1160,7 +1160,7 @@ namespace client
} }
template<typename Dest> template<typename Dest>
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStreamSync (const Dest& dest, int port) std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStreamSync (const Dest& dest, uint16_t port)
{ {
volatile bool done = false; volatile bool done = false;
std::shared_ptr<i2p::stream::Stream> stream; std::shared_ptr<i2p::stream::Stream> stream;
@ -1184,17 +1184,17 @@ namespace client
return stream; return stream;
} }
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (const i2p::data::IdentHash& dest, int port) std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (const i2p::data::IdentHash& dest, uint16_t port)
{ {
return CreateStreamSync (dest, port); return CreateStreamSync (dest, port);
} }
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port) std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, uint16_t port)
{ {
return CreateStreamSync (dest, port); return CreateStreamSync (dest, port);
} }
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port) std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, uint16_t port)
{ {
if (m_StreamingDestination) if (m_StreamingDestination)
return m_StreamingDestination->CreateNewOutgoingStream (remote, port); return m_StreamingDestination->CreateNewOutgoingStream (remote, port);
@ -1231,7 +1231,7 @@ namespace client
}); });
} }
std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::GetStreamingDestination (int port) const std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::GetStreamingDestination (uint16_t port) const
{ {
if (port) if (port)
{ {
@ -1269,7 +1269,7 @@ namespace client
m_StreamingDestination->AcceptOnce (acceptor); m_StreamingDestination->AcceptOnce (acceptor);
} }
std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::CreateStreamingDestination (int port, bool gzip) std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::CreateStreamingDestination (uint16_t port, bool gzip)
{ {
auto dest = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis (), port, gzip); auto dest = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis (), port, gzip);
if (port) if (port)
@ -1279,7 +1279,7 @@ namespace client
return dest; return dest;
} }
std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::RemoveStreamingDestination (int port) std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::RemoveStreamingDestination (uint16_t port)
{ {
if (port) if (port)
{ {

18
libi2pd/Destination.h

@ -242,15 +242,15 @@ namespace client
int GetRefCounter () const { return m_RefCounter; }; int GetRefCounter () const { return m_RefCounter; };
// streaming // streaming
std::shared_ptr<i2p::stream::StreamingDestination> CreateStreamingDestination (int port, bool gzip = true); // additional std::shared_ptr<i2p::stream::StreamingDestination> CreateStreamingDestination (uint16_t port, bool gzip = true); // additional
std::shared_ptr<i2p::stream::StreamingDestination> GetStreamingDestination (int port = 0) const; std::shared_ptr<i2p::stream::StreamingDestination> GetStreamingDestination (uint16_t port = 0) const;
std::shared_ptr<i2p::stream::StreamingDestination> RemoveStreamingDestination (int port); std::shared_ptr<i2p::stream::StreamingDestination> RemoveStreamingDestination (uint16_t port);
// following methods operate with default streaming destination // following methods operate with default streaming destination
void CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, int port = 0); void CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, uint16_t port = 0);
void CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port = 0); void CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, uint16_t port = 0);
std::shared_ptr<i2p::stream::Stream> CreateStream (const i2p::data::IdentHash& dest, int port = 0); // sync std::shared_ptr<i2p::stream::Stream> CreateStream (const i2p::data::IdentHash& dest, uint16_t port = 0); // sync
std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port = 0); // sync std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, uint16_t port = 0); // sync
std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port = 0); std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, uint16_t port = 0);
void SendPing (const i2p::data::IdentHash& to); void SendPing (const i2p::data::IdentHash& to);
void SendPing (std::shared_ptr<const i2p::data::BlindedPublicKey> to); void SendPing (std::shared_ptr<const i2p::data::BlindedPublicKey> to);
void AcceptStreams (const i2p::stream::StreamingDestination::Acceptor& acceptor); void AcceptStreams (const i2p::stream::StreamingDestination::Acceptor& acceptor);
@ -286,7 +286,7 @@ namespace client
void ReadAuthKey (const std::string& group, const std::map<std::string, std::string> * params); void ReadAuthKey (const std::string& group, const std::map<std::string, std::string> * params);
template<typename Dest> template<typename Dest>
std::shared_ptr<i2p::stream::Stream> CreateStreamSync (const Dest& dest, int port); std::shared_ptr<i2p::stream::Stream> CreateStreamSync (const Dest& dest, uint16_t port);
private: private:

26
libi2pd_client/BOB.cpp

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2022, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -127,7 +127,7 @@ namespace client
connection->I2PConnect (receiver->data, receiver->dataLen); connection->I2PConnect (receiver->data, receiver->dataLen);
} }
BOBI2POutboundTunnel::BOBI2POutboundTunnel (const std::string& outhost, int port, BOBI2POutboundTunnel::BOBI2POutboundTunnel (const std::string& outhost, uint16_t port,
std::shared_ptr<ClientDestination> localDestination, bool quiet): BOBI2PTunnel (localDestination), std::shared_ptr<ClientDestination> localDestination, bool quiet): BOBI2PTunnel (localDestination),
m_Endpoint (boost::asio::ip::address::from_string (outhost), port), m_IsQuiet (quiet) m_Endpoint (boost::asio::ip::address::from_string (outhost), port), m_IsQuiet (quiet)
{ {
@ -164,7 +164,7 @@ namespace client
BOBDestination::BOBDestination (std::shared_ptr<ClientDestination> localDestination, BOBDestination::BOBDestination (std::shared_ptr<ClientDestination> localDestination,
const std::string &nickname, const std::string &inhost, const std::string &outhost, const std::string &nickname, const std::string &inhost, const std::string &outhost,
const int inport, const int outport, const bool quiet): const uint16_t inport, const uint16_t outport, const bool quiet):
m_LocalDestination (localDestination), m_LocalDestination (localDestination),
m_OutboundTunnel (nullptr), m_InboundTunnel (nullptr), m_OutboundTunnel (nullptr), m_InboundTunnel (nullptr),
m_Nickname(nickname), m_InHost(inhost), m_OutHost(outhost), m_Nickname(nickname), m_InHost(inhost), m_OutHost(outhost),
@ -209,7 +209,7 @@ namespace client
} }
} }
void BOBDestination::CreateInboundTunnel (int port, const std::string& inhost) void BOBDestination::CreateInboundTunnel (uint16_t port, const std::string& inhost)
{ {
if (!m_InboundTunnel) if (!m_InboundTunnel)
{ {
@ -230,7 +230,7 @@ namespace client
} }
} }
void BOBDestination::CreateOutboundTunnel (const std::string& outhost, int port, bool quiet) void BOBDestination::CreateOutboundTunnel (const std::string& outhost, uint16_t port, bool quiet)
{ {
if (!m_OutboundTunnel) if (!m_OutboundTunnel)
{ {
@ -595,9 +595,12 @@ namespace client
LogPrint (eLogDebug, "BOB: outport ", operand); LogPrint (eLogDebug, "BOB: outport ", operand);
if (*operand) if (*operand)
{ {
m_OutPort = std::stoi(operand); int port = std::stoi(operand);
if (m_OutPort >= 0) if (port >= 0 && port < 65536)
{
m_OutPort = port;
SendReplyOK ("outbound port set"); SendReplyOK ("outbound port set");
}
else else
SendReplyError ("port out of range"); SendReplyError ("port out of range");
} }
@ -622,9 +625,12 @@ namespace client
LogPrint (eLogDebug, "BOB: inport ", operand); LogPrint (eLogDebug, "BOB: inport ", operand);
if (*operand) if (*operand)
{ {
m_InPort = std::stoi(operand); int port = std::stoi(operand);
if (m_InPort >= 0) if (port >= 0 && port < 65536)
{
m_InPort = port;
SendReplyOK ("inbound port set"); SendReplyOK ("inbound port set");
}
else else
SendReplyError ("port out of range"); SendReplyError ("port out of range");
} }
@ -814,7 +820,7 @@ namespace client
} }
} }
BOBCommandChannel::BOBCommandChannel (const std::string& address, int port): BOBCommandChannel::BOBCommandChannel (const std::string& address, uint16_t port):
RunnableService ("BOB"), RunnableService ("BOB"),
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), port)) m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), port))
{ {

20
libi2pd_client/BOB.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -124,7 +124,7 @@ namespace client
{ {
public: public:
BOBI2POutboundTunnel (const std::string& outhost, int port, std::shared_ptr<ClientDestination> localDestination, bool quiet); BOBI2POutboundTunnel (const std::string& outhost, uint16_t port, std::shared_ptr<ClientDestination> localDestination, bool quiet);
void Start (); void Start ();
void Stop (); void Stop ();
@ -149,19 +149,19 @@ namespace client
BOBDestination (std::shared_ptr<ClientDestination> localDestination, BOBDestination (std::shared_ptr<ClientDestination> localDestination,
const std::string &nickname, const std::string &inhost, const std::string &outhost, const std::string &nickname, const std::string &inhost, const std::string &outhost,
const int inport, const int outport, const bool quiet); const uint16_t inport, const uint16_t outport, const bool quiet);
~BOBDestination (); ~BOBDestination ();
void Start (); void Start ();
void Stop (); void Stop ();
void StopTunnels (); void StopTunnels ();
void CreateInboundTunnel (int port, const std::string& inhost); void CreateInboundTunnel (uint16_t port, const std::string& inhost);
void CreateOutboundTunnel (const std::string& outhost, int port, bool quiet); void CreateOutboundTunnel (const std::string& outhost, uint16_t port, bool quiet);
const std::string& GetNickname() const { return m_Nickname; } const std::string& GetNickname() const { return m_Nickname; }
const std::string& GetInHost() const { return m_InHost; } const std::string& GetInHost() const { return m_InHost; }
const std::string& GetOutHost() const { return m_OutHost; } const std::string& GetOutHost() const { return m_OutHost; }
int GetInPort() const { return m_InPort; } uint16_t GetInPort() const { return m_InPort; }
int GetOutPort() const { return m_OutPort; } uint16_t GetOutPort() const { return m_OutPort; }
bool GetQuiet() const { return m_Quiet; } bool GetQuiet() const { return m_Quiet; }
bool IsRunning() const { return m_IsRunning; } bool IsRunning() const { return m_IsRunning; }
const i2p::data::PrivateKeys& GetKeys () const { return m_LocalDestination->GetPrivateKeys (); }; const i2p::data::PrivateKeys& GetKeys () const { return m_LocalDestination->GetPrivateKeys (); };
@ -175,7 +175,7 @@ namespace client
std::string m_Nickname; std::string m_Nickname;
std::string m_InHost, m_OutHost; std::string m_InHost, m_OutHost;
int m_InPort, m_OutPort; uint16_t m_InPort, m_OutPort;
bool m_Quiet; bool m_Quiet;
bool m_IsRunning; bool m_IsRunning;
}; };
@ -237,7 +237,7 @@ namespace client
boost::asio::streambuf m_ReceiveBuffer, m_SendBuffer; boost::asio::streambuf m_ReceiveBuffer, m_SendBuffer;
bool m_IsOpen, m_IsQuiet, m_IsActive; bool m_IsOpen, m_IsQuiet, m_IsActive;
std::string m_Nickname, m_InHost, m_OutHost; std::string m_Nickname, m_InHost, m_OutHost;
int m_InPort, m_OutPort; uint16_t m_InPort, m_OutPort;
i2p::data::PrivateKeys m_Keys; i2p::data::PrivateKeys m_Keys;
std::map<std::string, std::string> m_Options; std::map<std::string, std::string> m_Options;
BOBDestination * m_CurrentDestination; BOBDestination * m_CurrentDestination;
@ -248,7 +248,7 @@ namespace client
{ {
public: public:
BOBCommandChannel (const std::string& address, int port); BOBCommandChannel (const std::string& address, uint16_t port);
~BOBCommandChannel (); ~BOBCommandChannel ();
void Start (); void Start ();

26
libi2pd_client/ClientContext.cpp

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2022, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -577,12 +577,12 @@ namespace client
std::string dest; std::string dest;
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION); dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT); uint16_t port = section.second.get<uint16_t> (I2P_CLIENT_TUNNEL_PORT);
// optional params // optional params
bool matchTunnels = section.second.get(I2P_CLIENT_TUNNEL_MATCH_TUNNELS, false); bool matchTunnels = section.second.get (I2P_CLIENT_TUNNEL_MATCH_TUNNELS, false);
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "transient"); std::string keys = section.second.get<std::string> (I2P_CLIENT_TUNNEL_KEYS, "transient");
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1"); std::string address = section.second.get<std::string> (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); uint16_t destinationPort = section.second.get<uint16_t> (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519); i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519);
i2p::data::CryptoKeyType cryptoType = section.second.get (I2P_CLIENT_TUNNEL_CRYPTO_TYPE, i2p::data::CRYPTO_KEY_TYPE_ELGAMAL); i2p::data::CryptoKeyType cryptoType = section.second.get (I2P_CLIENT_TUNNEL_CRYPTO_TYPE, i2p::data::CRYPTO_KEY_TYPE_ELGAMAL);
// I2CP // I2CP
@ -720,22 +720,22 @@ namespace client
{ {
// mandatory params // mandatory params
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST); std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST);
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT); uint16_t port = section.second.get<uint16_t> (I2P_SERVER_TUNNEL_PORT);
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS); std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
// optional params // optional params
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0); uint16_t inPort = section.second.get<uint16_t> (I2P_SERVER_TUNNEL_INPORT, 0);
std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, ""); std::string accessList = section.second.get<std::string> (I2P_SERVER_TUNNEL_ACCESS_LIST, "");
if(accessList == "") if(accessList == "")
accessList=section.second.get (I2P_SERVER_TUNNEL_WHITE_LIST, ""); accessList = section.second.get<std::string> (I2P_SERVER_TUNNEL_WHITE_LIST, "");
std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, ""); std::string hostOverride = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST_OVERRIDE, "");
std::string webircpass = section.second.get<std::string> (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, ""); std::string webircpass = section.second.get<std::string> (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, "");
bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, false); bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, false);
i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519); i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519);
i2p::data::CryptoKeyType cryptoType = section.second.get (I2P_CLIENT_TUNNEL_CRYPTO_TYPE, i2p::data::CRYPTO_KEY_TYPE_ELGAMAL); i2p::data::CryptoKeyType cryptoType = section.second.get (I2P_CLIENT_TUNNEL_CRYPTO_TYPE, i2p::data::CRYPTO_KEY_TYPE_ELGAMAL);
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, ""); std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "");
bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true); bool isUniqueLocal = section.second.get (I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
bool ssl = section.second.get(I2P_SERVER_TUNNEL_SSL, false); bool ssl = section.second.get (I2P_SERVER_TUNNEL_SSL, false);
// I2CP // I2CP
std::map<std::string, std::string> options; std::map<std::string, std::string> options;

2
libi2pd_client/HTTPProxy.cpp

@ -748,7 +748,7 @@ namespace proxy {
Done (shared_from_this()); Done (shared_from_this());
} }
HTTPProxy::HTTPProxy(const std::string& name, const std::string& address, int port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination): HTTPProxy::HTTPProxy(const std::string& name, const std::string& address, uint16_t port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination):
TCPIPAcceptor (address, port, localDestination ? localDestination : i2p::client::context.GetSharedLocalDestination ()), TCPIPAcceptor (address, port, localDestination ? localDestination : i2p::client::context.GetSharedLocalDestination ()),
m_Name (name), m_OutproxyUrl (outproxy), m_Addresshelper (addresshelper) m_Name (name), m_OutproxyUrl (outproxy), m_Addresshelper (addresshelper)
{ {

6
libi2pd_client/HTTPProxy.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -15,8 +15,8 @@ namespace proxy {
{ {
public: public:
HTTPProxy(const std::string& name, const std::string& address, int port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination); HTTPProxy(const std::string& name, const std::string& address, uint16_t port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination);
HTTPProxy(const std::string& name, const std::string& address, int port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr) : HTTPProxy(const std::string& name, const std::string& address, uint16_t port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr) :
HTTPProxy(name, address, port, "", true, localDestination) {} ; HTTPProxy(name, address, port, "", true, localDestination) {} ;
~HTTPProxy() {}; ~HTTPProxy() {};

2
libi2pd_client/I2CP.cpp

@ -936,7 +936,7 @@ namespace client
} }
} }
I2CPServer::I2CPServer (const std::string& interface, int port, bool isSingleThread): I2CPServer::I2CPServer (const std::string& interface, uint16_t port, bool isSingleThread):
RunnableService ("I2CP"), m_IsSingleThread (isSingleThread), RunnableService ("I2CP"), m_IsSingleThread (isSingleThread),
m_Acceptor (GetIOService (), m_Acceptor (GetIOService (),
boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(interface), port)) boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(interface), port))

4
libi2pd_client/I2CP.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2022, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -210,7 +210,7 @@ namespace client
{ {
public: public:
I2CPServer (const std::string& interface, int port, bool isSingleThread); I2CPServer (const std::string& interface, uint16_t port, bool isSingleThread);
~I2CPServer (); ~I2CPServer ();
void Start (); void Start ();

6
libi2pd_client/I2PService.cpp

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -107,7 +107,7 @@ namespace client
m_ReadyTimerTriggered = false; m_ReadyTimerTriggered = false;
} }
void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) { void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, uint16_t port) {
assert(streamRequestComplete); assert(streamRequestComplete);
auto address = i2p::client::context.GetAddressBook ().GetAddress (dest); auto address = i2p::client::context.GetAddressBook ().GetAddress (dest);
if (address) if (address)
@ -119,7 +119,7 @@ namespace client
} }
} }
void I2PService::CreateStream(StreamRequestComplete streamRequestComplete, std::shared_ptr<const Address> address, int port) void I2PService::CreateStream(StreamRequestComplete streamRequestComplete, std::shared_ptr<const Address> address, uint16_t port)
{ {
if(m_ConnectTimeout && !m_LocalDestination->IsReady()) if(m_ConnectTimeout && !m_LocalDestination->IsReady())
{ {

10
libi2pd_client/I2PService.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -59,8 +59,8 @@ namespace client
if (dest) dest->Acquire (); if (dest) dest->Acquire ();
m_LocalDestination = dest; m_LocalDestination = dest;
} }
void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port = 0); void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, uint16_t port = 0);
void CreateStream(StreamRequestComplete complete, std::shared_ptr<const Address> address, int port); void CreateStream(StreamRequestComplete complete, std::shared_ptr<const Address> address, uint16_t port);
inline boost::asio::io_service& GetService () { return m_LocalDestination->GetService (); } inline boost::asio::io_service& GetService () { return m_LocalDestination->GetService (); }
virtual void Start () = 0; virtual void Start () = 0;
@ -155,11 +155,11 @@ namespace client
{ {
public: public:
TCPIPAcceptor (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination = nullptr) : TCPIPAcceptor (const std::string& address, uint16_t port, std::shared_ptr<ClientDestination> localDestination = nullptr) :
I2PService(localDestination), I2PService(localDestination),
m_LocalEndpoint (boost::asio::ip::address::from_string(address), port), m_LocalEndpoint (boost::asio::ip::address::from_string(address), port),
m_Timer (GetService ()) {} m_Timer (GetService ()) {}
TCPIPAcceptor (const std::string& address, int port, i2p::data::SigningKeyType kt) : TCPIPAcceptor (const std::string& address, uint16_t port, i2p::data::SigningKeyType kt) :
I2PService(kt), I2PService(kt),
m_LocalEndpoint (boost::asio::ip::address::from_string(address), port), m_LocalEndpoint (boost::asio::ip::address::from_string(address), port),
m_Timer (GetService ()) {} m_Timer (GetService ()) {}

20
libi2pd_client/I2PTunnel.cpp

@ -31,7 +31,7 @@ namespace client
} }
I2PTunnelConnection::I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket, I2PTunnelConnection::I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
std::shared_ptr<const i2p::data::LeaseSet> leaseSet, int port): std::shared_ptr<const i2p::data::LeaseSet> leaseSet, uint16_t port):
I2PServiceHandler(owner), m_Socket (socket), m_RemoteEndpoint (socket->remote_endpoint ()), I2PServiceHandler(owner), m_Socket (socket), m_RemoteEndpoint (socket->remote_endpoint ()),
m_IsQuiet (true) m_IsQuiet (true)
{ {
@ -581,7 +581,7 @@ namespace client
{ {
public: public:
I2PClientTunnelHandler (I2PClientTunnel * parent, std::shared_ptr<const Address> address, I2PClientTunnelHandler (I2PClientTunnel * parent, std::shared_ptr<const Address> address,
int destinationPort, std::shared_ptr<boost::asio::ip::tcp::socket> socket): uint16_t destinationPort, std::shared_ptr<boost::asio::ip::tcp::socket> socket):
I2PServiceHandler(parent), m_Address(address), I2PServiceHandler(parent), m_Address(address),
m_DestinationPort (destinationPort), m_Socket(socket) {}; m_DestinationPort (destinationPort), m_Socket(socket) {};
void Handle(); void Handle();
@ -589,7 +589,7 @@ namespace client
private: private:
void HandleStreamRequestComplete (std::shared_ptr<i2p::stream::Stream> stream); void HandleStreamRequestComplete (std::shared_ptr<i2p::stream::Stream> stream);
std::shared_ptr<const Address> m_Address; std::shared_ptr<const Address> m_Address;
int m_DestinationPort; uint16_t m_DestinationPort;
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket; std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
}; };
@ -630,7 +630,7 @@ namespace client
} }
I2PClientTunnel::I2PClientTunnel (const std::string& name, const std::string& destination, I2PClientTunnel::I2PClientTunnel (const std::string& name, const std::string& destination,
const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination, int destinationPort): const std::string& address, uint16_t port, std::shared_ptr<ClientDestination> localDestination, uint16_t destinationPort):
TCPIPAcceptor (address, port, localDestination), m_Name (name), m_Destination (destination), TCPIPAcceptor (address, port, localDestination), m_Name (name), m_Destination (destination),
m_DestinationPort (destinationPort), m_KeepAliveInterval (0) m_DestinationPort (destinationPort), m_KeepAliveInterval (0)
{ {
@ -705,10 +705,10 @@ namespace client
} }
I2PServerTunnel::I2PServerTunnel (const std::string& name, const std::string& address, I2PServerTunnel::I2PServerTunnel (const std::string& name, const std::string& address,
int port, std::shared_ptr<ClientDestination> localDestination, int inport, bool gzip): uint16_t port, std::shared_ptr<ClientDestination> localDestination, uint16_t inport, bool gzip):
I2PService (localDestination), m_IsUniqueLocal(true), m_Name (name), m_Address (address), m_Port (port), m_IsAccessList (false) I2PService (localDestination), m_IsUniqueLocal(true), m_Name (name), m_Address (address), m_Port (port), m_IsAccessList (false)
{ {
int inPort = (inport ? inport : port); uint16_t inPort = (inport ? inport : port);
m_PortDestination = localDestination->GetStreamingDestination (inPort); m_PortDestination = localDestination->GetStreamingDestination (inPort);
if (!m_PortDestination) // default destination if (!m_PortDestination) // default destination
m_PortDestination = localDestination->CreateStreamingDestination (inPort, gzip); m_PortDestination = localDestination->CreateStreamingDestination (inPort, gzip);
@ -870,8 +870,8 @@ namespace client
} }
I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address, I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address,
int port, std::shared_ptr<ClientDestination> localDestination, uint16_t port, std::shared_ptr<ClientDestination> localDestination,
const std::string& host, int inport, bool gzip): const std::string& host, uint16_t inport, bool gzip):
I2PServerTunnel (name, address, port, localDestination, inport, gzip), I2PServerTunnel (name, address, port, localDestination, inport, gzip),
m_Host (host) m_Host (host)
{ {
@ -883,8 +883,8 @@ namespace client
} }
I2PServerTunnelIRC::I2PServerTunnelIRC (const std::string& name, const std::string& address, I2PServerTunnelIRC::I2PServerTunnelIRC (const std::string& name, const std::string& address,
int port, std::shared_ptr<ClientDestination> localDestination, uint16_t port, std::shared_ptr<ClientDestination> localDestination,
const std::string& webircpass, int inport, bool gzip): const std::string& webircpass, uint16_t inport, bool gzip):
I2PServerTunnel (name, address, port, localDestination, inport, gzip), I2PServerTunnel (name, address, port, localDestination, inport, gzip),
m_WebircPass (webircpass) m_WebircPass (webircpass)
{ {

24
libi2pd_client/I2PTunnel.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2022, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -41,7 +41,7 @@ namespace client
public: public:
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket, I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
std::shared_ptr<const i2p::data::LeaseSet> leaseSet, int port = 0); // to I2P std::shared_ptr<const i2p::data::LeaseSet> leaseSet, uint16_t port = 0); // to I2P
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket, I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
std::shared_ptr<i2p::stream::Stream> stream); // to I2P using simplified API std::shared_ptr<i2p::stream::Stream> stream); // to I2P using simplified API
I2PTunnelConnection (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream, I2PTunnelConnection (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
@ -154,7 +154,7 @@ namespace client
public: public:
I2PClientTunnel (const std::string& name, const std::string& destination, I2PClientTunnel (const std::string& name, const std::string& destination,
const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination, int destinationPort = 0); const std::string& address, uint16_t port, std::shared_ptr<ClientDestination> localDestination, uint16_t destinationPort = 0);
~I2PClientTunnel () {} ~I2PClientTunnel () {}
void Start (); void Start ();
@ -174,7 +174,7 @@ namespace client
std::string m_Name, m_Destination; std::string m_Name, m_Destination;
std::shared_ptr<const Address> m_Address; std::shared_ptr<const Address> m_Address;
int m_DestinationPort; uint16_t m_DestinationPort;
uint32_t m_KeepAliveInterval; uint32_t m_KeepAliveInterval;
std::unique_ptr<boost::asio::deadline_timer> m_KeepAliveTimer; std::unique_ptr<boost::asio::deadline_timer> m_KeepAliveTimer;
}; };
@ -183,8 +183,8 @@ namespace client
{ {
public: public:
I2PServerTunnel (const std::string& name, const std::string& address, int port, I2PServerTunnel (const std::string& name, const std::string& address, uint16_t port,
std::shared_ptr<ClientDestination> localDestination, int inport = 0, bool gzip = true); std::shared_ptr<ClientDestination> localDestination, uint16_t inport = 0, bool gzip = true);
void Start (); void Start ();
void Stop (); void Stop ();
@ -200,7 +200,7 @@ namespace client
void SetLocalAddress (const std::string& localAddress); void SetLocalAddress (const std::string& localAddress);
const std::string& GetAddress() const { return m_Address; } const std::string& GetAddress() const { return m_Address; }
int GetPort () const { return m_Port; }; uint16_t GetPort () const { return m_Port; };
uint16_t GetLocalPort () const { return m_PortDestination->GetLocalPort (); }; uint16_t GetLocalPort () const { return m_PortDestination->GetLocalPort (); };
const boost::asio::ip::tcp::endpoint& GetEndpoint () const { return m_Endpoint; } const boost::asio::ip::tcp::endpoint& GetEndpoint () const { return m_Endpoint; }
@ -219,7 +219,7 @@ namespace client
bool m_IsUniqueLocal; bool m_IsUniqueLocal;
std::string m_Name, m_Address; std::string m_Name, m_Address;
int m_Port; uint16_t m_Port;
boost::asio::ip::tcp::endpoint m_Endpoint; boost::asio::ip::tcp::endpoint m_Endpoint;
std::shared_ptr<i2p::stream::StreamingDestination> m_PortDestination; std::shared_ptr<i2p::stream::StreamingDestination> m_PortDestination;
std::set<i2p::data::IdentHash> m_AccessList; std::set<i2p::data::IdentHash> m_AccessList;
@ -232,9 +232,9 @@ namespace client
{ {
public: public:
I2PServerTunnelHTTP (const std::string& name, const std::string& address, int port, I2PServerTunnelHTTP (const std::string& name, const std::string& address, uint16_t port,
std::shared_ptr<ClientDestination> localDestination, const std::string& host, std::shared_ptr<ClientDestination> localDestination, const std::string& host,
int inport = 0, bool gzip = true); uint16_t inport = 0, bool gzip = true);
private: private:
@ -249,9 +249,9 @@ namespace client
{ {
public: public:
I2PServerTunnelIRC (const std::string& name, const std::string& address, int port, I2PServerTunnelIRC (const std::string& name, const std::string& address, uint16_t port,
std::shared_ptr<ClientDestination> localDestination, const std::string& webircpass, std::shared_ptr<ClientDestination> localDestination, const std::string& webircpass,
int inport = 0, bool gzip = true); uint16_t inport = 0, bool gzip = true);
private: private:

4
libi2pd_client/SAM.cpp

@ -1217,7 +1217,7 @@ namespace client
subsessions.clear (); subsessions.clear ();
} }
SAMSubSession::SAMSubSession (std::shared_ptr<SAMMasterSession> master, const std::string& name, SAMSessionType type, int port): SAMSubSession::SAMSubSession (std::shared_ptr<SAMMasterSession> master, const std::string& name, SAMSessionType type, uint16_t port):
SAMSession (master->m_Bridge, name, type), masterSession (master), inPort (port) SAMSession (master->m_Bridge, name, type), masterSession (master), inPort (port)
{ {
if (Type == eSAMSessionTypeStream) if (Type == eSAMSessionTypeStream)
@ -1244,7 +1244,7 @@ namespace client
// TODO: implement datagrams // TODO: implement datagrams
} }
SAMBridge::SAMBridge (const std::string& address, int portTCP, int portUDP, bool singleThread): SAMBridge::SAMBridge (const std::string& address, uint16_t portTCP, uint16_t portUDP, bool singleThread):
RunnableService ("SAM"), m_IsSingleThread (singleThread), RunnableService ("SAM"), m_IsSingleThread (singleThread),
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), portTCP)), m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), portTCP)),
m_DatagramEndpoint (boost::asio::ip::address::from_string(address), (!portUDP) ? portTCP-1 : portUDP), m_DatagramSocket (GetIOService (), m_DatagramEndpoint), m_DatagramEndpoint (boost::asio::ip::address::from_string(address), (!portUDP) ? portTCP-1 : portUDP), m_DatagramSocket (GetIOService (), m_DatagramEndpoint),

6
libi2pd_client/SAM.h

@ -221,9 +221,9 @@ namespace client
struct SAMSubSession: public SAMSession struct SAMSubSession: public SAMSession
{ {
std::shared_ptr<SAMMasterSession> masterSession; std::shared_ptr<SAMMasterSession> masterSession;
int inPort; uint16_t inPort;
SAMSubSession (std::shared_ptr<SAMMasterSession> master, const std::string& name, SAMSessionType type, int port); SAMSubSession (std::shared_ptr<SAMMasterSession> master, const std::string& name, SAMSessionType type, uint16_t port);
// implements SAMSession // implements SAMSession
std::shared_ptr<ClientDestination> GetLocalDestination (); std::shared_ptr<ClientDestination> GetLocalDestination ();
void StopLocalDestination (); void StopLocalDestination ();
@ -233,7 +233,7 @@ namespace client
{ {
public: public:
SAMBridge (const std::string& address, int portTCP, int portUDP, bool singleThread); SAMBridge (const std::string& address, uint16_t portTCP, uint16_t portUDP, bool singleThread);
~SAMBridge (); ~SAMBridge ();
void Start (); void Start ();

2
libi2pd_client/SOCKS.cpp

@ -837,7 +837,7 @@ namespace proxy
shared_from_this(), std::placeholders::_1, std::placeholders::_2)); shared_from_this(), std::placeholders::_1, std::placeholders::_2));
} }
SOCKSServer::SOCKSServer(const std::string& name, const std::string& address, int port, SOCKSServer::SOCKSServer(const std::string& name, const std::string& address, uint16_t port,
bool outEnable, const std::string& outAddress, uint16_t outPort, bool outEnable, const std::string& outAddress, uint16_t outPort,
std::shared_ptr<i2p::client::ClientDestination> localDestination) : std::shared_ptr<i2p::client::ClientDestination> localDestination) :
TCPIPAcceptor (address, port, localDestination ? localDestination : i2p::client::context.GetSharedLocalDestination ()), m_Name (name) TCPIPAcceptor (address, port, localDestination ? localDestination : i2p::client::context.GetSharedLocalDestination ()), m_Name (name)

4
libi2pd_client/SOCKS.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2023, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -23,7 +23,7 @@ namespace proxy
{ {
public: public:
SOCKSServer(const std::string& name, const std::string& address, int port, bool outEnable, const std::string& outAddress, uint16_t outPort, SOCKSServer(const std::string& name, const std::string& address, uint16_t port, bool outEnable, const std::string& outAddress, uint16_t outPort,
std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr); std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr);
~SOCKSServer() {}; ~SOCKSServer() {};

Loading…
Cancel
Save