Skip to content

Commit

Permalink
fix(WebTunnel): fix RemotePortForwarder channel close bug (shutting d…
Browse files Browse the repository at this point in the history
…own WebSocket instead of StreamSocket)
  • Loading branch information
obiltschnig committed Nov 22, 2024
1 parent 6a550bd commit 6c7fd8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions WebTunnel/include/Poco/WebTunnel/RemotePortForwarder.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class WebTunnel_API RemotePortForwarder
void connectTimeout(SocketDispatcher& dispatcher, Poco::Net::StreamSocket& socket, Poco::UInt16 channel);
void forwardData(const char* buffer, int size, Poco::UInt16 channel);
void openChannel(Poco::UInt16 channel, Poco::UInt16 port);
void shutdownSendChannel(Poco::UInt16 channel);
void removeChannel(Poco::UInt16 channel);
void sendResponse(Poco::UInt16 channel, Poco::UInt8 opcode, Poco::UInt16 errorCode);
void closeWebSocket(CloseReason reason, bool active);
Expand Down
13 changes: 12 additions & 1 deletion WebTunnel/src/RemotePortForwarder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void RemotePortForwarder::demultiplex(SocketDispatcher& dispatcher, Poco::Net::S
}
else
{
_dispatcher.shutdownSend(socket);
shutdownSendChannel(channel);
}
break;

Expand Down Expand Up @@ -490,6 +490,17 @@ void RemotePortForwarder::openChannel(Poco::UInt16 channel, Poco::UInt16 port)
}


void RemotePortForwarder::shutdownSendChannel(Poco::UInt16 channel)
{
Poco::FastMutex::ScopedLock lock(_mutex);
ChannelMap::iterator it = _channelMap.find(channel);
if (it != _channelMap.end())
{
_dispatcher.shutdownSend(it->second.socket);
}
}


void RemotePortForwarder::removeChannel(Poco::UInt16 channel)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Expand Down

0 comments on commit 6c7fd8d

Please sign in to comment.