📄 sbindysshserveriohandler10.pas
字号:
end;
function TElIdSSHClientServerIOHandler.GetEncryptionAlgorithmSC: TSSHEncryptionAlgorithm;
begin
Result := FSSHServer.EncryptionAlgorithmServerToClient;
end;
function TElIdSSHClientServerIOHandler.GetForceCompression: boolean;
begin
Result := FSSHServer.ForceCompression;
end;
function TElIdSSHClientServerIOHandler.GetKexAlgorithm: TSSHKexAlgorithm;
begin
Result := FSSHServer.KexAlgorithm;
end;
function TElIdSSHClientServerIOHandler.GetKexAlgorithms(
Index: TSSHKexAlgorithm): boolean;
begin
Result := FSSHServer.KexAlgorithms[Index];
end;
function TElIdSSHClientServerIOHandler.GetKeyStorage: TElSSHCustomKeyStorage;
begin
Result := FSSHServer.KeyStorage;
end;
function TElIdSSHClientServerIOHandler.GetMacAlgorithmCS: TSSHMacAlgorithm;
begin
Result := FSSHServer.MacAlgorithmClientToServer;
end;
function TElIdSSHClientServerIOHandler.GetMACAlgorithms(
Index: TSSHMacAlgorithm): boolean;
begin
Result := FSSHServer.MacAlgorithms[Index];
end;
function TElIdSSHClientServerIOHandler.GetMacAlgorithmSC: TSSHMacAlgorithm;
begin
Result := FSSHServer.MacAlgorithmServerToClient;
end;
function TElIdSSHClientServerIOHandler.GetPublicKeyAlgorithm: TSSHPublicKeyAlgorithm;
begin
Result := FSSHServer.PublicKeyAlgorithm;
end;
function TElIdSSHClientServerIOHandler.GetPublicKeyAlgorithms(
Index: TSSHPublicKeyAlgorithm): boolean;
begin
Result := FSSHServer.PublicKeyAlgorithms[Index];
end;
function TElIdSSHClientServerIOHandler.GetSoftwareName: string;
begin
Result := FSSHServer.SoftwareName;
end;
procedure TElIdSSHClientServerIOHandler.SetAuthenticationTypes(
const Value: integer);
begin
FSSHServer.AuthenticationTypes := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetCloseIfNoActiveTunnels(
const Value: boolean);
begin
FSSHServer.CloseIfNoActiveTunnels := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetCompressionAlgorithms(
Index: TSSHCompressionAlgorithm; const Value: boolean);
begin
FSSHServer.CompressionAlgorithms[Index] := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetCompressionLevel(
const Value: integer);
begin
FSSHServer.CompressionLevel := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetEncryptionAlgorithms(
Index: TSSHEncryptionAlgorithm; const Value: boolean);
begin
FSSHServer.EncryptionAlgorithms[Index] := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetForceCompression(
const Value: boolean);
begin
FSSHServer.ForceCompression := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetKexAlgorithms(
Index: TSSHKexAlgorithm; const Value: boolean);
begin
FSSHServer.KexAlgorithms[Index] := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetKeyStorage(
const Value: TElSSHCustomKeyStorage);
begin
FSSHServer.KeyStorage := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetMACAlgorithms(
Index: TSSHMacAlgorithm; const Value: boolean);
begin
FSSHServer.MacAlgorithms[Index] := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetPublicKeyAlgorithms(
Index: TSSHPublicKeyAlgorithm; const Value: boolean);
begin
FSSHServer.PublicKeyAlgorithms[Index] := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetSoftwareName(
const Value: string);
begin
FSSHServer.SoftwareName := Value;
end;
function TElIdSSHClientServerIOHandler.GetConnectionCount: integer;
begin
Result := FConnections.Count;
end;
{procedure TElIdSSHClientServerIOHandler.CheckForDisconnect(
ARaiseExceptionIfDisconnected, AIgnoreBuffer: Boolean);
begin
inherited CheckForDisconnect;
end;}
{procedure TElIdSSHClientServerIOHandler.CheckForDataOnSource(
ATimeout: Integer);
begin
inherited CheckForDataOnSource;
end;}
procedure TElIdSSHClientServerIOHandler.InitComponent;
begin
inherited;
FSSHServer := TElSSHServer.Create(nil);
FConnections := TList.Create;
FActive := false;
FErrorOccured := false;
end;
procedure TElIdSSHClientServerIOHandler.DoCloseConnection(Sender: TObject);
begin
if FActive then
Close;
if Assigned(FOnCloseConnection) then
FOnCloseConnection(Sender);
end;
function TElIdSSHClientServerIOHandler.GetOnOpenConnection: TSSHOpenConnectionEvent;
begin
Result := FSSHServer.OnOpenConnection;
end;
procedure TElIdSSHClientServerIOHandler.SetOnOpenConnection(
const Value: TSSHOpenConnectionEvent);
begin
FSSHServer.OnOpenConnection := Value;
end;
{ TElIdSSHConnectionIOHandler }
procedure TElIdSSHConnectionIOHandler.CheckForDataOnSource(
ATimeout: Integer);
begin
if Assigned(FSSHServer) then
FSSHServer.DataAvailable;
end;
procedure TElIdSSHConnectionIOHandler.CheckForDisconnect(
ARaiseExceptionIfDisconnected, AIgnoreBuffer: boolean);
begin
if Assigned(FSSHServer) then
FSSHServer.DataAvailable;
end;
procedure TElIdSSHConnectionIOHandler.Close;
begin
if Assigned(FTunnelConnection) and FActive then
begin
FActive := false;
FTunnelConnection.Close;
FTunnelConnection := nil;
end;
inherited;
end;
function TElIdSSHConnectionIOHandler.Connected: boolean;
begin
Result := FActive;
end;
destructor TElIdSSHConnectionIOHandler.Destroy;
begin
Close;
inherited;
end;
procedure TElIdSSHConnectionIOHandler.DoOnClose(Sender: TObject;
CloseType: TSSHCloseType);
begin
FActive := false;
FTunnelConnection := nil;
end;
procedure TElIdSSHConnectionIOHandler.DoOnData(Sender: TObject;
Buffer: pointer; Size: Integer);
var
Buf : TIdBytes;
begin
if Size > 0 then
begin
SetLength(Buf, Size);
Move(Buffer^, Buf[0], Size);
if Assigned(Intercept) then
Intercept.Receive(Buf);
InputBuffer.Write(Buf);
end;
end;
procedure TElIdSSHConnectionIOHandler.DoOnError(Sender: TObject;
ErrorCode: integer);
begin
FErrorOccured := true;
end;
procedure TElIdSSHConnectionIOHandler.InitComponent;
begin
inherited;
FErrorOccured := false;
FActive := false;
FSSHServer := nil;
FTunnelConnection := nil;
end;
procedure TElIdSSHConnectionIOHandler.SetConnection(
ATunnelConnection: TElSSHTunnelConnection; ASSHServer : TElSSHServer);
begin
if (FTunnelConnection = nil) and Assigned(ATunnelConnection)
and Assigned(ASSHServer)
then
begin
FTunnelConnection := ATunnelConnection;
FTunnelConnection.OnData := DoOnData;
FTunnelConnection.OnError := DoOnError;
FTunnelConnection.OnClose := DoOnClose;
FSSHServer := ASSHServer;
FSSHServer.FreeNotification(Self);
FActive := true;
end;
end;
function TElIdSSHConnectionIOHandler.Readable(AMSec: Integer): Boolean;
begin
if Assigned(FTunnelConnection) and FActive then
Result := true
else
Result := false;
end;
function TElIdSSHConnectionIOHandler.ReadFromSource(
ARaiseExceptionIfDisconnected: Boolean; ATimeout: Integer;
ARaiseExceptionOnTimeout: Boolean): Integer;
begin
if Assigned(FSSHServer) then
FSSHServer.DataAvailable;
Result := 0;
end;
{$ifndef INDY1011}
procedure TElIdSSHConnectionIOHandler.WriteDirect(ABuffer: TIdBytes);
{$else}
procedure TElIdSSHConnectionIOHandler.WriteDirect(var ABuffer: TIdBytes);
{$endif}
begin
if Assigned(FIntercept) then
FIntercept.Send(ABuffer);
if Assigned(FTunnelConnection) and FActive and (Length(Abuffer) > 0) then
FTunnelConnection.SendData(@ABuffer[0], Length(ABuffer));
end;
procedure TElIdSSHConnectionIOHandler.Notification(AComponent: TComponent;
AOperation: TOperation);
begin
inherited;
if (AComponent = FSSHServer) and (AOperation = opRemove) then
begin
FSSHServer := nil;
FTunnelConnection := nil;
FActive := false;
end;
end;
{ TElIdSSHConnection }
function TElIdSSHConnection.GetData: pointer;
begin
if Assigned(FTunnelConnection) then
Result := FTunnelConnection.Data
else
Result := nil;
end;
function TElIdSSHConnection.GetExitMessage: string;
begin
if Assigned(FTunnelConnection) then
Result := FTunnelConnection.ExitMessage
else
Result := '';
end;
function TElIdSSHConnection.GetExitSignal: string;
begin
if Assigned(FTunnelConnection) then
Result := FTunnelConnection.ExitSignal
else
Result := '';
end;
function TElIdSSHConnection.GetExitStatus: integer;
begin
if Assigned(FTunnelConnection) then
Result := FTunnelConnection.ExitStatus
else
Result := 0;
end;
function TElIdSSHConnection.GetTunnelType: TSSHTunnelType;
begin
if FTunnelConnection.Tunnel is TElShellSSHTunnel then
Result := ttShell
else if FTunnelConnection.Tunnel is TElCommandSSHTunnel then
Result := ttCommand
else if FTunnelConnection.Tunnel is TElLocalPortForwardSSHTunnel then
Result := ttLocalPortToRemoteAddress
else if FTunnelConnection.Tunnel is TElRemotePortForwardSSHTunnel then
Result := ttRemotePortToLocalAddress
else if FTunnelConnection.Tunnel is TElX11ForwardSSHTunnel then
Result := ttX11
else if FTunnelConnection.Tunnel is TElSubsystemSSHTunnel then
Result := ttSubsystem
else if FTunnelConnection.Tunnel is TElAuthenticationAgentSSHTunnel then
Result := ttAuthenticationAgent
else
Result := ttSubsystem;
end;
procedure TElIdSSHConnection.InitComponent;
begin
inherited;
FTunnelConnection := nil;
FSSHServer := nil;
FDestPort := 0;
FSrcPort := 0;
FDestHost := '';
FSrcHost := '';
FScreenNumber := 0;
FCommand := '';
FAuthenticationProtocol := '';
FSubsystem := '';
FTerminalInfo := nil;
FEnvironment := nil;
end;
procedure TElIdSSHConnection.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (AComponent = FSSHServer) and (Operation = opRemove) then
begin
FSSHServer := nil;
FTunnelConnection := nil;
end;
end;
procedure TElIdSSHConnection.SetConnection(ATunnelConnection :
TElSSHTunnelConnection; ASSHServer : TElSSHServer);
begin
if Assigned(ATunnelConnection) and Assigned(ASSHServer)
then
begin
ASSHServer.FreeNotification(Self);
FTunnelConnection := ATunnelConnection;
FSSHServer := ASSHServer;
if Assigned(FIOHandler) then
TElIdSSHConnectionIOHandler(FIOHandler).SetConnection(
FTunnelConnection, FSSHServer);
end;
end;
procedure TElIdSSHConnection.SetData(const Value: pointer);
begin
if Assigned(FTunnelConnection) then
FTunnelConnection.Data := Value;
end;
procedure TElIdSSHConnection.SetIOHandler(AValue: TIdIOHandler);
begin
if AValue is TElIdSSHConnectionIOHandler then
begin
inherited SetIOHandler(AValue);
TElIdSSHConnectionIOHandler(FIOHandler).SetConnection(
FTunnelConnection, FSSHServer);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -