| 3812 | // Create an SSH tunnel on the port specified by the server for the passive data connection |
| 3813 | int error = 0; |
| 3814 | static int tunnelPID = 0; |
| 3815 | if( m_pSocket->GetRemotePort(error) == 2121 ) // I use this port only for SSH tunneling |
| 3816 | { |
| 3817 | if ( tunnelPID ) |
| 3818 | { |
| 3819 | kill( tunnelPID, 15 ); // SIGTERM (include signal.h) |
| 3820 | waitpid( tunnelPID, &error, 0 ); // (include sys/wait.h) |
| 3821 | } |
| 3822 | wxString portFw = wxString::Format("%d:%s:%d", pData->port, pData->host.c_str(), pData->port); |
| 3823 | if ( !( tunnelPID = fork() ) ) |
| 3824 | execlp("ssh", "ssh", "-L", portFw.c_str(), "myuser@myproxyserver.fr", "-N", "-n", NULL); |
| 3825 | pData->host = peerIP; // Connect to localhost (SSH tunnel), not to the specified IP |
| 3826 | sleep(4); // myproxyserver is somewhat slow to create the tunnel |
| 3827 | } |
| 3828 | |