Sha256: 89e6b56a0a469175d079d12938b852cf7f850b42b2eecdf5c08db777bb472444

Contents?: true

Size: 776 Bytes

Versions: 7

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

require_relative 'command_handler'

module Ftpd

  class CmdProt < CommandHandler

    def cmd_prot(level_arg)
      level_code = level_arg.upcase
      unless protection_buffer_size_set
        error "PROT must be preceded by PBSZ", 503
      end
      level = DATA_CHANNEL_PROTECTION_LEVELS[level_code]
      unless level
        error "Unknown protection level", 504
      end
      unless level == :private
        error "Unsupported protection level #{level}", 536
      end
      self.data_channel_protection_level = level
      reply "200 Data protection level #{level_code}"
    end

    private

    DATA_CHANNEL_PROTECTION_LEVELS = {
      'C'=>:clear,
      'S'=>:safe,
      'E'=>:confidential,
      'P'=>:private
    }

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ftpd-2.1.0 lib/ftpd/cmd_prot.rb
ftpd-2.0.5 lib/ftpd/cmd_prot.rb
ftpd-2.0.4 lib/ftpd/cmd_prot.rb
ftpd-2.0.3 lib/ftpd/cmd_prot.rb
ftpd-2.0.2 lib/ftpd/cmd_prot.rb
ftpd-2.0.1 lib/ftpd/cmd_prot.rb
ftpd-2.0.0 lib/ftpd/cmd_prot.rb