Snoop function for UNIX version

This commit is contained in:
mysticbbs 2012-06-18 08:59:19 -04:00
parent 439eb2a052
commit 32b416817e
4 changed files with 57 additions and 8 deletions

View File

@ -58,7 +58,6 @@ Const
FocusMax = 4; FocusMax = 4;
Var Var
Console : TOutput;
Keyboard : TInput; Keyboard : TInput;
TelnetServer : TServerManager; TelnetServer : TServerManager;
FTPServer : TServerManager; FTPServer : TServerManager;
@ -265,7 +264,6 @@ Procedure LocalLogin;
Const Const
BufferSize = 1024 * 4; BufferSize = 1024 * 4;
Var Var
Term : TTermAnsi;
Client : TSocketClass; Client : TSocketClass;
Res : LongInt; Res : LongInt;
Buffer : Array[1..BufferSize] of Char; Buffer : Array[1..BufferSize] of Char;
@ -338,6 +336,38 @@ Begin
End; End;
{$IFDEF UNIX} {$IFDEF UNIX}
Procedure Snoop;
Begin
If FocusCurrent <> FocusTelnet Then Exit;
If FocusPtr.ClientList[BarPos - 1] <> NIL Then Begin
Term := TTermAnsi.Create(Console);
Console.TextAttr := 7;
Console.ClearScreen;
Console.SetWindow (1, 1, 80, 24, True);
Console.WriteXY (1, 25, 112, strPadC('Snooping : Press [ESC] to Quit', 80, ' '));
TTelnetServer(FocusPtr.ClientList[BarPos - 1]).Snooping := True;
Repeat Until Keyboard.ReadKey = #27;
If TTelnetServer(FocusPtr.ClientList[BarPos - 1]) <> NIL Then
TTelnetServer(FocusPtr.ClientList[BarPos - 1]).Snooping := False;
Term.Free;
Console.TextAttr := 7;
Console.SetWindow (1, 1, 80, 25, True);
FocusCurrent := FocusMax;
DrawStatusScreen;
SwitchFocus;
End;
End;
Procedure ExecuteDaemon; Procedure ExecuteDaemon;
Var Var
PID : TPID; PID : TPID;
@ -468,7 +498,7 @@ Begin
{$ENDIF} {$ENDIF}
Repeat Repeat
If Keyboard.KeyWait(1000) Then If Keyboard.KeyWait(500) Then
Case Keyboard.ReadKey of Case Keyboard.ReadKey of
#00 : Case Keyboard.ReadKey of #00 : Case Keyboard.ReadKey of
#72 : If BarPos > TopPage Then Begin #72 : If BarPos > TopPage Then Begin
@ -511,6 +541,7 @@ Begin
End; End;
End; End;
#09 : SwitchFocus; #09 : SwitchFocus;
#13 : {$IFDEF UNIX}Snoop{$ENDIF};
#27 : Break; #27 : Break;
#32 : LocalLogin; #32 : LocalLogin;
End; End;

View File

@ -37,6 +37,12 @@ Const
'u','t','d','o','w','n',' ',#24); 'u','t','d','o','w','n',' ',#24);
Begin Begin
Console.LoadScreenImage(ImageData, ImageData_Length, ImageData_Width, 1, 1); Console.LoadScreenImage(ImageData, ImageData_Length, ImageData_Width, 1, 1);
//Console.WriteXY (25, 1, 113, strPadC(mysVersionText, 30, ' '));
{$IFDEF UNIX}
Console.WriteXY (1, 25, 113, strPadC('ENTER/Snoop SPACE/Local TELNET TAB/Switch ESC/Shutdown', 79, ' '));
{$ELSE}
Console.WriteXY (1, 25, 113, strPadC('SPACE/Local TELNET TAB/Switch ESC/Shutdown', 79, ' ')); Console.WriteXY (1, 25, 113, strPadC('SPACE/Local TELNET TAB/Switch ESC/Shutdown', 79, ' '));
// Console.WriteXY (25, 1, 113, strPadC(mysVersionText, 30, ' ')); {$ENDIF}
End; End;

View File

@ -27,6 +27,7 @@ Function CreateTelnet (Owner: TServerManager; Config: RecConfig; ND: TNodeData;
Type Type
TTelnetServer = Class(TServerClient) TTelnetServer = Class(TServerClient)
ND : TNodeData; ND : TNodeData;
Snooping : Boolean;
Constructor Create (Owner: TServerManager; ND: TNodeData; CliSock: TSocketClass); Constructor Create (Owner: TServerManager; ND: TNodeData; CliSock: TSocketClass);
Procedure Execute; Override; Procedure Execute; Override;
Destructor Destroy; Override; Destructor Destroy; Override;
@ -44,6 +45,7 @@ Begin
Inherited Create(Owner, CliSock); Inherited Create(Owner, CliSock);
Self.ND := ND; Self.ND := ND;
Snooping := False;
End; End;
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
@ -133,6 +135,9 @@ Begin
While Proc.Output.NumBytesAvailable > 0 Do Begin While Proc.Output.NumBytesAvailable > 0 Do Begin
bRead := Proc.Output.Read(Buffer, BufferSize); bRead := Proc.Output.Read(Buffer, BufferSize);
Client.WriteBuf (Buffer, bRead); Client.WriteBuf (Buffer, bRead);
If Snooping Then
Term.ProcessBuf(Buffer[1], bRead);
End; End;
End Else End Else
If Client.DataWaiting Then Begin If Client.DataWaiting Then Begin
@ -140,8 +145,9 @@ Begin
If bWrite < 0 Then Break; If bWrite < 0 Then Break;
If bWrite > 0 Then If bWrite > 0 Then Begin
Proc.Input.Write(Buffer, bWrite); Proc.Input.Write(Buffer, bWrite);
End;
End Else End Else
Sleep(10); Sleep(10);
End; End;

View File

@ -4,10 +4,16 @@ Unit MIS_Common;
Interface Interface
Uses
m_Output,
m_Term_Ansi;
{$I RECORDS.PAS} {$I RECORDS.PAS}
Var Var
bbsConfig : RecConfig; bbsConfig : RecConfig;
Console : TOutput;
Term : TTermAnsi;
Function SearchForUser (UN: String; Var Rec: RecUser; Var RecPos: LongInt) : Boolean; Function SearchForUser (UN: String; Var Rec: RecUser; Var RecPos: LongInt) : Boolean;
Function CheckAccess (User: RecUser; IgnoreGroup: Boolean; Str: String) : Boolean; Function CheckAccess (User: RecUser; IgnoreGroup: Boolean; Str: String) : Boolean;