⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbindysshclientiohandler9.pas

📁 著名的SecureBlackBox控件完整源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  FreeAndNil(FTunnelList);

  inherited;
end;

procedure TElClientIndySSHTransport.Disconnect;
begin
  if FActive then
  begin
    try
      FActive := false;
      if FSSHClient.Active then
        FSSHClient.Close(not FErrorOccured);
      while FSSHClient.Active do
        FSSHClient.DataAvailable;
      FErrorOccured := false;
      FLastError := 0;

      FTCPClient.Disconnect;
    finally
    end;
  end;
end;

procedure TElClientIndySSHTransport.DoSSHAuthenticationFailed(
  Sender: TObject; AuthenticationType: integer);
begin
  if Assigned(FOnAuthenticationFailed) then
    FOnAuthenticationFailed(Self, AuthenticationType);
end;

procedure TElClientIndySSHTransport.DoSSHAuthenticationKeyboard(
  Sender: TObject; Prompts: TStringList; Echo: TBits;
  Responses: TStringList);
begin
  if Assigned(FOnAuthenticationKeyboard) then
    FOnAuthenticationKeyboard(Self, Prompts, Echo, Responses);
end;

procedure TElClientIndySSHTransport.DoSSHAuthenticationSuccess(
  Sender: TObject);
begin
  if Assigned(FOnAuthenticationSuccess) then
    FOnAuthenticationSuccess(Self);
end;

procedure TElClientIndySSHTransport.DoSSHBanner(Sender: TObject;
  const Text, Language: string);
begin
  if Assigned(FOnBanner) then
    FOnBanner(Self, Text, Language);
end;

procedure TElClientIndySSHTransport.DoSSHOpenConnection(
  Sender: TObject);
begin
  if Assigned(FOnOpenConnection) then
    FOnOpenConnection(Self);
end;

procedure TElClientIndySSHTransport.DoSSHCloseConnection(
  Sender: TObject);
begin
  if FActive then
    Disconnect;

  if Assigned(FOnCloseConnection) then
    FOnCloseConnection(Self);
end;

procedure TElClientIndySSHTransport.DoSSHError(Sender: TObject;
  ErrorCode: integer);
begin
  FErrorOccured := true;
  FLastError := ErrorCode;

  if Assigned(FOnError) then
    FOnError(Self, ErrorCode);
end;

procedure TElClientIndySSHTransport.DoSSHKeyValidate(Sender: TObject;
  ServerKey: TElSSHKey; var Validate: boolean);
begin
  if Assigned(FOnKeyValidate) then
    FOnKeyValidate(Self, ServerKey, Validate)
  else
    Validate := true;
end;

procedure TElClientIndySSHTransport.DoSSHReceive(Sender: TObject;
  Buffer: pointer; MaxSize: Integer; out Written: Integer);
begin
  Written := 0;
  if FActive then
  try
    FTCPClient.ReadFromStack(false, 0, false);

    if FTCPClient.Connected then
    begin
      Written := Min(FTCPClient.InputBuffer.Size, MaxSize);

      if Written > 0 then
      begin
        FTCPClient.InputBuffer.Position := 0;
        FTCPClient.InputBuffer.Read(Buffer^, Written);
        FTCPClient.InputBuffer.Remove(Written);
      end;
    end
    else
    begin
      Disconnect;
    end;
  except
    Written := 0;
    raise;
  end;
end;

procedure TElClientIndySSHTransport.DoSSHSend(Sender: TObject;
  Buffer: pointer; Size: Integer);
begin
  if FActive then
  begin
    FTCPClient.CheckForGracefulDisconnect(false);

    if FTCPClient.Connected and TIdIOHandlerSocket(FTCPClient.IOHandler).Binding.HandleAllocated then
    begin
      if FTCPClient.IOHandler.Send(Buffer^, Size) = -1 then
        raise Exception.Create('Connection lost');
      FTCPClient.IOHandler.DoWork(wmWrite, Size);
    end
    else
    if FTCPClient.InputBuffer.Size = 0 then
    begin
      raise Exception.Create('Connection lost');
    end;
  end;
end;

function TElClientIndySSHTransport.GetActive: boolean;
begin
  Result := FActive;
