Recent

Author Topic: Accessing the MySQL database of the intranet host through libssh2  (Read 861 times)

myisjwj

  • Full Member
  • ***
  • Posts: 104
I have connected to the remote external host using Libssh2, and now I want to map the port of the internal host to 127.0.0.1. The code is as follows:

Code: Pascal  [Select][+][-]
  1.     localPort := 33069;
  2.     tunnelSock := fpSocket(AF_INET, SOCK_STREAM, 0);
  3.     FillChar(tunnelAddr, SizeOf(tunnelAddr), 0);
  4.     tunnelAddr.sin_family := AF_INET;
  5.     tunnelAddr.sin_port := htons(localPort);
  6.     tunnelAddr.sin_addr.S_addr := INADDR_ANY;
  7.     rc := fpBind(tunnelSock, @tunnelAddr, SizeOf(tunnelAddr));
  8.     rc := fpListen(tunnelSock, 1);
  9.     channel1:=libssh2_channel_direct_tcpip_ex(session1, '192.168.0.77', 3306, '127.0.0.1', localPort);

But now MySQL cannot connect to the intranet host. The error is: MySQL waiting for initial communication packet.

Code: Pascal  [Select][+][-]
  1.     rc := fpBind(tunnelSock, @tunnelAddr, SizeOf(tunnelAddr));
  2.     rc := fpListen(tunnelSock, 1);
  3.     channel1:=libssh2_channel_direct_tcpip_ex(session1, '192.168.0.77', 3306, '127.0.0.1', localPort);

All return to normal.

 

TinyPortal © 2005-2018