2016-12-09 20:36:38 +00:00
|
|
|
#include "WebSocks.h"
|
|
|
|
#include "Log.h"
|
2016-12-13 14:10:39 +00:00
|
|
|
#include <string>
|
2016-12-09 20:36:38 +00:00
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
|
|
|
class WebSocksImpl
|
|
|
|
{
|
|
|
|
public:
|
2017-01-07 13:32:50 +00:00
|
|
|
WebSocksImpl(const std::string & addr, int port) : m_Addr(addr), m_Port(port)
|
2016-12-13 14:10:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~WebSocksImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-09 20:36:38 +00:00
|
|
|
void Start()
|
|
|
|
{
|
2020-02-27 11:58:06 +00:00
|
|
|
LogPrint(eLogInfo, "[Tunnels] starting websocks tunnel at %s:%d is rejected: WebSockets is deprecated", m_Addr, m_Port);
|
2016-12-09 20:36:38 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 14:10:39 +00:00
|
|
|
void Stop()
|
|
|
|
{
|
2017-01-07 13:32:50 +00:00
|
|
|
}
|
2016-12-13 14:10:39 +00:00
|
|
|
|
2017-01-07 13:32:50 +00:00
|
|
|
void InitializeDestination(WebSocks * parent)
|
|
|
|
{
|
2016-12-13 14:10:39 +00:00
|
|
|
}
|
|
|
|
|
2017-01-07 13:32:50 +00:00
|
|
|
boost::asio::ip::tcp::endpoint GetLocalEndpoint()
|
|
|
|
{
|
|
|
|
return boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(m_Addr), m_Port);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string m_Addr;
|
|
|
|
int m_Port;
|
|
|
|
|
2016-12-09 20:36:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
2017-01-07 13:32:50 +00:00
|
|
|
WebSocks::WebSocks(const std::string & addr, int port, std::shared_ptr<ClientDestination> localDestination) : m_Impl(new WebSocksImpl(addr, port))
|
|
|
|
{
|
|
|
|
m_Impl->InitializeDestination(this);
|
|
|
|
}
|
2016-12-09 20:36:38 +00:00
|
|
|
WebSocks::~WebSocks() { delete m_Impl; }
|
|
|
|
|
|
|
|
void WebSocks::Start()
|
|
|
|
{
|
|
|
|
m_Impl->Start();
|
2017-01-07 13:32:50 +00:00
|
|
|
GetLocalDestination()->Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::asio::ip::tcp::endpoint WebSocks::GetLocalEndpoint() const
|
|
|
|
{
|
|
|
|
return m_Impl->GetLocalEndpoint();
|
2016-12-09 20:36:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebSocks::Stop()
|
|
|
|
{
|
|
|
|
m_Impl->Stop();
|
2017-01-07 13:32:50 +00:00
|
|
|
GetLocalDestination()->Stop();
|
2016-12-09 20:36:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-07 13:32:50 +00:00
|
|
|
|