forked from qt-creator/qt-creator
SSH: Export information about the underlying TCP connection.
Change-Id: I62bce3b563b6aba481642fac0d427c0f0d3b2ddd Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -167,9 +167,12 @@ SshConnectionParameters SshConnection::connectionParameters() const
|
|||||||
return d->m_connParams;
|
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()
|
SshConnection::~SshConnection()
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtNetwork/QAbstractSocket>
|
#include <QtNetwork/QHostAddress>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class SftpChannel;
|
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);
|
||||||
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
|
class QTCREATOR_UTILS_EXPORT SshConnection : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -87,7 +100,7 @@ public:
|
|||||||
SshError errorState() const;
|
SshError errorState() const;
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
SshConnectionParameters connectionParameters() const;
|
SshConnectionParameters connectionParameters() const;
|
||||||
QAbstractSocket::NetworkLayerProtocol ipProtocolVersion() const;
|
SshConnectionInfo connectionInfo() const;
|
||||||
~SshConnection();
|
~SshConnection();
|
||||||
|
|
||||||
QSharedPointer<SshRemoteProcess> createRemoteProcess(const QByteArray &command);
|
QSharedPointer<SshRemoteProcess> createRemoteProcess(const QByteArray &command);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = RemoteLinux
|
TARGET = RemoteLinux
|
||||||
|
QT += network
|
||||||
|
|
||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
include(remotelinux_dependencies.pri)
|
include(remotelinux_dependencies.pri)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec
|
|||||||
SLOT(handleRemoteStdErr(QByteArray)));
|
SLOT(handleRemoteStdErr(QByteArray)));
|
||||||
QString procFilePath;
|
QString procFilePath;
|
||||||
int addressLength;
|
int addressLength;
|
||||||
if (connection->ipProtocolVersion() == QAbstractSocket::IPv4Protocol) {
|
if (connection->connectionInfo().localAddress.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
procFilePath = QLatin1String("/proc/net/tcp");
|
procFilePath = QLatin1String("/proc/net/tcp");
|
||||||
addressLength = 8;
|
addressLength = 8;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user