@@ -120,15 +120,19 @@
diff --git a/manifest.json b/manifest.json
index a09a028..8f3838f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -51,6 +51,7 @@
"scripts": [
"config.js",
"i2pcontrol/i2pcontrol.js",
+ "torrent/torrent.js",
"host.js",
"privacy.js",
"platform.js",
@@ -69,11 +70,6 @@
"name": "RouterConsole",
"uriTemplate": "http://127.0.0.1:7657/%s"
},
- {
- "protocol": "ext+dati2p",
- "name": "Dat over I2P",
- "uriTemplate": "/dat.html#!/%s"
- },
{
"protocol": "magnet",
"name": "I2PTorrent",
diff --git a/proxy.js b/proxy.js
index 7f76838..cf38201 100644
--- a/proxy.js
+++ b/proxy.js
@@ -20,7 +20,6 @@ function shouldProxyRequest(requestInfo) {
}
var handleContextProxyRequest = async function(requestDetails) {
- console.log("(proxy)Searching for proxy by context");
try {
var handleProxyRequest = function(context) {
proxy = {
diff --git a/torrent/torrent.js b/torrent/torrent.js
index 540529e..eaf36e9 100644
--- a/torrent/torrent.js
+++ b/torrent/torrent.js
@@ -1,4 +1,5 @@
-var hello = "hello bittorrent";
+var hellot = "hello bittorrent";
+var xTransmissionSessionId = ""
function makeid(length) {
var result = "";
@@ -11,7 +12,7 @@ function makeid(length) {
return result;
}
-function send(
+function torrentsend(
message,
control_host = "127.0.0.1",
control_port = "7657",
@@ -20,20 +21,22 @@ function send(
async function postData(url = "", data = {}) {
// Default options are marked with *
let requestBody = JSON.stringify(data);
- //console.log("(i2pcontrol)", requestBody, data);
+ console.log("(torrent-rpc) send", requestBody, data);
let opts = {
method: "POST", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, *cors, same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
- "Content-Type": "application/json"
+ "Content-Type": "application/json",
+ "X-Transmission-Session-Id": xTransmissionSessionId
},
redirect: "follow", // manual, *follow, error
referrerPolicy: "no-referrer", // no-referrer, *client
body: requestBody // body data type must match "Content-Type" header
};
const response = await fetch(url, opts);
+ console.log("(torrent-rpc) response", response)
return await response.json(); // parses JSON response into native JavaScript objects
}
@@ -41,42 +44,48 @@ function send(
"http://" + control_host + ":" + control_port + "/" + control_path + "/",
message
);
+/* return postData(
+ "http://" + control_host + ":" + control_port + "/" + control_path,
+ message
+ );*/
}
-function authenticate(
+function sessionStats(
password = "transmission",
control_host = "127.0.0.1",
control_port = "7657",
control_path = "transmission/rpc"
) {
- let store = browser.storage.local.get("rpc_pass");
- if (store != undefined) {
- console.log("Stored password found");
- password = store;
- }
- function auth(got) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
- json["method"] = "Authenticate";
- json["params"] = new Object();
- json["params"]["API"] = 1;
- json["params"]["Password"] = password;
- return send(json);
- }
- store.then(auth);
+ json["method"] = "session-stats";
+ //json["params"] = new Object();
+ return torrentsend(json, control_host, control_port, control_path);
}
-async function GetToken(
+async function GetTorrentToken(
password,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "transmission/rpc"
) {
- let me = authenticate(password);
- return await me.then(gettoken);
+ let me = sessionStats(password);
+ return await me.then(gettorrenttoken);
}
-function gettoken(authtoken) {
+function gettorrenttoken(authtoken) {
+ console.log(authtoken)
return authtoken.result.Token;
}
+
+function TorrentDone(result){
+ console.log("(torrent-rpc) recv", result)
+}
+
+function TorrentError(result){
+ console.log("(torrent-rpc) recv err", result)
+}
+
+var result = GetTorrentToken()
+result.then(TorrentDone, TorrentError)
\ No newline at end of file