end;

function TElClientIndySSHTransport.GetAuthenticationTypes: integer;
begin
  Result := FSSHClient.AuthenticationTypes;
end;

function TElClientIndySSHTransport.GetClientHostname: string;
begin
  Result := FSSHClient.ClientHostName;
end;

function TElClientIndySSHTransport.GetClientUsername: string;
begin
  Result := FSSHClient.ClientUserName;
end;

function TElClientIndySSHTransport.GetCompressionAlgorithmCS: TSSHCompressionAlgorithm;
begin
  Result := FSSHClient.CompressionAlgorithmClientToServer;
end;

function TElClientIndySSHTransport.GetCompressionAlgorithms(
  Index: TSSHCompressionAlgorithm): boolean;
begin
  Result := FSSHClient.CompressionAlgorithms[Index];
end;

function TElClientIndySSHTransport.GetCompressionAlgorithmSC: TSSHCompressionAlgorithm;
begin
  Result := FSSHClient.CompressionAlgorithmServerToClient;
end;

function TElClientIndySSHTransport.GetCompressionLevel: integer;
begin
  Result := FSSHClient.CompressionLevel;
end;

function TElClientIndySSHTransport.GetEncryptionAlgorithmCS: TSSHEncryptionAlgorithm;
begin
  Result := FSSHClient.EncryptionAlgorithmClientToServer;
end;

function TElClientIndySSHTransport.GetEncryptionAlgorithms(
  Index: TSSHEncryptionAlgorithm): boolean;
begin
  Result := FSSHClient.EncryptionAlgorithms[Index];
end;

function TElClientIndySSHTransport.GetEncryptionAlgorithmSC: TSSHEncryptionAlgorithm;
begin
  Result := FSSHClient.EncryptionAlgorithmServerToClient;
end;

function TElClientIndySSHTransport.GetForceCompression: boolean;
begin
  Result := FSSHClient.ForceCompression;
end;

function TElClientIndySSHTransport.GetKexAlgorithm: TSSHKexAlgorithm;
begin
  Result := FSSHClient.KexAlgorithm;
end;

function TElClientIndySSHTransport.GetKexAlgorithms(
  Index: TSSHKexAlgorithm): boolean;
begin
  Result := FSSHClient.KexAlgorithms[Index];
end;

function TElClientIndySSHTransport.GetKeyStorage: TElSSHCustomKeyStorage;
begin
  Result := FSSHClient.KeyStorage;
end;

function TElClientIndySSHTransport.GetMacAlgorithmCS: TSSHMacAlgorithm;
begin
  Result := FSSHClient.MacAlgorithmClientToServer;
end;

function TElClientIndySSHTransport.GetMACAlgorithms(
  Index: TSSHMacAlgorithm): boolean;
begin
  Result := FSSHClient.MACAlgorithms[Index];
end;

function TElClientIndySSHTransport.GetMacAlgorithmSC: TSSHMacAlgorithm;
begin
  Result := FSSHClient.MacAlgorithmServerToClient;
end;

function TElClientIndySSHTransport.GetPassword: string;
begin
  Result := FSSHClient.Password;
end;

function TElClientIndySSHTransport.GetPublicKeyAlgorithm: TSSHPublicKeyAlgorithm;
begin
  Result := FSSHClient.PublicKeyAlgorithm;
end;

function TElClientIndySSHTransport.GetPublicKeyAlgorithms(
  Index: TSSHPublicKeyAlgorithm): boolean;
begin
  Result := FSSHClient.PublicKeyAlgorithms[Index];
end;

function TElClientIndySSHTransport.GetServerCloseReason: string;
begin
  Result := FSSHClient.ServerCloseReason;
end;

function TElClientIndySSHTransport.GetServerSoftwareName: string;
begin
  Result := FSSHClient.ServerSoftwareName;
end;

function TElClientIndySSHTransport.GetSoftwareName: string;
begin
  Result := FSSHClient.SoftwareName;
end;

function TElClientIndySSHTransport.GetUsername: string;
begin
  Result := FSSHClient.Username;
end;

function TElClientIndySSHTransport.GetVersion: TSSHVersion;
begin
  Result := FSSHClient.Version;
