mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 13:14:13 +00:00
consmetic fixes
This commit is contained in:
parent
77c83c4f42
commit
a59e073536
28
WebSocks.cpp
28
WebSocks.cpp
@ -199,7 +199,6 @@ namespace client
|
|||||||
LogPrint(eLogDebug, "websocks: connected to ", m_RemoteAddr, ":", m_RemotePort);
|
LogPrint(eLogDebug, "websocks: connected to ", m_RemoteAddr, ":", m_RemotePort);
|
||||||
SendResponse("");
|
SendResponse("");
|
||||||
m_State = eWSCOkayConnect;
|
m_State = eWSCOkayConnect;
|
||||||
StartForwarding();
|
|
||||||
} else if(state == eWSCFailConnect) {
|
} else if(state == eWSCFailConnect) {
|
||||||
// we did not connect okay
|
// we did not connect okay
|
||||||
LogPrint(eLogDebug, "websocks: failed to connect to ", m_RemoteAddr, ":", m_RemotePort);
|
LogPrint(eLogDebug, "websocks: failed to connect to ", m_RemoteAddr, ":", m_RemotePort);
|
||||||
@ -252,6 +251,8 @@ namespace client
|
|||||||
void StartForwarding()
|
void StartForwarding()
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "websocks: begin forwarding data");
|
LogPrint(eLogDebug, "websocks: begin forwarding data");
|
||||||
|
uint8_t b[1];
|
||||||
|
m_Stream->Send(b, 0);
|
||||||
AsyncRecv();
|
AsyncRecv();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,15 +265,17 @@ namespace client
|
|||||||
} else {
|
} else {
|
||||||
// forward data
|
// forward data
|
||||||
LogPrint(eLogDebug, "websocks recv ", n);
|
LogPrint(eLogDebug, "websocks recv ", n);
|
||||||
std::string str((char*)m_RecvBuf, n);
|
|
||||||
auto conn = m_Parent->GetConn(m_Conn);
|
std::string str((char*)m_RecvBuf, n);
|
||||||
if(!conn) {
|
auto conn = m_Parent->GetConn(m_Conn);
|
||||||
LogPrint(eLogWarning, "websocks: connection is gone");
|
if(!conn) {
|
||||||
EnterState(eWSCClose);
|
LogPrint(eLogWarning, "websocks: connection is gone");
|
||||||
return;
|
EnterState(eWSCClose);
|
||||||
}
|
return;
|
||||||
conn->send(str);
|
}
|
||||||
AsyncRecv();
|
conn->send(str);
|
||||||
|
AsyncRecv();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +283,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
m_Stream->AsyncReceive(
|
m_Stream->AsyncReceive(
|
||||||
boost::asio::buffer(m_RecvBuf, sizeof(m_RecvBuf)),
|
boost::asio::buffer(m_RecvBuf, sizeof(m_RecvBuf)),
|
||||||
std::bind(&WebSocksConn::HandleAsyncRecv, this, std::placeholders::_1, std::placeholders::_2));
|
std::bind(&WebSocksConn::HandleAsyncRecv, this, std::placeholders::_1, std::placeholders::_2), 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief send error message or empty string for success */
|
/** @brief send error message or empty string for success */
|
||||||
@ -310,6 +313,7 @@ namespace client
|
|||||||
if(m_Stream) {
|
if(m_Stream) {
|
||||||
// connect good
|
// connect good
|
||||||
EnterState(eWSCOkayConnect);
|
EnterState(eWSCOkayConnect);
|
||||||
|
StartForwarding();
|
||||||
} else {
|
} else {
|
||||||
// connect failed
|
// connect failed
|
||||||
EnterState(eWSCFailConnect);
|
EnterState(eWSCFailConnect);
|
||||||
@ -323,7 +327,7 @@ namespace client
|
|||||||
if(m_State == eWSCOkayConnect)
|
if(m_State == eWSCOkayConnect)
|
||||||
{
|
{
|
||||||
// forward to server
|
// forward to server
|
||||||
LogPrint(eLogDebug, "websocks: send ", payload.size());
|
LogPrint(eLogDebug, "websocks: forward ", payload.size());
|
||||||
m_Stream->Send((uint8_t*)payload.c_str(), payload.size());
|
m_Stream->Send((uint8_t*)payload.c_str(), payload.size());
|
||||||
} else if (m_State == eWSCInitial) {
|
} else if (m_State == eWSCInitial) {
|
||||||
// recv connect request
|
// recv connect request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user