#ifdef HAVE_LIBSSH
case CParameterProxy::TYPE::SSHTunnel:
{
auto &ssh = m_pParameter->m_Proxy.m_SSH;
parameter->setServer(ssh.GetHost());
parameter->setPort(ssh.GetPort());
auto &user = ssh.m_User;
parameter->SetUser(user.GetUser());
parameter->SetUseSystemFile(user.GetUseSystemFile());
if(CParameterUser::TYPE::UserPassword == user.GetUsedType()) {
parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PASSWORD);
parameter->SetPassword(user.GetPassword());
}
if(CParameterUser::TYPE::PublicKey == user.GetUsedType()) {
parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PUBLICKEY);
parameter->SetPublicKeyFile(user.GetPublicKeyFile());
parameter->SetPrivateKeyFile(user.GetPrivateKeyFile());
parameter->SetPassphrase(user.GetPassphrase());
}
auto &net = m_pParameter->m_Net;
parameter->SetRemoteHost(net.GetHost());
parameter->SetRemotePort(net.GetPort());
if(!m_pThread)
if(!m_pThread)
return OnInitReturnValue::Fail;
bool check = connect(m_pThread, SIGNAL(
sigServer(QString, quint16)),
this, SLOT(slotConnectProxyServer(QString, quint16)));
Q_ASSERT(check);
#if defined(HAVE_UNIX_DOMAIN_SOCKET) && defined(Q_OS_UNIX)
check = connect(m_pThread, SIGNAL(
sigServer(QString)),
this, SLOT(slotConnectProxyServer(QString)));
Q_ASSERT(check);
#endif
check = connect(m_pThread, SIGNAL(sigError(int,QString)),
this, SIGNAL(sigError(int,QString)));
Q_ASSERT(check);
check = connect(m_pThread, SIGNAL(sigDisconnect()),
this, SIGNAL(sigDisconnect()));
Q_ASSERT(check);
m_pThread->start();
return OnInitReturnValue::UseOnProcess;
}
#endif
实现通过本地 SOCKET 与 SSH 隧道转发数据。适用于库没有实现传输层接口,只有 socket 的情况。
void sigServer(QString szHost, quint16 nPort)
当 SOCKET 服务建立监听后触发,用于通知其它本地 SOCKET 可以连接它