Now assigns random port based on IANI recommendations

This commit is contained in:
mysticbbs 2013-09-07 19:03:24 -04:00
parent ada1c5dfd1
commit 027af16d6f
1 changed files with 8 additions and 4 deletions

View File

@ -15,6 +15,8 @@ Type
DataIP : String; DataIP : String;
DataSocket : TIOSocket; DataSocket : TIOSocket;
IsPassive : Boolean; IsPassive : Boolean;
MinPort : Word;
MaxPort : Word;
Constructor Create (NetI: String); Override; Constructor Create (NetI: String); Override;
Function OpenDataSession : Boolean; Function OpenDataSession : Boolean;
@ -43,7 +45,9 @@ Begin
IsPassive := False; IsPassive := False;
DataIP := ''; DataIP := '';
DataPort := ftpDefaultDataPort; MinPort := 49152;
MaxPort := 65535;
DataPort := Random(MaxPort - MinPort) + MinPort;
End; End;
Function TFTPClient.OpenDataSession : Boolean; Function TFTPClient.OpenDataSession : Boolean;
@ -154,7 +158,7 @@ Begin
End; End;
End Else Begin End Else Begin
IsPassive := False; IsPassive := False;
DataPort := ftpDefaultDataPort; DataPort := Random(MaxPort - MinPort) + MinPort;
Result := SendCommand('PORT ' + strReplace(Client.PeerIP, '.', ',') + ',' + strI2S(WordRec(DataPort).Hi) + ',' + strI2S(WordRec(DataPort).Lo)) = 200; Result := SendCommand('PORT ' + strReplace(Client.PeerIP, '.', ',') + ',' + strI2S(WordRec(DataPort).Hi) + ',' + strI2S(WordRec(DataPort).Lo)) = 200;
End; End;
End; End;