Class: Aspera::Fasp::Uri
- Inherits:
-
Object
- Object
- Aspera::Fasp::Uri
- Defined in:
- lib/aspera/fasp/uri.rb
Overview
translates a “faspe:” URI (used in Faspex 4) into transfer spec hash
Instance Method Summary collapse
-
#initialize(fasp_link) ⇒ Uri
constructor
A new instance of Uri.
- #transfer_spec ⇒ Object
Constructor Details
Instance Method Details
#transfer_spec ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aspera/fasp/uri.rb', line 17 def transfer_spec result_ts = {} result_ts['remote_host'] = @fasp_uri.host result_ts['remote_user'] = @fasp_uri.user result_ts['ssh_port'] = @fasp_uri.port result_ts['paths'] = [{'source' => URI.decode_www_form_component(@fasp_uri.path)}] # faspex does not encode trailing base64 padding, fix that to be able to decode properly fixed_query = @fasp_uri.query.gsub(/(=+)$/){|x|'%3D' * x.length} URI.decode_www_form(fixed_query).each do |i| name = i[0] value = i[1] case name when 'cookie' then result_ts['cookie'] = value when 'token' then result_ts['token'] = value when 'sshfp' then result_ts['sshfp'] = value when 'policy' then result_ts['rate_policy'] = value when 'httpport' then result_ts['http_fallback_port'] = value.to_i when 'targetrate' then result_ts['target_rate_kbps'] = value.to_i when 'minrate' then result_ts['min_rate_kbps'] = value.to_i when 'port' then result_ts['fasp_port'] = value.to_i when 'bwcap' then result_ts['target_rate_cap_kbps'] = value.to_i when 'enc' then result_ts['cipher'] = value.gsub(/^aes/, 'aes-').gsub(/cfb$/, '-cfb').gsub(/gcm$/, '-gcm').gsub(/--/, '-') when 'tags64' then result_ts['tags'] = JSON.parse(Base64.strict_decode64(value)) when 'createpath' then result_ts['create_dir'] = CommandLineBuilder.yes_to_true(value) when 'fallback' then result_ts['http_fallback'] = CommandLineBuilder.yes_to_true(value) when 'lockpolicy' then result_ts['lock_rate_policy'] = CommandLineBuilder.yes_to_true(value) when 'lockminrate' then result_ts['lock_min_rate'] = CommandLineBuilder.yes_to_true(value) when 'auth' then Log.log.debug{"ignoring #{name}=#{value}"} # Not used (yes/no) when 'v' then Log.log.debug{"ignoring #{name}=#{value}"} # rubocop:disable Lint/DuplicateBranch Not used (2) when 'protect' then Log.log.debug{"ignoring #{name}=#{value}"} # rubocop:disable Lint/DuplicateBranch TODO: what is this ? else Log.log.warn{"URI parameter ignored: #{name} = #{value}"} end end return result_ts end |