Get client IP in OnClientError of SSHserver component

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
tcaduto12068
Posts: 132
Joined: Wed 17 Aug 2016 05:57

Get client IP in OnClientError of SSHserver component

Post by tcaduto12068 » Fri 14 Jul 2017 19:01

Hi,
How do you get the clients IP and port in the Onclienterror event in the sshserver component?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Get client IP in OnClientError of SSHserver component

Post by ViktorV » Mon 17 Jul 2017 13:55

To solve the issue try to use the following code:

Code: Select all

procedure TSSHServerFrame.ScSSHServerClientError(Sender: TObject;
  ClientInfo: TScSSHClientInfo; E: Exception);
var
  IP, Port: string;
  Sock: TIPEndPoint;
begin
  Sock := TIPEndPoint.Create(PSockAddrIn(ClientInfo.SockAddr));
  try
    IP := Sock.ToString;
    Port := IntToStr(Sock.Port)
  finally
    Sock.Free;
  end;
end;

Post Reply