File Information
Library: WebTunnel
Package: WebTunnel
Header: Poco/WebTunnel/RemotePortForwarder.h
Description
This class forwards one or more ports to a remote host, using a shared web socket for tunneling the data.
Member Summary
Member Functions: closeWebSocket, demultiplex, demultiplexError, demultiplexTimeout, forwardData, getConnectTimeout, getLocalTimeout, multiplex, multiplexError, multiplexTimeout, openChannel, pingWebSocket, remoteTimeout, removeChannel, sendResponse, setConnectTimeout, setLocalTimeout, stop, updateProperties
Enumerations
CloseReason
Graceful shutdown, initiated by peer.
Unexpected shutdown by peer.
RPF_CLOSE_ERROR = 2
Close due to socket exception.
Close due to timeout.
Constructors
RemotePortForwarder
RemotePortForwarder(
SocketDispatcher & dispatcher,
Poco::SharedPtr < Poco::Net::WebSocket > pWebSocket,
const Poco::Net::IPAddress & host,
const std::set < Poco::UInt16 > & ports,
Poco::Timespan remoteTimeout = Poco::Timespan (300, 0),
SocketFactory::Ptr pSocketFactory = new SocketFactory
);
Creates the RemotePortForwarder, using the given socket dispatcher and web socket, which is used for tunneling data. Only the port numbers given in ports will be forwarded. The web socket must have already been connected to the reflector server.
Destructor
~RemotePortForwarder
Destroys the RemotePortForwarder and closes the web socket connection.
Member Functions
getConnectTimeout
const Poco::Timespan & getConnectTimeout() const;
Returns the timeout for connecting to local ports.
getLocalTimeout
const Poco::Timespan & getLocalTimeout() const;
Returns the timeout for the forwarded local ports.
remoteTimeout
const Poco::Timespan & remoteTimeout() const;
Returns the timeout for the remote connection.
setConnectTimeout
void setConnectTimeout(
const Poco::Timespan & timeout
);
Sets the timeout for connecting to local ports.
setLocalTimeout
void setLocalTimeout(
const Poco::Timespan & timeout
);
Sets the timeout for the forwarded local ports.
stop
void stop();
Stops the RemotePortForwarder.
updateProperties
void updateProperties(
const std::map < std::string, std::string > & props
);
Transmits properties (key-value pairs) to the remote peer.
closeWebSocket
void closeWebSocket(
CloseReason reason,
bool active
);
demultiplex
bool demultiplex(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::Buffer < char > & buffer
);
demultiplexError
void demultiplexError(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::Buffer < char > & buffer
);
demultiplexTimeout
void demultiplexTimeout(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::Buffer < char > & buffer
);
forwardData
bool forwardData(
const char * buffer,
int size,
Poco::UInt16 channel
);
multiplex
bool multiplex(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::UInt16 channel,
Poco::Buffer < char > & buffer
);
multiplexError
void multiplexError(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::UInt16 channel,
Poco::Buffer < char > & buffer
);
multiplexTimeout
void multiplexTimeout(
SocketDispatcher & dispatcher,
Poco::Net::StreamSocket & socket,
Poco::UInt16 channel,
Poco::Buffer < char > & buffer
);
openChannel
bool openChannel(
Poco::UInt16 channel,
Poco::UInt16 port
);
pingWebSocket
void pingWebSocket();
removeChannel
void removeChannel(
Poco::UInt16 channel
);
sendResponse
void sendResponse(
Poco::UInt16 channel,
Poco::UInt8 opcode,
Poco::UInt16 errorCode
);
Variables
webSocketClosed
Poco::BasicEvent < const int > webSocketClosed;
Fired when the web socket has been closed.
The event argument will indicate the reason for the close. See the CloseReason enum for values and their meanings.