I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0adc0121 authored by str4d's avatar str4d
Browse files

Remove SAM version range from API

The library should handle version negotiation, and fail gracefully if the user
asks the library to do something that the negotiated version doesn't allow.
parent a50d85ca
No related branches found
No related tags found
No related merge requests found
...@@ -52,8 +52,8 @@ void I2pSocket::freeWSA() ...@@ -52,8 +52,8 @@ void I2pSocket::freeWSA()
} }
#endif #endif
I2pSocket::I2pSocket(const std::string& SAMHost, uint16_t SAMPort, const std::string& minVer, const std::string &maxVer) I2pSocket::I2pSocket(const std::string& SAMHost, uint16_t SAMPort)
: socket_(INVALID_SOCKET), SAMHost_(SAMHost), SAMPort_(SAMPort), minVer_(minVer), maxVer_(maxVer) : socket_(INVALID_SOCKET), SAMHost_(SAMHost), SAMPort_(SAMPort)
{ {
#ifdef WIN32 #ifdef WIN32
if (instances_++ == 0) if (instances_++ == 0)
...@@ -68,8 +68,8 @@ I2pSocket::I2pSocket(const std::string& SAMHost, uint16_t SAMPort, const std::st ...@@ -68,8 +68,8 @@ I2pSocket::I2pSocket(const std::string& SAMHost, uint16_t SAMPort, const std::st
bootstrapI2P(); bootstrapI2P();
} }
I2pSocket::I2pSocket(const sockaddr_in& addr, const std::string &minVer, const std::string& maxVer) I2pSocket::I2pSocket(const sockaddr_in& addr)
: socket_(INVALID_SOCKET), servAddr_(addr), minVer_(minVer), maxVer_(maxVer) : socket_(INVALID_SOCKET), servAddr_(addr)
{ {
#ifdef WIN32 #ifdef WIN32
if (instances_++ == 0) if (instances_++ == 0)
...@@ -79,7 +79,7 @@ I2pSocket::I2pSocket(const sockaddr_in& addr, const std::string &minVer, const s ...@@ -79,7 +79,7 @@ I2pSocket::I2pSocket(const sockaddr_in& addr, const std::string &minVer, const s
} }
I2pSocket::I2pSocket(const I2pSocket& rhs) I2pSocket::I2pSocket(const I2pSocket& rhs)
: socket_(INVALID_SOCKET), servAddr_(rhs.servAddr_), minVer_(rhs.minVer_), maxVer_(rhs.maxVer_) : socket_(INVALID_SOCKET), servAddr_(rhs.servAddr_)
{ {
#ifdef WIN32 #ifdef WIN32
if (instances_++ == 0) if (instances_++ == 0)
...@@ -228,16 +228,6 @@ const std::string& I2pSocket::getVersion() const ...@@ -228,16 +228,6 @@ const std::string& I2pSocket::getVersion() const
return version_; return version_;
} }
const std::string& I2pSocket::getMinVer() const
{
return minVer_;
}
const std::string& I2pSocket::getMaxVer() const
{
return maxVer_;
}
const sockaddr_in& I2pSocket::getAddress() const const sockaddr_in& I2pSocket::getAddress() const
{ {
return servAddr_; return servAddr_;
...@@ -251,10 +241,8 @@ StreamSession::StreamSession( ...@@ -251,10 +241,8 @@ StreamSession::StreamSession(
const std::string& SAMHost /*= SAM_DEFAULT_ADDRESS*/, const std::string& SAMHost /*= SAM_DEFAULT_ADDRESS*/,
uint16_t SAMPort /*= SAM_DEFAULT_PORT*/, uint16_t SAMPort /*= SAM_DEFAULT_PORT*/,
const std::string& destination /*= SAM_GENERATE_MY_DESTINATION*/, const std::string& destination /*= SAM_GENERATE_MY_DESTINATION*/,
const std::string& i2pOptions /*= SAM_DEFAULT_I2P_OPTIONS*/, const std::string& i2pOptions /*= SAM_DEFAULT_I2P_OPTIONS*/)
const std::string& minVer /*= SAM_DEFAULT_MIN_VER*/, : socket_(SAMHost, SAMPort)
const std::string& maxVer /*= SAM_DEFAULT_MAX_VER*/)
: socket_(SAMHost, SAMPort, minVer, maxVer)
, nickname_(nickname) , nickname_(nickname)
, sessionID_(generateSessionID()) , sessionID_(generateSessionID())
, i2pOptions_(i2pOptions) , i2pOptions_(i2pOptions)
...@@ -607,22 +595,6 @@ uint16_t StreamSession::getSAMPort() const ...@@ -607,22 +595,6 @@ uint16_t StreamSession::getSAMPort() const
return socket_.getPort(); return socket_.getPort();
} }
const std::string& StreamSession::getSAMMinVer() const
{
#ifdef DEBUG_ON_STDOUT
std::cout << "getSAMMinVer: " << socket_.getMinVer() << std::endl;
#endif // DEBUG_ON_STDOUT
return socket_.getMinVer();
}
const std::string& StreamSession::getSAMMaxVer() const
{
#ifdef DEBUG_ON_STDOUT
std::cout << "getSAMMaxVer: " << socket_.getMaxVer() << std::endl;
#endif // DEBUG_ON_STDOUT
return socket_.getMaxVer();
}
const std::string& StreamSession::getSAMVersion() const const std::string& StreamSession::getSAMVersion() const
{ {
#ifdef DEBUG_ON_STDOUT #ifdef DEBUG_ON_STDOUT
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#define SAM_DEFAULT_ADDRESS "127.0.0.1" #define SAM_DEFAULT_ADDRESS "127.0.0.1"
#define SAM_DEFAULT_PORT 7656 #define SAM_DEFAULT_PORT 7656
#define SAM_DEFAULT_MIN_VER "3.0"
#define SAM_DEFAULT_MAX_VER "3.0"
#define SAM_GENERATE_MY_DESTINATION "TRANSIENT" #define SAM_GENERATE_MY_DESTINATION "TRANSIENT"
#define SAM_MY_NAME "ME" #define SAM_MY_NAME "ME"
#define SAM_DEFAULT_I2P_OPTIONS "" #define SAM_DEFAULT_I2P_OPTIONS ""
...@@ -201,8 +199,8 @@ private: ...@@ -201,8 +199,8 @@ private:
class I2pSocket class I2pSocket
{ {
public: public:
I2pSocket(const std::string& SAMHost, uint16_t SAMPort, const std::string &minVer, const std::string& maxVer); I2pSocket(const std::string& SAMHost, uint16_t SAMPort);
I2pSocket(const sockaddr_in& addr, const std::string& minVer, const std::string& maxVer); I2pSocket(const sockaddr_in& addr);
// explicit because we don't want to create any socket implicity // explicit because we don't want to create any socket implicity
explicit I2pSocket(const I2pSocket& rhs); // creates a new socket with the same parameters explicit I2pSocket(const I2pSocket& rhs); // creates a new socket with the same parameters
~I2pSocket(); ~I2pSocket();
...@@ -219,8 +217,6 @@ public: ...@@ -219,8 +217,6 @@ public:
const std::string& getVersion() const; const std::string& getVersion() const;
const std::string& getHost() const; const std::string& getHost() const;
uint16_t getPort() const; uint16_t getPort() const;
const std::string& getMinVer() const;
const std::string& getMaxVer() const;
const sockaddr_in& getAddress() const; const sockaddr_in& getAddress() const;
...@@ -229,8 +225,8 @@ private: ...@@ -229,8 +225,8 @@ private:
sockaddr_in servAddr_; sockaddr_in servAddr_;
std::string SAMHost_; std::string SAMHost_;
uint16_t SAMPort_; uint16_t SAMPort_;
const std::string minVer_; const std::string minVer_ = "3.0";
const std::string maxVer_; const std::string maxVer_ = "3.0";
std::string version_; std::string version_;
#ifdef WIN32 #ifdef WIN32
...@@ -332,9 +328,7 @@ public: ...@@ -332,9 +328,7 @@ public:
const std::string& SAMHost = SAM_DEFAULT_ADDRESS, const std::string& SAMHost = SAM_DEFAULT_ADDRESS,
uint16_t SAMPort = SAM_DEFAULT_PORT, uint16_t SAMPort = SAM_DEFAULT_PORT,
const std::string& destination = SAM_GENERATE_MY_DESTINATION, const std::string& destination = SAM_GENERATE_MY_DESTINATION,
const std::string& i2pOptions = SAM_DEFAULT_I2P_OPTIONS, const std::string& i2pOptions = SAM_DEFAULT_I2P_OPTIONS);
const std::string& minVer = SAM_DEFAULT_MIN_VER,
const std::string& maxVer = SAM_DEFAULT_MAX_VER);
explicit StreamSession(StreamSession& rhs); explicit StreamSession(StreamSession& rhs);
~StreamSession(); ~StreamSession();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment