mirror of https://github.com/aria2/aria2
aria2mon: Add --secret option
parent
a1ce6d2e7f
commit
a9fe783484
|
@ -32,6 +32,7 @@ OptionParser.new do |opt|
|
||||||
|
|
||||||
opt.on("--user USERNAME", "XML-RPC username"){|val| options["user"]=val }
|
opt.on("--user USERNAME", "XML-RPC username"){|val| options["user"]=val }
|
||||||
opt.on("--passwd PASSWORD", "XML-RPC password"){|val| options["passwd"]=val }
|
opt.on("--passwd PASSWORD", "XML-RPC password"){|val| options["passwd"]=val }
|
||||||
|
opt.on("--secret SECRET", "XML-RPC secret authorization token"){|val| options["secret"]=val }
|
||||||
|
|
||||||
opt.banner=<<EOS
|
opt.banner=<<EOS
|
||||||
Usage: #{program_name} [options]
|
Usage: #{program_name} [options]
|
||||||
|
@ -77,6 +78,7 @@ end
|
||||||
if not options.has_key?("port") then
|
if not options.has_key?("port") then
|
||||||
options["port"]="6800"
|
options["port"]="6800"
|
||||||
end
|
end
|
||||||
|
secret = if options.has_key?("secret") then "token:"+options["secret"] else nil end
|
||||||
|
|
||||||
client=XMLRPC::Client.new3({:host => options["server"],
|
client=XMLRPC::Client.new3({:host => options["server"],
|
||||||
:port => options["port"],
|
:port => options["port"],
|
||||||
|
@ -88,8 +90,17 @@ options.delete("server")
|
||||||
options.delete("port")
|
options.delete("port")
|
||||||
options.delete("user")
|
options.delete("user")
|
||||||
options.delete("passwd")
|
options.delete("passwd")
|
||||||
|
options.delete("secret")
|
||||||
|
|
||||||
result=client.call("aria2.tellActive")
|
def client_call client, secret, method, *params
|
||||||
|
if secret.nil?
|
||||||
|
client.call(method, *params)
|
||||||
|
else
|
||||||
|
client.call(method, secret, *params)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result=client_call(client, secret, "aria2.tellActive")
|
||||||
|
|
||||||
print "-- Download Progress --\n"
|
print "-- Download Progress --\n"
|
||||||
result.each { |entry|
|
result.each { |entry|
|
||||||
|
|
Loading…
Reference in New Issue