Beginning of FTP uploads
This commit is contained in:
parent
7e25a22a71
commit
6db36536ed
|
@ -48,13 +48,13 @@ Type
|
||||||
Procedure Execute; Override;
|
Procedure Execute; Override;
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
|
|
||||||
|
Function OpenDataSession : Boolean;
|
||||||
|
Procedure CloseDataSession;
|
||||||
Procedure ResetSession;
|
Procedure ResetSession;
|
||||||
Procedure UpdateUserStats (TFBase: RecFileBase; FDir: RecFileList; DirPos: LongInt);
|
Procedure UpdateUserStats (TFBase: RecFileBase; FDir: RecFileList; DirPos: LongInt);
|
||||||
Function CheckFileLimits (TempFBase: RecFileBase; FDir: RecFileList) : Byte;
|
Function CheckFileLimits (TempFBase: RecFileBase; FDir: RecFileList) : Byte;
|
||||||
Function OpenDataSession : Boolean;
|
Function ValidDirectory (TempBase: RecFileBase) : Boolean;
|
||||||
Procedure CloseDataSession;
|
Function FindDirectory (Var TempBase: RecFileBase) : LongInt;
|
||||||
Function ValidDirectory (TempBase: RecFileBase) : Boolean;
|
|
||||||
Function FindDirectory (Var TempBase: RecFileBase) : LongInt;
|
|
||||||
|
|
||||||
Procedure cmdUSER;
|
Procedure cmdUSER;
|
||||||
Procedure cmdPASS;
|
Procedure cmdPASS;
|
||||||
|
@ -67,6 +67,7 @@ Type
|
||||||
Procedure cmdLIST;
|
Procedure cmdLIST;
|
||||||
Procedure cmdPWD;
|
Procedure cmdPWD;
|
||||||
Procedure cmdRETR;
|
Procedure cmdRETR;
|
||||||
|
Procedure cmdSTOR;
|
||||||
Procedure cmdSTRU;
|
Procedure cmdSTRU;
|
||||||
Procedure cmdMODE;
|
Procedure cmdMODE;
|
||||||
Procedure cmdSYST;
|
Procedure cmdSYST;
|
||||||
|
@ -497,14 +498,17 @@ Begin
|
||||||
If LoggedIn Then Begin
|
If LoggedIn Then Begin
|
||||||
If (Data = '/') or (Copy(Data, 1, 2) = '..') Then Begin
|
If (Data = '/') or (Copy(Data, 1, 2) = '..') Then Begin
|
||||||
FBasePos := -1;
|
FBasePos := -1;
|
||||||
|
|
||||||
Client.WriteLine(re_DirOkay + '"/"');
|
Client.WriteLine(re_DirOkay + '"/"');
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
TempPos := FindDirectory(TempBase);
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
If TempPos = -1 Then Begin
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
Client.WriteLine(re_BadDir);
|
Client.WriteLine(re_BadDir);
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -526,10 +530,10 @@ Begin
|
||||||
If LoggedIn Then Begin
|
If LoggedIn Then Begin
|
||||||
TempPos := FindDirectory(TempBase);
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
If TempPos = -1 Then Begin
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
OpenDataSession;
|
OpenDataSession;
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
// list files in root directory, so show nothing
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -608,6 +612,12 @@ Begin
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
If Not ValidDirectory(TempBase) Then Begin
|
||||||
|
Client.WriteLine(re_BadCommand);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
OpenDataSession;
|
OpenDataSession;
|
||||||
|
|
||||||
DirFile := TFileBuffer.Create(FileBufSize);
|
DirFile := TFileBuffer.Create(FileBufSize);
|
||||||
|
@ -633,6 +643,38 @@ Begin
|
||||||
Client.WriteLine(re_BadCommand);
|
Client.WriteLine(re_BadCommand);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Procedure TFTPServer.cmdSTOR;
|
||||||
|
Var
|
||||||
|
TempPos : LongInt;
|
||||||
|
TempBase : RecFileBase;
|
||||||
|
Begin
|
||||||
|
If Not LoggedIn Then Begin
|
||||||
|
Client.WriteLine(re_BadCommand);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
|
TempPos := FindDirectory(TempBase);
|
||||||
|
|
||||||
|
If (TempPos = -1) Or Not ValidDirectory(TempBase) Then Begin
|
||||||
|
Client.WriteLine(re_BadFile);
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Client.WriteLine(re_BadFile);
|
||||||
|
|
||||||
|
//reasons why i haven't finished this (todo):
|
||||||
|
|
||||||
|
// ratios
|
||||||
|
// diskspace
|
||||||
|
// archive testing
|
||||||
|
// file_id.diz importing
|
||||||
|
// forcing uploads to upload base (if non-zero)
|
||||||
|
// duplicate file checking
|
||||||
|
// upload statistic tracking
|
||||||
|
End;
|
||||||
|
|
||||||
Procedure TFTPServer.cmdRETR;
|
Procedure TFTPServer.cmdRETR;
|
||||||
Var
|
Var
|
||||||
TempPos : LongInt;
|
TempPos : LongInt;
|
||||||
|
@ -823,7 +865,7 @@ Begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
If Cmd = 'CDUP' Then cmdCDUP Else
|
If Cmd = 'CDUP' Then cmdCDUP Else
|
||||||
If Cmd = 'CWD' Then cmdCWD Else
|
If Cmd = 'CWD' Then cmdCWD Else
|
||||||
If Cmd = 'EPRT' Then cmdEPRT Else
|
If Cmd = 'EPRT' Then cmdEPRT Else
|
||||||
If Cmd = 'EPSV' Then cmdEPSV Else
|
If Cmd = 'EPSV' Then cmdEPSV Else
|
||||||
If Cmd = 'LIST' Then cmdLIST Else
|
If Cmd = 'LIST' Then cmdLIST Else
|
||||||
|
@ -833,15 +875,16 @@ Begin
|
||||||
If Cmd = 'PASS' Then cmdPASS Else
|
If Cmd = 'PASS' Then cmdPASS Else
|
||||||
If Cmd = 'PASV' Then cmdPASV Else
|
If Cmd = 'PASV' Then cmdPASV Else
|
||||||
If Cmd = 'PORT' Then cmdPORT Else
|
If Cmd = 'PORT' Then cmdPORT Else
|
||||||
If Cmd = 'PWD' Then cmdPWD ELse
|
If Cmd = 'PWD' Then cmdPWD Else
|
||||||
If Cmd = 'REIN' Then cmdREIN Else
|
If Cmd = 'REIN' Then cmdREIN Else
|
||||||
If Cmd = 'RETR' Then cmdRETR Else
|
If Cmd = 'RETR' Then cmdRETR Else
|
||||||
If Cmd = 'SIZE' Then cmdSIZE Else
|
If Cmd = 'SIZE' Then cmdSIZE Else
|
||||||
|
If Cmd = 'STOR' Then cmdSTOR Else
|
||||||
If Cmd = 'STRU' Then cmdSTRU Else
|
If Cmd = 'STRU' Then cmdSTRU Else
|
||||||
If Cmd = 'SYST' Then cmdSYST Else
|
If Cmd = 'SYST' Then cmdSYST Else
|
||||||
If Cmd = 'TYPE' Then cmdTYPE Else
|
If Cmd = 'TYPE' Then cmdTYPE Else
|
||||||
If Cmd = 'USER' Then cmdUSER Else
|
If Cmd = 'USER' Then cmdUSER Else
|
||||||
If Cmd = 'XPWD' Then cmdPWD Else
|
If Cmd = 'XPWD' Then cmdPWD Else
|
||||||
If Cmd = 'QUIT' Then Begin
|
If Cmd = 'QUIT' Then Begin
|
||||||
GotQuit := True;
|
GotQuit := True;
|
||||||
Break;
|
Break;
|
||||||
|
|
Loading…
Reference in New Issue