Sha256: 426072c5be2117fc03f89bcf2e4a727243cd827e883ee8f2cc5c3d31aadb32ca

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

require 'dandelion/utils'

module Dandelion
  module Adapter
    class FTPS < Dandelion::Adapter::FTP
      include ::Dandelion::Utils

      adapter 'ftps'
      requires_gems 'double-bag-ftps'

      def initialize(config)
        require 'double_bag_ftps'

        config[:auth_tls] = to_b(config[:auth_tls])
        config[:ftps_implicit] = to_b(config[:ftps_implicit])
        config[:inscecure] = to_b(config[:insecure])

        super(config)
      end

    private

      def ftp_client
        ftps = DoubleBagFTPS.new(@config['host'], nil, nil, nil, ftps_mode, {})

        if @config['insecure']
          ftps.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE)
        end

        ftps.login(@config['username'], @config['password'], nil, ftps_auth)
        ftps.passive = @config[:passive]

        ftps
      end

      def ftps_auth
        @config['auth_tls'] ? 'TLS' : nil
      end

      def ftps_mode
        @config['ftps_implicit'] ? DoubleBagFTPS::IMPLICIT : DoubleBagFTPS::EXPLICIT
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dandelion-0.5.4 lib/dandelion/adapter/ftps.rb
dandelion-0.5.3 lib/dandelion/adapter/ftps.rb
dandelion-0.5.2 lib/dandelion/adapter/ftps.rb
dandelion-0.5.1 lib/dandelion/adapter/ftps.rb
dandelion-0.5.0 lib/dandelion/adapter/ftps.rb
dandelion-0.4.17 lib/dandelion/adapter/ftps.rb
dandelion-0.4.16 lib/dandelion/adapter/ftps.rb
dandelion-0.4.15 lib/dandelion/adapter/ftps.rb
dandelion-0.4.14 lib/dandelion/adapter/ftps.rb
dandelion-0.4.10 lib/dandelion/adapter/ftps.rb
dandelion-0.4.9 lib/dandelion/adapter/ftps.rb
dandelion-0.4.8 lib/dandelion/adapter/ftps.rb
dandelion-0.4.7 lib/dandelion/adapter/ftps.rb