Commit 22861e22 authored by Luke Dashjr's avatar Luke Dashjr
Browse files

VncSshTunnelThread: Support specifying port 0 to get an ephemeral port

parent ab2a1a3a
......@@ -35,6 +35,11 @@ VncSshTunnelThread::~VncSshTunnelThread()
}
int VncSshTunnelThread::tunnelPort() const
{
return m_tunnelPort;
}
QString VncSshTunnelThread::password() const
{
return m_password;
......@@ -146,6 +151,15 @@ void VncSshTunnelThread::run()
Q_EMIT errorMessage(i18n("Error creating tunnel socket"));
return;
}
if (m_tunnelPort == 0) {
socklen_t sin_len = sizeof sin;
if (getsockname(server_sock, (struct sockaddr *)&sin, &sin_len) == -1) {
Q_EMIT errorMessage(i18n("Error creating tunnel socket"));
return;
}
m_tunnelPort = ntohs(sin.sin_port);
}
}
if (listen(server_sock, 1) == -1) {
......
......@@ -34,6 +34,8 @@ public:
IgnoreWallet
};
int tunnelPort() const;
QString password() const;
void setPassword(const QString &password, PasswordOrigin origin);
void userCanceledPasswordRequest();
......
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