aspera-cli 4.5.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -0
- data/README.md +1894 -1574
- data/bin/ascli +21 -1
- data/bin/asession +38 -34
- data/docs/test_env.conf +14 -3
- data/examples/aoc.rb +17 -15
- data/examples/dascli +26 -0
- data/examples/faspex4.rb +42 -35
- data/examples/proxy.pac +1 -1
- data/examples/transfer.rb +38 -37
- data/lib/aspera/aoc.rb +245 -205
- data/lib/aspera/ascmd.rb +111 -90
- data/lib/aspera/ats_api.rb +16 -14
- data/lib/aspera/cli/basic_auth_plugin.rb +19 -18
- data/lib/aspera/cli/extended_value.rb +50 -39
- data/lib/aspera/cli/formater.rb +161 -135
- data/lib/aspera/cli/info.rb +18 -0
- data/lib/aspera/cli/listener/line_dump.rb +4 -2
- data/lib/aspera/cli/listener/logger.rb +3 -1
- data/lib/aspera/cli/listener/progress.rb +20 -21
- data/lib/aspera/cli/listener/progress_multi.rb +29 -31
- data/lib/aspera/cli/main.rb +194 -183
- data/lib/aspera/cli/manager.rb +213 -206
- data/lib/aspera/cli/plugin.rb +71 -49
- data/lib/aspera/cli/plugins/alee.rb +8 -7
- data/lib/aspera/cli/plugins/aoc.rb +675 -558
- data/lib/aspera/cli/plugins/ats.rb +116 -109
- data/lib/aspera/cli/plugins/bss.rb +35 -34
- data/lib/aspera/cli/plugins/config.rb +722 -542
- data/lib/aspera/cli/plugins/console.rb +28 -22
- data/lib/aspera/cli/plugins/cos.rb +28 -37
- data/lib/aspera/cli/plugins/faspex.rb +281 -227
- data/lib/aspera/cli/plugins/faspex5.rb +129 -84
- data/lib/aspera/cli/plugins/node.rb +426 -232
- data/lib/aspera/cli/plugins/orchestrator.rb +106 -98
- data/lib/aspera/cli/plugins/preview.rb +196 -191
- data/lib/aspera/cli/plugins/server.rb +131 -126
- data/lib/aspera/cli/plugins/shares.rb +49 -36
- data/lib/aspera/cli/plugins/sync.rb +27 -28
- data/lib/aspera/cli/transfer_agent.rb +84 -79
- data/lib/aspera/cli/version.rb +3 -1
- data/lib/aspera/colors.rb +37 -28
- data/lib/aspera/command_line_builder.rb +84 -63
- data/lib/aspera/cos_node.rb +68 -34
- data/lib/aspera/data_repository.rb +4 -2
- data/lib/aspera/environment.rb +61 -46
- data/lib/aspera/fasp/agent_base.rb +36 -31
- data/lib/aspera/fasp/agent_connect.rb +44 -37
- data/lib/aspera/fasp/agent_direct.rb +101 -104
- data/lib/aspera/fasp/agent_httpgw.rb +91 -90
- data/lib/aspera/fasp/agent_node.rb +36 -33
- data/lib/aspera/fasp/agent_trsdk.rb +28 -31
- data/lib/aspera/fasp/error.rb +3 -1
- data/lib/aspera/fasp/error_info.rb +81 -54
- data/lib/aspera/fasp/installation.rb +171 -151
- data/lib/aspera/fasp/listener.rb +2 -0
- data/lib/aspera/fasp/parameters.rb +105 -111
- data/lib/aspera/fasp/parameters.yaml +305 -249
- data/lib/aspera/fasp/resume_policy.rb +20 -20
- data/lib/aspera/fasp/transfer_spec.rb +27 -0
- data/lib/aspera/fasp/uri.rb +31 -29
- data/lib/aspera/faspex_gw.rb +95 -118
- data/lib/aspera/hash_ext.rb +12 -13
- data/lib/aspera/id_generator.rb +11 -9
- data/lib/aspera/keychain/encrypted_hash.rb +73 -57
- data/lib/aspera/keychain/macos_security.rb +27 -29
- data/lib/aspera/log.rb +40 -39
- data/lib/aspera/nagios.rb +24 -22
- data/lib/aspera/node.rb +38 -30
- data/lib/aspera/oauth.rb +217 -248
- data/lib/aspera/open_application.rb +9 -7
- data/lib/aspera/persistency_action_once.rb +15 -14
- data/lib/aspera/persistency_folder.rb +15 -18
- data/lib/aspera/preview/file_types.rb +266 -270
- data/lib/aspera/preview/generator.rb +94 -92
- data/lib/aspera/preview/image_error.png +0 -0
- data/lib/aspera/preview/options.rb +20 -17
- data/lib/aspera/preview/utils.rb +99 -102
- data/lib/aspera/preview/video_error.png +0 -0
- data/lib/aspera/{proxy_auto_config.erb.js → proxy_auto_config.js} +23 -31
- data/lib/aspera/proxy_auto_config.rb +114 -21
- data/lib/aspera/rest.rb +144 -142
- data/lib/aspera/rest_call_error.rb +3 -2
- data/lib/aspera/rest_error_analyzer.rb +31 -31
- data/lib/aspera/rest_errors_aspera.rb +18 -16
- data/lib/aspera/secret_hider.rb +68 -0
- data/lib/aspera/ssh.rb +20 -16
- data/lib/aspera/sync.rb +57 -54
- data/lib/aspera/temp_file_manager.rb +20 -14
- data/lib/aspera/timer_limiter.rb +10 -8
- data/lib/aspera/uri_reader.rb +14 -15
- data/lib/aspera/web_auth.rb +85 -80
- data.tar.gz.sig +0 -0
- metadata +169 -40
- metadata.gz.sig +2 -0
- data/bin/dascli +0 -13
- data/docs/Makefile +0 -63
- data/docs/README.erb.md +0 -4221
- data/docs/README.md +0 -13
- data/docs/diagrams.txt +0 -49
- data/docs/doc_tools.rb +0 -58
- data/lib/aspera/cli/plugins/shares2.rb +0 -114
- data/lib/aspera/fasp/default.rb +0 -17
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
// inspired by PACSuppport.js, 2003-2004 by Apple Computer, Inc., all rights reserved
|
|
2
|
-
function dnsResolve(host) {
|
|
3
|
-
if (host == '<%=context_host%>' || host == '<%=context_ip%>')
|
|
4
|
-
return '<%=context_ip%>';
|
|
5
|
-
throw 'only DNS for initial host, not '+host;
|
|
6
|
-
}
|
|
7
|
-
function myIpAddress() {
|
|
8
|
-
return '<%=context_self%>';
|
|
9
|
-
}
|
|
10
2
|
function isPlainHostName(host) {
|
|
11
3
|
return (host.indexOf('.') == -1 ? true : false);
|
|
12
4
|
}
|
|
13
|
-
function dnsDomainIs(host, domain) {
|
|
5
|
+
function dnsDomainIs(host, domain) {
|
|
14
6
|
var h = host.toLowerCase();
|
|
15
7
|
var d = domain.toLowerCase();
|
|
16
8
|
var sub = h.substring(h.length - d.length, h.length);
|
|
@@ -35,7 +27,7 @@ function isInNet(host, pattern, mask) {
|
|
|
35
27
|
var a = ip.split('.');
|
|
36
28
|
if ((p.length == m.length) && (m.length == a.length)) {
|
|
37
29
|
for (i = 0; i < p.length; i++) {
|
|
38
|
-
if ((p[i]& m[i]) != (m[i]& a[i]))
|
|
30
|
+
if ((p[i] & m[i]) != (m[i] & a[i]))
|
|
39
31
|
return false;
|
|
40
32
|
}
|
|
41
33
|
return true;
|
|
@@ -108,7 +100,7 @@ function dateRange() {
|
|
|
108
100
|
var today = new Date();
|
|
109
101
|
var num = arguments.length;
|
|
110
102
|
var gmt = arguments[num - 1];
|
|
111
|
-
if (typeof gmt !=
|
|
103
|
+
if (typeof gmt != "string")
|
|
112
104
|
gmt = false;
|
|
113
105
|
else {
|
|
114
106
|
gmt = gmt.toUpperCase();
|
|
@@ -137,8 +129,7 @@ function dateRange() {
|
|
|
137
129
|
y2 = arg;
|
|
138
130
|
else
|
|
139
131
|
return false;
|
|
140
|
-
}
|
|
141
|
-
else if (!arg)
|
|
132
|
+
} else if (!arg)
|
|
142
133
|
return false;
|
|
143
134
|
else if (!d1)
|
|
144
135
|
d1 = arg;
|
|
@@ -146,13 +137,12 @@ function dateRange() {
|
|
|
146
137
|
d2 = arg;
|
|
147
138
|
else
|
|
148
139
|
return false;
|
|
149
|
-
}
|
|
150
|
-
else if (typeof arg == "string") {
|
|
140
|
+
} else if (typeof arg == "string") {
|
|
151
141
|
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
|
|
152
142
|
arg = arg.toUpperCase();
|
|
153
143
|
arg = months.indexOf(arg);
|
|
154
144
|
if (arg == -1)
|
|
155
|
-
return false;
|
|
145
|
+
return false;
|
|
156
146
|
arg /= 3;
|
|
157
147
|
arg += 1;
|
|
158
148
|
if (!m1)
|
|
@@ -161,23 +151,27 @@ function dateRange() {
|
|
|
161
151
|
m2 = arg;
|
|
162
152
|
else
|
|
163
153
|
return false;
|
|
164
|
-
}
|
|
165
|
-
else
|
|
154
|
+
} else
|
|
166
155
|
return false;
|
|
167
156
|
}
|
|
168
|
-
if (!y1)
|
|
169
|
-
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
if (!
|
|
173
|
-
|
|
157
|
+
if (!y1)
|
|
158
|
+
y1 = gmt ? today.getUTCFullYear() : today.getFullYear();
|
|
159
|
+
if (!y2)
|
|
160
|
+
y2 = y1;
|
|
161
|
+
if (!m1)
|
|
162
|
+
m1 = (gmt ? today.getUTCMonth() : today.getMonth()) + 1;
|
|
163
|
+
if (!m2)
|
|
164
|
+
m2 = m1;
|
|
165
|
+
if (!d1)
|
|
166
|
+
d1 = gmt ? today.getUTCDate() : today.getDate();
|
|
167
|
+
if (!d2)
|
|
168
|
+
d2 = d1;
|
|
174
169
|
var date1;
|
|
175
170
|
var date2;
|
|
176
171
|
if (gmt) {
|
|
177
172
|
date1 = Date.UTC(y1, m1 - 1, d1, 0, 0, 0, 0);
|
|
178
173
|
date2 = Date.UTC(y2, m2 - 1, d2, 23, 59, 59, 999);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
174
|
+
} else {
|
|
181
175
|
date1 = (Date(y1, m1 - 1, d1, 0, 0, 0, 0)).valueOf();
|
|
182
176
|
date2 = (Date(y2, m2 - 1, d2, 23, 59, 59, 999)).valueOf();
|
|
183
177
|
}
|
|
@@ -190,7 +184,7 @@ function timeRange() {
|
|
|
190
184
|
var date2 = new Date();
|
|
191
185
|
var num = arguments.length;
|
|
192
186
|
var gmt = arguments[num - 1];
|
|
193
|
-
if (typeof gmt !=
|
|
187
|
+
if (typeof gmt != "string")
|
|
194
188
|
gmt = false;
|
|
195
189
|
else {
|
|
196
190
|
gmt = gmt.toUpperCase();
|
|
@@ -226,8 +220,7 @@ function timeRange() {
|
|
|
226
220
|
date2.setUTCSeconds(arg);
|
|
227
221
|
break;
|
|
228
222
|
}
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
223
|
+
} else {
|
|
231
224
|
switch (i) {
|
|
232
225
|
case 0:
|
|
233
226
|
date1.setHours(arg);
|
|
@@ -262,8 +255,7 @@ function timeRange() {
|
|
|
262
255
|
date2.setUTCSeconds(arg);
|
|
263
256
|
break;
|
|
264
257
|
}
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
258
|
+
} else {
|
|
267
259
|
switch (i) {
|
|
268
260
|
case 0:
|
|
269
261
|
date2.setHours(arg);
|
|
@@ -1,34 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'uri'
|
|
2
4
|
require 'resolv'
|
|
3
|
-
|
|
5
|
+
|
|
6
|
+
module URI
|
|
7
|
+
class Generic
|
|
8
|
+
# save original method that finds proxy in URI::Generic, it uses env var http_proxy
|
|
9
|
+
alias_method :find_proxy_orig, :find_proxy
|
|
10
|
+
def self.register_proxy_finder
|
|
11
|
+
raise 'mandatory block missing' unless Kernel.block_given?
|
|
12
|
+
# overload the method in URI : call user's provided block and fallback to original method
|
|
13
|
+
define_method(:find_proxy) {|envars=ENV| yield(to_s) || find_proxy_orig(envars)}
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
4
17
|
|
|
5
18
|
module Aspera
|
|
6
|
-
#
|
|
19
|
+
# Evaluate a proxy autoconfig script
|
|
7
20
|
class ProxyAutoConfig
|
|
8
21
|
# template file is read once, it contains functions that can be used in a proxy autoconf script
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
# it is similar to mozilla ascii_pac_utils.inc
|
|
23
|
+
PAC_FUNCTIONS_FILE = __FILE__.gsub(/\.rb$/,'.js').freeze
|
|
24
|
+
PAC_MAIN_FUNCTION = 'FindProxyForURL'
|
|
25
|
+
private_constant :PAC_FUNCTIONS_FILE,:PAC_MAIN_FUNCTION
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
# variables starting with "context_" are replaced in the ERB template file
|
|
30
|
+
# I did not find an easy way for the javascript to callback ruby
|
|
31
|
+
# and anyway, it only needs to get DNS translation
|
|
32
|
+
def pac_dns_functions(context_host)
|
|
33
|
+
context_self = '127.0.0.1'
|
|
34
|
+
context_ip = nil
|
|
35
|
+
Resolv::DNS.open{|dns|dns.each_address(context_host){|r_addr|context_ip = r_addr.to_s if r_addr.is_a?(Resolv::IPv4)}}
|
|
36
|
+
raise "DNS name not found: #{context_host}" if context_ip.nil?
|
|
37
|
+
# NOTE: Javascript code here with string inclusions
|
|
38
|
+
javascript = <<END_OF_JAVASCRIPT
|
|
39
|
+
function dnsResolve(host) {
|
|
40
|
+
if (host == '#{context_host}' || host == '#{context_ip}')
|
|
41
|
+
return '#{context_ip}';
|
|
42
|
+
throw 'only DNS for initial host, not ' + host;
|
|
43
|
+
}
|
|
44
|
+
function myIpAddress() {
|
|
45
|
+
return '#{context_self}';
|
|
46
|
+
}
|
|
47
|
+
END_OF_JAVASCRIPT
|
|
48
|
+
return javascript
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
public
|
|
52
|
+
|
|
11
53
|
# @param proxy_auto_config the proxy auto config script to be evaluated
|
|
12
54
|
def initialize(proxy_auto_config)
|
|
13
|
-
|
|
55
|
+
# user provided javascript with FindProxyForURL function
|
|
56
|
+
@proxy_auto_config = proxy_auto_config
|
|
57
|
+
# avoid multiple execution, this does not support load balancing
|
|
58
|
+
@cache = {}
|
|
59
|
+
@pac_functions = nil
|
|
14
60
|
end
|
|
15
61
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
def register_uri_generic
|
|
63
|
+
URI::Generic.register_proxy_finder{|url_str|get_proxies(url_str).first}
|
|
64
|
+
# allow chaining
|
|
65
|
+
return self
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# execute proxy auto config script for the given URL : https://en.wikipedia.org/wiki/Proxy_auto-config
|
|
69
|
+
# @return either nil, or a String formated following PAC standard
|
|
70
|
+
def find_proxy_for_url(service_url)
|
|
71
|
+
uri = URI.parse(service_url)
|
|
72
|
+
simple_url = "#{uri.scheme}://#{uri.host}"
|
|
73
|
+
if !@cache.has_key?(simple_url)
|
|
74
|
+
Log.log.debug("PAC: starting javascript for #{service_url}")
|
|
75
|
+
# require at runtime, in case there is no js engine
|
|
76
|
+
require 'execjs'
|
|
77
|
+
# read template lib
|
|
78
|
+
@pac_functions = File.read(PAC_FUNCTIONS_FILE).freeze if @pac_functions.nil?
|
|
79
|
+
# to be executed is dns + utils + user function
|
|
80
|
+
js_to_execute = "#{pac_dns_functions(uri.host)}#{@pac_functions}#{@proxy_auto_config}"
|
|
81
|
+
executable_js = ExecJS.compile(js_to_execute)
|
|
82
|
+
@cache[simple_url] = executable_js.call(PAC_MAIN_FUNCTION, simple_url, uri.host)
|
|
83
|
+
Log.log.debug("PAC: result: #{@cache[simple_url]}")
|
|
84
|
+
end
|
|
85
|
+
return @cache[simple_url]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# used to replace URI::Generic.find_proxy
|
|
89
|
+
# @return Array of URI, possibly empty
|
|
90
|
+
def get_proxies(service_url)
|
|
91
|
+
# prepare result
|
|
92
|
+
uri_list = []
|
|
93
|
+
# execute PAC script
|
|
94
|
+
proxy_list_str = find_proxy_for_url(service_url)
|
|
95
|
+
if !proxy_list_str.is_a?(String)
|
|
96
|
+
Log.log.warn("PAC: did not return a String, returned #{proxy_list_str.class}")
|
|
97
|
+
return uri_list
|
|
98
|
+
end
|
|
99
|
+
proxy_list_str.strip!
|
|
100
|
+
proxy_list_str.gsub!(/\s+/,' ')
|
|
101
|
+
proxy_list_str.split(';').each do |item|
|
|
102
|
+
# strip and split by space
|
|
103
|
+
parts = item.strip.split
|
|
104
|
+
case parts.shift
|
|
105
|
+
when 'DIRECT'
|
|
106
|
+
raise 'DIRECT has no param' unless parts.empty?
|
|
107
|
+
when 'PROXY'
|
|
108
|
+
addr_port = parts.shift
|
|
109
|
+
raise 'PROXY shall have one param' unless addr_port.is_a?(String) && parts.empty?
|
|
110
|
+
begin
|
|
111
|
+
# PAC proxy addresses are <host>:<port>
|
|
112
|
+
if /:[0-9]+$/.match?(addr_port)
|
|
113
|
+
# we want to return URIs, so add dummy scheme
|
|
114
|
+
uri_list.push(URI.parse("proxy://#{addr_port}"))
|
|
115
|
+
else
|
|
116
|
+
Log.log.warn("PAC: PROXY must be <address>:<port>, ignoring #{addr_port}")
|
|
117
|
+
end
|
|
118
|
+
rescue StandardError
|
|
119
|
+
Log.log.warn("PAC: cannot parse #{addr_port}")
|
|
120
|
+
end
|
|
121
|
+
else Log.log.warn("PAC: ignoring proxy type #{parts.first}: not supported")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
return uri_list
|
|
31
125
|
end
|
|
32
126
|
end
|
|
33
127
|
end
|
|
34
|
-
|