Commit 220f67df authored by Christian Kandeler's avatar Christian Kandeler Committed by hjk
Browse files

SSH: Export information about the underlying TCP connection.



Change-Id: I62bce3b563b6aba481642fac0d427c0f0d3b2ddd
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 17c18623
......@@ -167,9 +167,12 @@ SshConnectionParameters SshConnection::connectionParameters() const
return d->m_connParams;
}
QAbstractSocket::NetworkLayerProtocol SshConnection::ipProtocolVersion() const
SshConnectionInfo SshConnection::connectionInfo() const
{
return d->m_socket->localAddress().protocol();
QTC_ASSERT(state() == Connected, return SshConnectionInfo());
return SshConnectionInfo(d->m_socket->localAddress(), d->m_socket->localPort(),
d->m_socket->peerAddress(), d->m_socket->peerPort());
}
SshConnection::~SshConnection()
......
......@@ -41,7 +41,7 @@
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <QtNetwork/QAbstractSocket>
#include <QtNetwork/QHostAddress>
namespace Utils {
class SftpChannel;
......@@ -71,6 +71,19 @@ public:
QTCREATOR_UTILS_EXPORT bool operator==(const SshConnectionParameters &p1, const SshConnectionParameters &p2);
QTCREATOR_UTILS_EXPORT bool operator!=(const SshConnectionParameters &p1, const SshConnectionParameters &p2);
class QTCREATOR_UTILS_EXPORT SshConnectionInfo
{
public:
SshConnectionInfo() : localPort(0), peerPort(0) {}
SshConnectionInfo(const QHostAddress &la, quint16 lp, const QHostAddress &pa, quint16 pp)
: localAddress(la), localPort(lp), peerAddress(pa), peerPort(pp) {}
QHostAddress localAddress;
quint16 localPort;
QHostAddress peerAddress;
quint16 peerPort;
};
class QTCREATOR_UTILS_EXPORT SshConnection : public QObject
{
Q_OBJECT
......@@ -87,7 +100,7 @@ public:
SshError errorState() const;
QString errorString() const;
SshConnectionParameters connectionParameters() const;
QAbstractSocket::NetworkLayerProtocol ipProtocolVersion() const;
SshConnectionInfo connectionInfo() const;
~SshConnection();
QSharedPointer<SshRemoteProcess> createRemoteProcess(const QByteArray &command);
......
TEMPLATE = lib
TARGET = RemoteLinux
QT += network
include(../../qtcreatorplugin.pri)
include(remotelinux_dependencies.pri)
......
......@@ -86,7 +86,7 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec
SLOT(handleRemoteStdErr(QByteArray)));
QString procFilePath;
int addressLength;
if (connection->ipProtocolVersion() == QAbstractSocket::IPv4Protocol) {
if (connection->connectionInfo().localAddress.protocol() == QAbstractSocket::IPv4Protocol) {
procFilePath = QLatin1String("/proc/net/tcp");
addressLength = 8;
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment