mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Raise connection error when local SSH port for plink is already in use. See http://www.heidisql.com/forum.php?t=18395
This commit is contained in:
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: HeidiSQL\n"
|
||||
"POT-Creation-Date: 2012-11-05 21:40\n"
|
||||
"PO-Revision-Date: 2015-04-26 15:27+0100\n"
|
||||
"PO-Revision-Date: 2015-05-11 19:49+0100\n"
|
||||
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
|
||||
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
|
||||
"language/en/)\n"
|
||||
@ -3962,6 +3962,10 @@ msgstr "PLink exited unexpected. Command line was: %s"
|
||||
msgid "Could not execute PLink: %s"
|
||||
msgstr "Could not execute PLink: %s"
|
||||
|
||||
#. Plink connection
|
||||
msgid "Could not execute PLink: Port %d already in use."
|
||||
msgstr "Could not execute PLink: Port %d already in use."
|
||||
|
||||
msgid ""
|
||||
"Connection closed immediately after it was established. This is mostly "
|
||||
"caused by an \"%s\" server variable which has errors in itself, or your user "
|
||||
|
@ -818,6 +818,10 @@ var
|
||||
ExitCode: LongWord;
|
||||
Waited, ReturnedSomethingAt: Integer;
|
||||
begin
|
||||
// Check if local port is open
|
||||
if not PortOpen(FConnection.Parameters.SSHLocalPort) then
|
||||
raise EDatabaseError.CreateFmt(_('Could not execute PLink: Port %d already in use.'), [FConnection.Parameters.SSHLocalPort]);
|
||||
|
||||
// Build plink.exe command line
|
||||
// plink bob@domain.com -pw myPassw0rd1 -P 22 -i "keyfile.pem" -L 55555:localhost:3306
|
||||
PlinkParameters := '-ssh ';
|
||||
|
@ -13,7 +13,7 @@ uses
|
||||
Windows, ShlObj, ActiveX, VirtualTrees, SynRegExpr, Messages, Math,
|
||||
Registry, DateUtils, Generics.Collections, StrUtils, AnsiStrings, TlHelp32, Types,
|
||||
dbconnection, mysql_structures, SynMemo, Menus, WinInet, gnugettext, Themes,
|
||||
Character, ImgList, System.UITypes, ActnList;
|
||||
Character, ImgList, System.UITypes, ActnList, WinSock;
|
||||
|
||||
type
|
||||
|
||||
@ -325,6 +325,7 @@ type
|
||||
function GetSystemImageIndex(Filename: String): Integer;
|
||||
function GetExecutableBits: Byte;
|
||||
procedure Help(Sender: TObject; Anchor: String);
|
||||
function PortOpen(Port: Word): Boolean;
|
||||
|
||||
|
||||
var
|
||||
@ -2690,6 +2691,29 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function PortOpen(Port: Word): Boolean;
|
||||
var
|
||||
client: sockaddr_in;
|
||||
sock: Integer;
|
||||
ret: Integer;
|
||||
wsdata: WSAData;
|
||||
begin
|
||||
Result := True;
|
||||
ret := WSAStartup($0002, wsdata);
|
||||
if ret<>0 then
|
||||
Exit;
|
||||
try
|
||||
client.sin_family := AF_INET;
|
||||
client.sin_port := htons(Port);
|
||||
client.sin_addr.s_addr := inet_addr(PAnsiChar('127.0.0.1'));
|
||||
sock := socket(AF_INET, SOCK_STREAM, 0);
|
||||
Result := connect(sock, client, SizeOf(client)) <> 0;
|
||||
finally
|
||||
WSACleanup;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
{ Threading stuff }
|
||||
|
Reference in New Issue
Block a user