end;

function TElClientIndySSHTransport.GetVersions: TSSHVersions;
begin
  Result := FSSHClient.Versions;
end;

procedure TElClientIndySSHTransport.SetAuthenticationTypes(
  const Value: integer);
begin
  FSSHClient.AuthenticationTypes := Value;
end;

procedure TElClientIndySSHTransport.SetClientHostname(
  const Value: string);
begin
  FSSHClient.ClientHostname := Value;
end;

procedure TElClientIndySSHTransport.SetClientUsername(
  const Value: string);
begin
  FSSHClient.ClientUsername := Value;
end;

procedure TElClientIndySSHTransport.SetCompressionAlgorithms(
  Index: TSSHCompressionAlgorithm; const Value: boolean);
begin
  FSSHClient.CompressionAlgorithms[Index] := Value;
end;

procedure TElClientIndySSHTransport.SetCompressionLevel(
  const Value: integer);
begin
  FSSHClient.CompressionLevel := Value;
end;

procedure TElClientIndySSHTransport.SetEncryptionAlgorithms(
  Index: TSSHEncryptionAlgorithm; const Value: boolean);
begin
  FSSHClient.EncryptionAlgorithms[Index] := Value;
end;

procedure TElClientIndySSHTransport.SetForceCompression(
  const Value: boolean);
begin
  FSSHClient.ForceCompression := Value;
end;

procedure TElClientIndySSHTransport.SetKexAlgorithms(
  Index: TSSHKexAlgorithm; const Value: boolean);
begin
  FSSHClient.KexAlgorithms[Index] := Value;
end;

procedure TElClientIndySSHTransport.SetKeyStorage(
  const Value: TElSSHCustomKeyStorage);
begin
  FSSHClient.KeyStorage := Value;
end;

procedure TElClientIndySSHTransport.SetMACAlgorithms(
  Index: TSSHMacAlgorithm; const Value: boolean);
begin
  FSSHClient.MACAlgorithms[Index] := Value;
end;

procedure TElClientIndySSHTransport.SetPassword(const Value: string);
begin
  FSSHClient.Password := Value;
end;

procedure TElClientIndySSHTransport.SetPublicKeyAlgorithms(
  Index: TSSHPublicKeyAlgorithm; const Value: boolean);
begin
  FSSHClient.PublicKeyAlgorithms[Index] := Value;
end;

procedure TElClientIndySSHTransport.SetSoftwareName(
  const Value: string);
begin
  FSSHClient.SoftwareName := Value;
end;

procedure TElClientIndySSHTransport.SetUsername(const Value: string);
begin
  FSSHClient.Username := Value;
end;

procedure TElClientIndySSHTransport.SetVersions(
  const Value: TSSHVersions);
begin
  FSSHClient.Versions := Value;
end;

function TElClientIndySSHTransport.GetHost: string;
begin
  Result := FTCPClient.Host;
end;

function TElClientIndySSHTransport.GetIOHandler: TIdIOHandler;
begin
  Result := FTCPClient.IOHandler;
end;

function TElClientIndySSHTransport.GetPort: integer;
begin
  Result := FTCPClient.Port;
end;

procedure TElClientIndySSHTransport.SetHost(const Value: string);
begin
  FTCPClient.Host := Value;
end;

procedure TElClientIndySSHTransport.SetIOHandler(
  const Value: TIdIOHandler);
begin
  FTCPClient.IOHandler := Value;
end;

procedure TElClientIndySSHTransport.SetPort(const Value: integer);
begin
  FTCPClient.Port := Value;
end;

procedure TElClientIndySSHTransport.DoTCPDisconnected(Sender: TObject);
begin
  DoSSHError(Self, ERROR_SSH_CONNECTION_LOST);
  Disconnect;
end;

function TElClientIndySSHTransport.GetCloseIfNoActiveTunnels: boolean;
begin
  Result := FSSHClient.CloseIfNoActiveTunnels;
end;

procedure TElClientIndySSHTransport.SetCloseIfNoActiveTunnels(
  const Value: boolean);
begin
  FSSHClient.CloseIfNoActiveTunnels := Value;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -