http authentication hack added for JSONP !!!!

This commit is contained in:
Hamza Zia 2012-06-06 14:17:55 +08:00
parent 7b8cdc9d6b
commit b1f297aa7b
2 changed files with 36 additions and 4 deletions

View File

@ -182,6 +182,16 @@
<input type="text" class="input-xlarge" placeholder="6800" id="input_port"/>
<p class="help-block">Enter the port of the server on which the rpc for aria2 is running (default = 6800)</p>
</div>
<label class="control-label" for="input_user">Enter the username (optional):</label>
<div class="controls">
<input type="text" class="input-xlarge" id="input_user"/>
<p class="help-block">Enter the username of the server on which the rpc for aria2 is running (empty if authentication not enabled)</p>
</div>
<label class="control-label" for="input_pass">Enter the password (optional):</label>
<div class="controls">
<input type="text" class="input-xlarge" id="input_pass"/>
<p class="help-block">Enter the password of the server on which the rpc for aria2 is running (empty if authentication not enabled)</p>
</div>
</div>
</fieldset>
</form>

View File

@ -11,15 +11,26 @@ var clear_dialogs = function() {
};
var server_conf = {
host: 'localhost',
port: 6800
port: 6800,
user: "",
pass: ""
};
var custom_aria2_connect = function() {
modals.err_connect.modal('hide');
modals.change_conf.modal('show');
};
var update_server_conf = function() {
server_conf.host = $('#input_host').val();
server_conf.port = $('#input_port').val();
var host = $('#input_host').val().trim();
var port = $('#input_port').val().trim();
server_conf.user = $('#input_user').val().trim();
server_conf.pass = $('#input_pass').val().trim();
if(host.length !== 0) {
server_conf.host = host;
}
if(port.length !== 0) {
server_conf.port = port;
}
clear_dialogs();
update_ui();
};
@ -31,8 +42,19 @@ function param_encode(param) {
return param;
}
var aria_syscall = function(conf, multicall) {
var url = "";
if(server_conf.user.length) {
url = 'http://' +
server_conf.user + ":" +
server_conf.pass + "@" +
server_conf.host + ':' +
server_conf.port + '/jsonrpc';
}
else {
url = 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc';
}
$.ajax({
url: 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc',
url: url,
timeout: 1000,
data: {
jsonrpc: 2.0,