Форум: "Сети";
Текущий архив: 2002.04.29;
Скачать: [xml.tar.bz2];
ВнизSOCKS5 server Найти похожие ветки
← →
Ghost. (2002-02-17 13:03) [11](******************************************************************************
DESTROY:
Destory this object.
******************************************************************************)
destructor TDXSOCKSV4ServerCore.Destroy;
Var
PSimpleEvent:PSOCKSV4SimpleEvent;
begin
While fEventArray.Count>0 do Begin
Case PSOCKSV4SimpleEvent(fEventArray[0]).Tag of
1:Begin
PSimpleEvent:=fEventArray[0];
Dispose(PSimpleEvent);
End;
End;
fEventArray.Delete(0);
End;
inherited Destroy;
end;
(******************************************************************************
ADDSimpleEVENT:
Allows you to dynamically assign a new command to the internal
parser. This allows the servercore to support the "pre-defined"
OnCommand* events, plus you can add other commands dynamically
at run-time in your application without requiring a source code
modification to our components!
To make support easier for us, we ask that you use the Add*Event
procedures to expand our code, reducing code changes when an
upgrade is released!
See documentation for complete information on how this works.
Example Usage: AddSimpleEvent("CDROM",MySpecialEvent);
******************************************************************************)
Procedure TDXSOCKSV4ServerCore.AddBasicEvent(Command:String;EventProc:SOCKSV4TSimpleEvent);
Var
PSimpleEvent:PSOCKSV4SimpleEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PSOCKSV4SimpleEvent(fEventArray[Loop]).Command=Command then Begin
PSOCKSV4SimpleEvent(fEventArray[Loop]).EventProcedure:=EventProc;
Exit;
End
Else Inc(Loop);
End;
New(PSimpleEvent);
PSimpleEvent.Tag:=1; // Denotes Event in fEventArray is a TSimpleEvent!
PSimpleEvent.Command:=Command;
PSimpleEvent.EventProcedure:=EventProc;
fEventArray.Add(PSimpleEvent);
End;
Procedure TDXSOCKSV4ServerCore.SetOnCommandUSER(value:SOCKSV4TSimpleEvent);
Begin
fOnCommandUSER:=Value;
AddBasicEvent("USER",Value);
End;
(******************************************************************************
PROCESSSESSION:
If you want this CORE to process the parsing, you should call
this from your "OnNewConnect" implementation. This should be
right after your call to SayHello (optional).
******************************************************************************)
procedure TDXSOCKSV4ServerCore.ProcessSession(ClientThread: TDXServerThread);
var
s, sCmd: string;
Loop:Integer;
WasHandled:Boolean;
procedure NotHandled(CMD: string);
Var
Ws:String;
begin
Ws:="500 command not recognized (" + CMD + ")";
ClientThread.Socket.Writeln(Ws);
end;
begin
with ClientThread.Socket do begin
s:=ReadLn(fiTimeout);
If LastReadTimeout or Not ValidSocket then Exit;
sCmd:=UpperCase(Fetch(s,#32,False));
Loop:=0;
WasHandled:=False;
While (Loop<fEventArray.Count) and (Not WasHandled) do Begin
If PSOCKSV4SimpleEvent(fEventArray[Loop]).Command=sCMD then Begin
Case PSOCKSV4SimpleEvent(fEventArray[Loop]).Tag of
1:if Assigned(PSOCKSV4SimpleEvent(fEventArray[Loop]).EventProcedure) then
SOCKSV4TSimpleEvent(PSOCKSV4SimpleEvent(fEventArray[Loop]).EventProcedure)(ClientThread);
End;
WasHandled:=True;
End
Else Inc(Loop);
End; {while}
If Not WasHandled then Begin
if assigned(OnCommandOther) then
OnCommandOther(ClientThread,sCmd,s,WasHandled);
end;
if not WasHandled then NotHandled(sCmd);
end; {with}
end; {doExecute}
end.
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2002.04.29;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.005 c