📄 sbindysshserveriohandler9.pas
字号:
Index : integer;
begin
Index := AddConnection(Connection, TElSSHServer(Sender));
if Assigned(FOnOpenChannel) then
FOnOpenChannel(Self, Connections[Index]);
if Assigned(FOnOpenX11Forwarding) then
FOnOpenX11Forwarding(Sender, Connection, OrigIP, OrigPort);
end;
procedure TElIdSSHClientServerIOHandler.DoReceive(Sender: TObject;
Buffer: pointer; MaxSize: Integer; out Written: Integer);
var
Buf : ByteArray;
begin
try
Written := 0;
if FBinding.HandleAllocated then
if FBinding.Readable then
begin
SetLength(Buf, MaxSize);
Written := inherited Recv(Buf[0], MaxSize);
if Written < 0 then
raise EElIdSSHException.Create(SConnectionError);
FInputBuffer.Seek(0, soFromEnd);
FInputBuffer.Write(Buf[0], Written);
end;
if Written > 0 then
begin
FInputBuffer.Position := 0;
FInputBuffer.Read(Buffer^, Written);
FInputBuffer.Remove(Written);
end;
except
Close;
Written := 0;
end;
end;
procedure TElIdSSHClientServerIOHandler.DoSend(Sender: TObject;
Buffer: pointer; Size: Integer);
begin
if FBinding.HandleAllocated then
try
inherited Send(Buffer^, Size);
except
Close;
end;
end;
function TElIdSSHClientServerIOHandler.GetConnections(
Index: integer): TElIdSSHConnection;
begin
if (Index >= 0) and (Index < FConnections.Count) then
Result := TElIdSSHConnection(FConnections[Index])
else
Result := nil;
end;
procedure TElIdSSHClientServerIOHandler.AfterAccept;
begin
inherited;
FSSHServer.OnError := DoSSHError;
FSSHServer.OnReceive := DoReceive;
FSSHServer.OnSend := DoSend;
FSSHServer.OnOpenShell := DoOpenShell;
FSSHServer.OnOpenCommand := DoOpenCommand;
FSSHServer.OnOpenSubsystem := DoOpenSubsystem;
FSSHServer.OnOpenClientForwarding := DoOpenClientForwarding;
FSSHServer.OnOpenServerForwarding := DoOpenServerForwarding;
FSSHServer.OnOpenX11Forwarding := DoOpenX11Forwarding;
FSSHServer.OnCloseConnection := DoCloseConnection;
FSSHServer.Open;
FActive := true;
end;
function TElIdSSHClientServerIOHandler.GetActive: boolean;
begin
Result := FActive;
end;
procedure TElIdSSHClientServerIOHandler.DataAvailable;
begin
FSSHServer.DataAvailable;
end;
function TElIdSSHClientServerIOHandler.GetAllowedSubsystems: TStringList;
begin
Result := FSSHServer.AllowedSubsystems;
end;
function TElIdSSHClientServerIOHandler.GetChangePwdPrompt: string;
begin
Result := FSSHServer.ChangePwdPrompt;
end;
function TElIdSSHClientServerIOHandler.GetClientCloseReason: string;
begin
Result := FSSHServer.ClientCloseReason;
end;
function TElIdSSHClientServerIOHandler.GetClientSoftwareName: string;
begin
Result := FSSHServer.ClientSoftwareName;
end;
function TElIdSSHClientServerIOHandler.GetUsername: string;
begin
Result := FSSHServer.Username;
end;
procedure TElIdSSHClientServerIOHandler.OpenServerForwarding(
const Address: string; Port: integer; const SrcHost: string;
SrcPort: integer; Data: pointer);
begin
FSSHServer.OpenServerForwarding(Address, Port, SrcHost, SrcPort, Data);
end;
procedure TElIdSSHClientServerIOHandler.SetChangePwdPrompt(
const Value: string);
begin
FSSHServer.ChangePwdPrompt := Value;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthAttempt: TSSHAuthAttemptEvent;
begin
Result := FSSHServer.OnAuthAttempt;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthBanner: TSSHAuthBannerEvent;
begin
Result := FSSHServer.OnAuthBanner;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthFailed: TSSHAuthenticationFailedEvent;
begin
Result := FSSHServer.OnAuthFailed;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthHostbased: TSSHAuthHostbasedEvent;
begin
Result := FSSHServer.OnAuthHostbased;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthKeyboard: TSSHAuthKeyboardEvent;
begin
Result := FSSHServer.OnAuthKeyboard;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthKeyboardResponse: TSSHAuthKeyboardResponseEvent;
begin
Result := FSSHServer.OnAuthKeyboardResponse;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthPassword: TSSHAuthPasswordEvent;
begin
Result := FSSHServer.OnAuthPassword;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthPasswordChange: TSSHAuthPasswordChangeEvent;
begin
Result := FSSHServer.OnAuthPasswordChange;
end;
function TElIdSSHClientServerIOHandler.GetOnAuthPublicKey: TSSHAuthPublicKeyEvent;
begin
Result := FSSHServer.OnAuthPublicKey;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenClientForwarding: TSSHBeforeOpenClientForwardingEvent;
begin
Result := FSSHServer.OnBeforeOpenClientForwarding;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenCommand: TSSHBeforeOpenCommandEvent;
begin
Result := FSSHServer.OnBeforeOpenCommand;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenSession: TSSHBeforeOpenSessionEvent;
begin
Result := FSSHServer.OnBeforeOpenSession;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenShell: TSSHBeforeOpenShellEvent;
begin
Result := FSSHServer.OnBeforeOpenShell;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenSubsystem: TSSHBeforeOpenSubsystemEvent;
begin
Result := FSSHServer.OnBeforeOpenSubsystem;
end;
function TElIdSSHClientServerIOHandler.GetOnBeforeOpenX11Forwarding: TSSHBeforeOpenX11ForwardingEvent;
begin
Result := FSSHServer.OnBeforeOpenX11Forwarding;
end;
function TElIdSSHClientServerIOHandler.GetOnOpenSession: TSSHOpenSessionEvent;
begin
Result := FSSHServer.OnOpenSession;
end;
function TElIdSSHClientServerIOHandler.GetOnServerForwardingCancel: TSSHServerForwardingCancelEvent;
begin
Result := FSSHServer.OnServerForwardingCancel;
end;
function TElIdSSHClientServerIOHandler.GetOnServerForwardingFailed: TSSHServerForwardingFailedEvent;
begin
Result := FSSHServer.OnServerForwardingFailed;
end;
function TElIdSSHClientServerIOHandler.GetOnServerForwardingRequest: TSSHServerForwardingRequestEvent;
begin
Result := FSSHServer.OnServerForwardingRequest;
end;
function TElIdSSHClientServerIOHandler.GetOnTerminalRequest: TSSHTerminalRequestEvent;
begin
Result := FSSHServer.OnTerminalRequest;
end;
function TElIdSSHClientServerIOHandler.GetOnX11ForwardingRequest: TSSHX11ForwardingRequestEvent;
begin
Result := FSSHServer.OnX11ForwardingRequest;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthAttempt(
const Value: TSSHAuthAttemptEvent);
begin
FSSHServer.OnAuthAttempt := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthBanner(
const Value: TSSHAuthBannerEvent);
begin
FSSHServer.OnAuthBanner := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthFailed(
const Value: TSSHAuthenticationFailedEvent);
begin
FSSHServer.OnAuthFailed := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthHostbased(
const Value: TSSHAuthHostbasedEvent);
begin
FSSHServer.OnAuthHostbased := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthKeyboard(
const Value: TSSHAuthKeyboardEvent);
begin
FSSHServer.OnAuthKeyboard := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthKeyboardResponse(
const Value: TSSHAuthKeyboardResponseEvent);
begin
FSSHServer.OnAuthKeyboardResponse := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthPassword(
const Value: TSSHAuthPasswordEvent);
begin
FSSHServer.OnAuthPassword := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthPasswordChange(
const Value: TSSHAuthPasswordChangeEvent);
begin
FSSHServer.OnAuthPasswordChange := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnAuthPublicKey(
const Value: TSSHAuthPublicKeyEvent);
begin
FSSHServer.OnAuthPublicKey := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenClientForwarding(
const Value: TSSHBeforeOpenClientForwardingEvent);
begin
FSSHServer.OnBeforeOpenClientForwarding := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenCommand(
const Value: TSSHBeforeOpenCommandEvent);
begin
FSSHServer.OnBeforeOpenCommand := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenSession(
const Value: TSSHBeforeOpenSessionEvent);
begin
FSSHServer.OnBeforeOpenSession := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenShell(
const Value: TSSHBeforeOpenShellEvent);
begin
FSSHServer.OnBeforeOpenShell := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenSubsystem(
const Value: TSSHBeforeOpenSubsystemEvent);
begin
FSSHServer.OnBeforeOpenSubsystem := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnBeforeOpenX11Forwarding(
const Value: TSSHBeforeOpenX11ForwardingEvent);
begin
FSSHServer.OnBeforeOpenX11Forwarding := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnOpenSession(
const Value: TSSHOpenSessionEvent);
begin
FSSHServer.OnOpenSession := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnServerForwardingCancel(
const Value: TSSHServerForwardingCancelEvent);
begin
FSSHServer.OnServerForwardingCancel := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnServerForwardingFailed(
const Value: TSSHServerForwardingFailedEvent);
begin
FSSHServer.OnServerForwardingFailed := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnServerForwardingRequest(
const Value: TSSHServerForwardingRequestEvent);
begin
FSSHServer.OnServerForwardingRequest := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnTerminalRequest(
const Value: TSSHTerminalRequestEvent);
begin
FSSHServer.OnTerminalRequest := Value;
end;
procedure TElIdSSHClientServerIOHandler.SetOnX11ForwardingRequest(
const Value: TSSHX11ForwardingRequestEvent);
begin
FSSHServer.OnX11ForwardingRequest := Value;
end;
function TElIdSSHClientServerIOHandler.AddConnection(
Connection: TElSSHTunnelConnection; Server : TElSSHServer) : integer;
var
Conn : TElIdSSHConnection;
begin
if FActive then
begin
Conn := TElIdSSHConnection.Create(nil);
Conn.IOHandler := TElIdSSHConnectionIOHandler.Create(nil);
TElIdSSHConnectionIOHandler(Conn.IOHandler).SetConnection(Connection, Server);
Conn.SetConnection(Connection, Server);
Conn.IOHandler.Open;
Result := FConnections.Add(Conn);
end
else
Result := -1;
end;
procedure TElIdSSHClientServerIOHandler.DoSSHError(Sender: TObject;
ErrorCode: integer);
begin
FErrorOccured := true;
if Assigned(FOnError) then
FOnError(Sender, ErrorCode);
end;
function TElIdSSHClientServerIOHandler.GetAuthenticationTypes: integer;
begin
Result := FSSHServer.AuthenticationTypes;
end;
function TElIdSSHClientServerIOHandler.GetCloseIfNoActiveTunnels: boolean;
begin
Result := FSSHServer.CloseIfNoActiveTunnels;
end;
function TElIdSSHClientServerIOHandler.GetCompressionAlgorithmCS: TSSHCompressionAlgorithm;
begin
Result := FSSHServer.CompressionAlgorithmClientToServer;
end;
function TElIdSSHClientServerIOHandler.GetCompressionAlgorithms(
Index: TSSHCompressionAlgorithm): boolean;
begin
Result := FSSHServer.CompressionAlgorithms[Index];
end;
function TElIdSSHClientServerIOHandler.GetCompressionAlgorithmSC: TSSHCompressionAlgorithm;
begin
Result := FSSHServer.CompressionAlgorithmServerToClient;
end;
function TElIdSSHClientServerIOHandler.GetCompressionLevel: integer;
begin
Result := FSSHServer.CompressionLevel;
end;
function TElIdSSHClientServerIOHandler.GetEncryptionAlgorithmCS: TSSHEncryptionAlgorithm;
begin
Result := FSSHServer.EncryptionAlgorithmClientToServer;
end;
function TElIdSSHClientServerIOHandler.GetEncryptionAlgorithms(
Index: TSSHEncryptionAlgorithm): boolean;
begin
Result := FSSHServer.EncryptionAlgorithms[Index];
end;
function TElIdSSHClientServerIOHandler.GetEncryptionAlgorithmSC: TSSHEncryptionAlgorithm;
begin
Result := FSSHServer.EncryptionAlgorithmServerToClient;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -