Implement --rpc-secret support
This commit is contained in:
parent
e733e0043d
commit
cea5f8bd12
10
index.html
10
index.html
|
@ -754,6 +754,16 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
<p class="help-block">Enable SSL/TLS encryption.</p>
|
<p class="help-block">Enable SSL/TLS encryption.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<label class="control-label">Enter the secret token (optional):</label>
|
||||||
|
<div class="controls">
|
||||||
|
<label>
|
||||||
|
<input type="text" class="input-xlarge" ng-model="connection.conf.auth.token"/>
|
||||||
|
<p class="help-block">
|
||||||
|
Enter the aria2 RPC secret token (leave empty if authentication is not enabled)>
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label class="control-label">Enter the username (optional):</label>
|
<label class="control-label">Enter the username (optional):</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xlarge"
|
<input type="text" class="input-xlarge"
|
||||||
|
|
|
@ -24,7 +24,7 @@ angular
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
conn.avgTimeout = 2000 + 3 * (new Date() - startTime);
|
conn.avgTimeout = 2000 + 3 * (new Date() - startTime);
|
||||||
return success(data)
|
return success(data);
|
||||||
},
|
},
|
||||||
error: error,
|
error: error,
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
|
@ -42,7 +42,7 @@ angular
|
||||||
function() {
|
function() {
|
||||||
// check if authentication details are given, if yes then use a hack to support
|
// check if authentication details are given, if yes then use a hack to support
|
||||||
// http authentication otherwise emit error
|
// http authentication otherwise emit error
|
||||||
if (!rpc.serverConf.auth) {
|
if (!rpc.serverConf.auth || !rpc.serverConf.auth.user) {
|
||||||
console.log("jsonrpc disconnect!!!");
|
console.log("jsonrpc disconnect!!!");
|
||||||
return opts.error();
|
return opts.error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ function(syscall, time, alerts, utils, rootScope, uri) {
|
||||||
var subscriptions = []
|
var subscriptions = []
|
||||||
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
|
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
|
||||||
, currentConf = {}
|
, currentConf = {}
|
||||||
|
, currentToken
|
||||||
, timeout = null
|
, timeout = null
|
||||||
, forceNextUpdate = false;
|
, forceNextUpdate = false;
|
||||||
|
|
||||||
|
@ -49,21 +50,51 @@ function(syscall, time, alerts, utils, rootScope, uri) {
|
||||||
|
|
||||||
if (configurations.length) {
|
if (configurations.length) {
|
||||||
currentConf = configurations.shift();
|
currentConf = configurations.shift();
|
||||||
|
if (currentConf && currentConf.auth && currentConf.auth.token) {
|
||||||
|
currentToken = currentConf.auth.token;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentToken = null;
|
||||||
|
}
|
||||||
syscall.init(currentConf);
|
syscall.init(currentConf);
|
||||||
}
|
}
|
||||||
|
|
||||||
var params = _.map(subs, function(s) {
|
var params = _.map(subs, function(s) {
|
||||||
|
var p = s.params;
|
||||||
|
if (currentToken) {
|
||||||
|
p = ["token:" + currentToken].concat(p || []);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
methodName: s.name,
|
methodName: s.name,
|
||||||
params: s.params && s.params.length ? s.params : undefined
|
params: p && p.length ? p : undefined
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var error = function() {
|
||||||
|
// If some proposed configurations are still in the pipeline then retry
|
||||||
|
if (configurations.length) {
|
||||||
|
alerts.log("The last connection attempt was unsuccessful. Trying another configuration");
|
||||||
|
timeout = setTimeout(update, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alerts.addAlert('<strong>Oh Snap!</strong> Could not connect to the aria2 RPC server. Will retry in ' + time / 1000 + ' secs. You might want to check the connection settings by going to Settings > Connection Settings', 'error');
|
||||||
|
timeout = setTimeout(update, time);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
syscall.invoke({
|
syscall.invoke({
|
||||||
name: 'system.multicall',
|
name: 'system.multicall',
|
||||||
params: [params],
|
params: [params],
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
|
||||||
|
var failed = _.any(data.result, function(d) {
|
||||||
|
return d.code && d.message === "Unauthorized";
|
||||||
|
});
|
||||||
|
if (failed) {
|
||||||
|
error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (configurations.length) {
|
if (configurations.length) {
|
||||||
// configuration worked, save it in cookie for next time and
|
// configuration worked, save it in cookie for next time and
|
||||||
// delete the pipelined configurations!!
|
// delete the pipelined configurations!!
|
||||||
|
@ -104,17 +135,7 @@ function(syscall, time, alerts, utils, rootScope, uri) {
|
||||||
timeout = setTimeout(update, time);
|
timeout = setTimeout(update, time);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: error
|
||||||
// If some proposed configurations are still in the pipeline then retry
|
|
||||||
if (configurations.length) {
|
|
||||||
alerts.log("The last connection attempt was unsuccessful. Trying another configuration");
|
|
||||||
timeout = setTimeout(update, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
alerts.addAlert('<strong>Oh Snap!</strong> Could not connect to the aria2 RPC server. Will retry in ' + time / 1000 + ' secs. You might want to check the connection settings by going to Settings > Connection Settings', 'error');
|
|
||||||
timeout = setTimeout(update, time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ function(log, jsonRPC, sockRPC, alerts) {
|
||||||
// port (number): port number for the aria2 server
|
// port (number): port number for the aria2 server
|
||||||
// encrypt (boolean, optional): true if encryption is enabled in the aria2 server
|
// encrypt (boolean, optional): true if encryption is enabled in the aria2 server
|
||||||
// auth (optional): {
|
// auth (optional): {
|
||||||
|
// token (string): secret token for authentication (--rpc-secret)
|
||||||
// user (string): username for http authentication if enabled
|
// user (string): username for http authentication if enabled
|
||||||
// pass (string): password for the http authentication if enabled
|
// pass (string): password for the http authentication if enabled
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user