Skip to content

Commit

Permalink
use string literals; update copyright year
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Jan 30, 2023
1 parent 3cd1998 commit 79ebd74
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 70 deletions.
8 changes: 4 additions & 4 deletions WebTunnel/WebTunnelAgent/src/WebTunnelAgent.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelAgent.cpp
//
// Copyright (c) 2013-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2013-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -231,7 +231,7 @@ class WebTunnelAgent: public Poco::Util::ServerApplication
helpFormatter.setUsage("OPTIONS"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE Device Agent.\n"
"Copyright (c) 2013-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2013-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to forward local TCP ports to remote\n"
"clients via the macchina.io REMOTE.\n\n"
Expand Down Expand Up @@ -570,7 +570,7 @@ class WebTunnelAgent: public Poco::Util::ServerApplication
if (!_stopped.tryWait(1))
{
Poco::Clock::ClockDiff retryDelay(static_cast<Poco::Clock::ClockDiff>(_retryDelay)*1000);
retryDelay += _random.next(250*_retryDelay);
retryDelay += _random.next(500*_retryDelay);
Poco::Clock nextClock;
nextClock += retryDelay;
logger().information(Poco::format("Will reconnect in %.2f seconds."s, retryDelay/1000000.0));
Expand Down Expand Up @@ -964,7 +964,7 @@ class WebTunnelAgent: public Poco::Util::ServerApplication

const std::string WebTunnelAgent::SEC_WEBSOCKET_PROTOCOL("Sec-WebSocket-Protocol");
const std::string WebTunnelAgent::WEBTUNNEL_PROTOCOL("com.appinf.webtunnel.server/1.0");
const std::string WebTunnelAgent::WEBTUNNEL_AGENT("WebTunnelAgent/1.14.1");
const std::string WebTunnelAgent::WEBTUNNEL_AGENT("WebTunnelAgent/1.15.0");


POCO_SERVER_MAIN(WebTunnelAgent)
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelClient/src/WebTunnelClient.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelClient.cpp
//
// Copyright (c) 2013-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2013-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -256,7 +256,7 @@ class WebTunnelClient: public Poco::Util::ServerApplication
helpFormatter.setUsage("OPTIONS <Remote-URI>"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE Client.\n"
"Copyright (c) 2013-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2013-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to forward a remote TCP port to the local\n"
"host via the macchina.io REMOTE server.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelRDP/src/WebTunnelRDP.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelRDP.cpp
//
// Copyright (c) 2015-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2015-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -214,7 +214,7 @@ class WebTunnelRDP: public Poco::Util::Application
helpFormatter.setUsage("OPTIONS <Remote-URI> [-- RDP-OPTIONS]"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE RDP Client.\n"
"Copyright (c) 2019-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2019-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to launch a Remote Desktop connection to a remote\n"
"host via the macchina.io REMOTE server.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelSCP/src/WebTunnelSCP.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelSCP.cpp
//
// Copyright (c) 2014-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2014-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -214,7 +214,7 @@ class WebTunnelSCP: public Poco::Util::Application
helpFormatter.setUsage("OPTIONS [-- SCP-OPTIONS] <source...> <target>"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE SCP Client.\n"
"Copyright (c) 2021-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2021-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to launch a SCP (Secure/SSH File Copy)\n"
"connection to a remote host via the macchina.io REMOTE server.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelSFTP/src/WebTunnelSFTP.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelSFTP.cpp
//
// Copyright (c) 2014-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2014-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -226,7 +226,7 @@ class WebTunnelSFTP: public Poco::Util::Application
helpFormatter.setUsage("OPTIONS <Remote-URI> [-- SFTP-OPTIONS]"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE SFTP Client.\n"
"Copyright (c) 2021-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2021-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to launch a SFTP (Secure/SSH File Transfer Protocol)\n"
"connection to a remote host via the macchina.io REMOTE server.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelSSH/src/WebTunnelSSH.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelSSH.cpp
//
// Copyright (c) 2014-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2014-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -253,7 +253,7 @@ class WebTunnelSSH: public Poco::Util::Application
helpFormatter.setUsage("OPTIONS <Remote-URI> [-- SSH-OPTIONS]"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE SSH Client.\n"
"Copyright (c) 2014-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2014-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to launch a SSH connection to a remote\n"
"host via the macchina.io REMOTE server.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions WebTunnel/WebTunnelVNC/src/WebTunnelVNC.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// WebTunnelVNC.cpp
//
// Copyright (c) 2015-2022, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2015-2023, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -195,7 +195,7 @@ class WebTunnelVNC: public Poco::Util::Application
helpFormatter.setUsage("OPTIONS <Remote-URI> [-- VNC-OPTIONS]"s);
helpFormatter.setHeader("\n"
"macchina.io REMOTE VNC Client.\n"
"Copyright (c) 2015-2022 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2015-2023 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This application is used to launch a VNC connection to a remote\n"
"host via the macchina.io REMOTE server.\n\n"
Expand Down
47 changes: 25 additions & 22 deletions WebTunnel/src/LocalPortForwarder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "Poco/Buffer.h"


using namespace std::string_literals;


namespace Poco {
namespace WebTunnel {

Expand Down Expand Up @@ -164,7 +167,7 @@ class BasicSocketForwarder: public SocketDispatcher::SocketHandler
}
catch (Poco::Exception& exc)
{
logger.warning("Error shutting down WebSocket: %s", exc.displayText());
logger.warning("Error shutting down WebSocket: %s"s, exc.displayText());
}
}

Expand All @@ -186,7 +189,7 @@ class StreamSocketToWebSocketForwarder: public BasicSocketForwarder
StreamSocketToWebSocketForwarder(Poco::SharedPtr<SocketDispatcher> pDispatcher, Poco::SharedPtr<Poco::Net::WebSocket> pWebSocket):
BasicSocketForwarder(pDispatcher),
_pWebSocket(pWebSocket),
_logger(Poco::Logger::get("WebTunnel.StreamSocketToWebSocketForwarder"))
_logger(Poco::Logger::get("WebTunnel.StreamSocketToWebSocketForwarder"s))
{
}

Expand All @@ -199,14 +202,14 @@ class StreamSocketToWebSocketForwarder: public BasicSocketForwarder
}
catch (Poco::Net::ConnectionResetException& exc)
{
_logger.debug("Exception while receiving data from local socket: " + exc.displayText());
_logger.debug("Exception while receiving data from local socket: %s"s, exc.displayText());
shutdown(*_pWebSocket, Poco::Net::WebSocket::WS_UNEXPECTED_CONDITION, _logger);
cleanupDispatcher(socket, *_pWebSocket);
return false;
}
catch (Poco::Exception& exc)
{
_logger.error("Exception while receiving data from local socket: " + exc.displayText());
_logger.error("Exception while receiving data from local socket: %s"s, exc.displayText());
shutdown(*_pWebSocket, Poco::Net::WebSocket::WS_UNEXPECTED_CONDITION, _logger);
cleanupDispatcher(socket, *_pWebSocket);
return false;
Expand All @@ -220,13 +223,13 @@ class StreamSocketToWebSocketForwarder: public BasicSocketForwarder
}
catch (Poco::Exception& exc)
{
_logger.error("Exception while sending data: " + exc.displayText());
_logger.error("Exception while sending data: %s"s, exc.displayText());
cleanupDispatcher(socket, *_pWebSocket);
}
}
else
{
_logger.debug("Closing connection");
_logger.debug("Closing connection"s);
shutdown(*_pWebSocket, Poco::Net::WebSocket::WS_NORMAL_CLOSE, _logger);
cleanupDispatcher(socket, *_pWebSocket);
}
Expand Down Expand Up @@ -263,7 +266,7 @@ class WebSocketToStreamSocketForwarder: public BasicSocketForwarder
BasicSocketForwarder(pDispatcher),
_streamSocket(streamSocket),
_timeoutCount(0),
_logger(Poco::Logger::get("WebTunnel.WebSocketToStreamSocketForwarder"))
_logger(Poco::Logger::get("WebTunnel.WebSocketToStreamSocketForwarder"s))
{
}

Expand All @@ -278,19 +281,19 @@ class WebSocketToStreamSocketForwarder: public BasicSocketForwarder
}
catch (Poco::Net::ConnectionResetException& exc)
{
_logger.debug("Exception while receiving data from remote socket: " + exc.displayText());
_logger.debug("Exception while receiving data from remote socket: %s"s, exc.displayText());
cleanupDispatcher(socket, _streamSocket);
return false;
}
catch (Poco::Exception& exc)
{
_logger.error("Exception while receiving data from remote socket: " + exc.displayText());
_logger.error("Exception while receiving data from remote socket: %s"s, exc.displayText());
cleanupDispatcher(socket, _streamSocket);
return false;
}
if ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_PONG)
{
_logger.debug("PONG received");
_logger.debug("PONG received"s);
_timeoutCount = 0;
return false;
}
Expand All @@ -303,21 +306,21 @@ class WebSocketToStreamSocketForwarder: public BasicSocketForwarder
}
catch (Poco::Exception& exc)
{
_logger.error("Exception while sending data: " + exc.displayText());
_logger.error("Exception while sending data: %s"s, exc.displayText());
cleanupDispatcher(socket, _streamSocket);
shutdown(webSocket, Poco::Net::WebSocket::WS_UNEXPECTED_CONDITION, _logger);
return false;
}
}
else if (n <= 0 || (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE)
{
_logger.debug("Shutting down WebSocket");
_logger.debug("Shutting down WebSocket"s);
cleanupDispatcher(socket, _streamSocket);
_streamSocket.shutdown();
}
else
{
_logger.debug("Ignoring unsupported frame type");
_logger.debug("Ignoring unsupported frame type"s);
}
return false;
}
Expand All @@ -329,13 +332,13 @@ class WebSocketToStreamSocketForwarder: public BasicSocketForwarder

void timeout(SocketDispatcher& dispatcher, Poco::Net::StreamSocket& socket)
{
_logger.debug("Timeout reading from WebSocket");
_logger.debug("Timeout reading from WebSocket"s);
if (_timeoutCount == 0)
{
_timeoutCount = 1;
try
{
_logger.debug("Sending PING");
_logger.debug("Sending PING"s);
Poco::Net::WebSocket webSocket(socket);
webSocket.sendFrame(0, 0, Poco::Net::WebSocket::FRAME_FLAG_FIN | Poco::Net::WebSocket::FRAME_OP_PING);
}
Expand Down Expand Up @@ -368,15 +371,15 @@ const std::string LocalPortForwarder::WEBTUNNEL_PROTOCOL("com.appinf.webtunnel.c


LocalPortForwarder::LocalPortForwarder(Poco::UInt16 localPort, Poco::UInt16 remotePort, const Poco::URI& remoteURI, WebSocketFactory::Ptr pWebSocketFactory):
_localAddr("localhost", localPort),
_localAddr("localhost"s, localPort),
_remotePort(remotePort),
_remoteURI(remoteURI),
_localTimeout(0),
_remoteTimeout(300, 0),
_pWebSocketFactory(pWebSocketFactory),
_serverSocket(_localAddr),
_tcpServer(new LocalPortForwarderConnectionFactory(*this), _serverSocket),
_logger(Poco::Logger::get("WebTunnel.LocalPortForwarder"))
_logger(Poco::Logger::get("WebTunnel.LocalPortForwarder"s))
{
_localAddr = _serverSocket.address();
_tcpServer.start();
Expand All @@ -394,7 +397,7 @@ LocalPortForwarder::LocalPortForwarder(const Poco::Net::SocketAddress& localAddr
_serverSocket(_localAddr),
_tcpServer(new LocalPortForwarderConnectionFactory(*this), _serverSocket, pServerParams),
_pDispatcher(new SocketDispatcher(16)),
_logger(Poco::Logger::get("WebTunnel.LocalPortForwarder"))
_logger(Poco::Logger::get("WebTunnel.LocalPortForwarder"s))
{
_localAddr = _serverSocket.address();
_tcpServer.start();
Expand Down Expand Up @@ -432,7 +435,7 @@ void LocalPortForwarder::forward(Poco::Net::StreamSocket& socket)
{
if (_logger.debug())
{
_logger.debug("Local connection accepted, creating forwarding connection to %s, remote port %hu", _remoteURI.toString(), _remotePort);
_logger.debug("Local connection accepted, creating forwarding connection to %s, remote port %hu."s, _remoteURI.toString(), _remotePort);
}
try
{
Expand All @@ -443,9 +446,9 @@ void LocalPortForwarder::forward(Poco::Net::StreamSocket& socket)
request.set(X_WEBTUNNEL_REMOTEPORT, Poco::NumberFormatter::format(_remotePort));
Poco::Net::HTTPResponse response;
Poco::SharedPtr<Poco::Net::WebSocket> pWebSocket = _pWebSocketFactory->createWebSocket(_remoteURI, request, response);
if (response.get(SEC_WEBSOCKET_PROTOCOL, "") != WEBTUNNEL_PROTOCOL)
if (response.get(SEC_WEBSOCKET_PROTOCOL, ""s) != WEBTUNNEL_PROTOCOL)
{
_logger.error("The remote host does not support the WebTunnel protocol.");
_logger.error("The remote host does not support the WebTunnel protocol."s);
pWebSocket->shutdown(Poco::Net::WebSocket::WS_PROTOCOL_ERROR);
pWebSocket->close();
socket.close();
Expand All @@ -460,7 +463,7 @@ void LocalPortForwarder::forward(Poco::Net::StreamSocket& socket)
}
catch (Poco::Exception& exc)
{
_logger.error("Failed to open forwarding connection: %s", exc.displayText());
_logger.error("Failed to open forwarding connection: %s"s, exc.displayText());
socket.close();
}
}
Expand Down
Loading

0 comments on commit 79ebd74

Please sign in to comment.