private HashPassword ( string password ) : byte[] | ||
password | string | |
Результат | byte[] |
/// <summary> /// Connect to FileZilla admin interface /// </summary> /// <param name="password">FileZilla admin password</param> public void Connect(string password) { Authentication authentication = null; Connect(); Receive(reader => { try { reader.Verify("FZS"); } catch (ProtocolException ex) { throw new ApiException("That's not a FileZilla server listening on that port.", ex); } ServerVersion = reader.ReadLength(reader.ReadBigEndianInt16(), x => x.ReadInt32()); ProtocolVersion = reader.ReadLength(reader.ReadBigEndianInt16(), x => x.ReadInt32()); // Verify protocol version if (!SupportedProtocolVersions.Contains(ProtocolVersion)) { if (ProtocolVersion < ProtocolVersions.Initial) { throw new ApiException("FileZilla server is too old. Install FileZilla Server 0.9.43 or later"); } throw new ApiException( string.Format( "Unsupported FileZilla protocol version:{0} server version:{1} (API version: {2}). Please report issue at https://github.com/PolarbearDK/Miracle.FileZilla.Api.", FormatVersion(ProtocolVersion), FormatVersion(ServerVersion), Assembly.GetExecutingAssembly().GetName().Version)); } authentication = reader.Read <Authentication>(ProtocolVersion); }); if (!authentication.NoPasswordRequired) { SendCommand(MessageType.Authenticate, authentication.HashPassword(password)); Receive(MessageType.Authenticate); } }
/// <summary> /// Connect to FileZilla admin console /// </summary> /// <param name="password">FileZilla admin password</param> public void Connect(string password) { Authentication authentication = null; Connect(); Receive(reader => { reader.Verify("FZS"); ServerVersion = reader.ReadShortLength(x => x.ReadInt32()); ProtocolVersion = reader.ReadShortLength(x => x.ReadInt32()); authentication = reader.BaseStream.Length > 15 ? reader.Read <Authentication>() : null; }); if (authentication != null) { Authenticate(authentication.HashPassword(password)); } }