From 34b6d97be6f963afaaeb173c8656c602524b133f Mon Sep 17 00:00:00 2001 From: hamza zia Date: Sat, 12 Sep 2015 16:55:02 +0800 Subject: [PATCH] added custom aria2 rpc path setting. Fixes #161 --- configuration.js | 1 + index.html | 14 ++++++++++++++ js/services/rpc/jsoncall.js | 4 ++-- js/services/rpc/rpc.js | 7 +++++++ js/services/rpc/sockcall.js | 4 ++-- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/configuration.js b/configuration.js index 46d6019..10fe943 100644 --- a/configuration.js +++ b/configuration.js @@ -5,6 +5,7 @@ angular .constant('$pageSize', 11) // number of downloads shown before pagination kicks in .constant('$authconf', { // default authentication configuration, never fill it in case the webui is hosted in public IP as it can be compromised host: 'localhost', + path: '/jsonrpc', port: 6800, encrypt: false, auth: { // either add the token field or the user and pass field, not both. diff --git a/index.html b/index.html index 6dbb6b4..7ccd623 100755 --- a/index.html +++ b/index.html @@ -944,6 +944,20 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4 --out=file2.mp4 +
+ +
+
+ http(s)://{{connection.conf.host + ':' + connection.conf.port}} + +
+

+ Enter path for the aria2 rpc endpoint (default = /jsonrpc) +

+
+
+
diff --git a/js/services/rpc/jsoncall.js b/js/services/rpc/jsoncall.js index c78c8bd..4642467 100644 --- a/js/services/rpc/jsoncall.js +++ b/js/services/rpc/jsoncall.js @@ -35,7 +35,7 @@ angular var rpc = this; var scheme = rpc.serverConf.encrypt ? 'https' : 'http'; rpc.ariaRequest( - scheme + '://' + rpc.serverConf.host + ':' + rpc.serverConf.port + '/jsonrpc', + scheme + '://' + rpc.serverConf.host + ':' + rpc.serverConf.port + (rpc.serverConf.path || '/jsonrpc'), opts.name, opts.params, opts.success, @@ -51,7 +51,7 @@ angular rpc.serverConf.auth.user + ":" + rpc.serverConf.auth.pass + "@" + rpc.serverConf.host + ':' + - rpc.serverConf.port + '/jsonrpc'; + rpc.serverConf.port + (rpc.serverConf.path || '/jsonrpc'); // hack is to basically inject an image with same uri as the aria2 rpc url, // most browsers will then cache the authentication details and we dont have diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js index 44719ac..758e621 100644 --- a/js/services/rpc/rpc.js +++ b/js/services/rpc/rpc.js @@ -24,8 +24,15 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { console.log(uri.host()); configurations.push({ host: uri.host(), + path: '/jsonrpc', port: 6800, encrypt: false + }, + { + host: uri.host(), + port: uri.port(), + path: '/jsonrpc', + encrypt: ( uri.protocol() == 'https' ) }); console.log(configurations); } diff --git a/js/services/rpc/sockcall.js b/js/services/rpc/sockcall.js index 9e43fca..009224f 100644 --- a/js/services/rpc/sockcall.js +++ b/js/services/rpc/sockcall.js @@ -94,13 +94,13 @@ function(_, JSON, name, utils, alerts) { } try { - var authUrl = sockRPC.scheme + '://' + conf.host + ':' + conf.port + '/jsonrpc'; + var authUrl = sockRPC.scheme + '://' + conf.host + ':' + conf.port + (conf.path || '/jsonrpc'); if (sockRPC.conf.auth && sockRPC.conf.auth.user && sockRPC.conf.auth.pass) { authUrl = sockRPC.scheme + '://' + sockRPC.conf.auth.user + ":" + sockRPC.conf.auth.pass + "@" + sockRPC.conf.host + ':' + - sockRPC.conf.port + '/jsonrpc'; + sockRPC.conf.port + (conf.path || '/jsonrpc'); } sockRPC.sock = new WebSocket(authUrl);