Commit 6bd17853 authored by guido's avatar guido

hidden service support

parent 2f6477e6
......@@ -15,7 +15,7 @@ In Debian GNU/Linux 8 (Jessie) the npm version is too old to work with. You will
### apaste, the share.riseup.net command-line client
This is a modification of [upclient](https://github.com/Upload/upclient), the [Up1](https://github.com/Upload/Up1) command-line client to make it work with [https://share.riseup.net](https://share.riseup.net). As there is currently no way to customize it using config files, we had to make this for now.
This is a modification of [upclient](https://github.com/Upload/upclient), the [Up1](https://github.com/Upload/Up1) command-line client to make it work with [https://share.riseup.net](https://share.riseup.net).
Please help and contribute directly to the [Up1 command-line client](https://github.com/Upload/upclient)
......@@ -24,13 +24,28 @@ Please help and contribute directly to the [Up1 command-line client](https://git
Upload files and text to an Up1 based pastebin. If no argument is specified, stdin is assumed.
Options:
-b, --binary force application/octet-stream (for downloadable file)
-t, --text force text/plain (for pastebin)
-f, --file <name> force file name for stdin based inputs
-m, --mime <mime> force given mime type (default: detect)
-b, --binary force application/octet-stream (for downloadable file)
-t, --text force text/plain (for pastebin)
-f, --file <name> force file name for stdin based inputs
-m, --mime <mime> force given mime type (default: detect)
-T, --tor route the upload through Tor.
-h, --hidden-service use hidden service address
--version display version information and exit
--help display this help and exit
### Configuration
You can customize some options in the at `~/.apasterc`. This is a list of possible options (with their default values)
```
server_address = https://share.riseup.net
hidden_service_address = http://6zc6sejeho3fwrd4.onion
api_key = 59Mnk5nY6eCn4bi9GvfOXhMH54E7Bh6EMJXtyJfs
tor = false
hidden_service = false
```
The `tor` and `hidden_service` variables means always route the upload through Tor and always use the hidden service address respectively. If `hidden_service = true` it tor will be always true too.
### Usage examples
......@@ -50,6 +65,16 @@ Do the same as above, but also notify when complete:
import png:- | apaste | tee >(xsel -b) >(xargs notify-send "Upload Complete")
Use the Tor network
echo "Hi Tor" | apaste -T
Use the Hidden service address
echo "Hi Tor" | apaste -h
(when you use the hidden service you will get the url with the hidden service address too)
### Up1
For more information on Up1, view the README at https://github.com/Upload/Up1
{
"name": "apaste",
"version": "1.1.1",
"version": "1.2.0",
"description": "Command-line client for riseup.net pastebin service",
"main": "upclient.js",
"preferGlobal": "true",
"homepage": "https://share.riseup.net",
"homepage": "http://share.riseup.net",
"repository": {
"type": "git",
"url": "https://gitlab.com/riseup/up1-cli-client-nodejs.git"
"url": "https://0xacab.org/riseup/up1-cli-client-nodejs"
},
"bugs": {
"url": "https://gitlab.com/riseup/up1-cli-client-nodejs/issues"
"url": "https://0xacab.org/riseup/up1-cli-client-nodejs/issues"
},
"bin": {
"apaste": "upclient.js"
......@@ -20,7 +20,9 @@
"mime": "*",
"mmmagic": "*",
"snack-cli": "*",
"string": "*"
"string": "*",
"tor-request": "*",
"home-config": "*"
},
"engines": {
"node": "*"
......@@ -37,4 +39,4 @@
"hireable": null
}
]
}
\ No newline at end of file
}
#!/usr/bin/env node
"use strict";
var sjcl = require('./sjcl.js');
var https = require('https');
var crypto = require('crypto');
var FormData = require('form-data');
var mmm = require('mmmagic');
......@@ -10,6 +9,9 @@ var fs = require('fs');
var cli = require('snack-cli');
var path = require('path');
var S = require('string');
var tr = require('tor-request');
var request = require('request');
var cfg = require('home-config').load('.apasterc');
S.extendPrototype();
var argv = cli
......@@ -21,6 +23,8 @@ var argv = cli
.option('-t, --text', 'force text/plain', false)
.option('-f, --file <name>', 'force file name for stdin based inputs', false)
.option('-m, --mime <mime>', 'force given mime type', 'detect')
.option('-T, --tor', 'route the upload through tor', false)
.option('-h, --hidden-service', 'use hidden service address', false)
.parse();
function parametersfrombits(seed) {
......@@ -122,20 +126,52 @@ function doUpload(data, name, type) {
var result = encrypt(blob, seed, 0);
/* use riseup by default */
if (cfg.server_address) {
var up1_address = cfg.server_address;
} else {
var up1_address = 'https://share.riseup.net';
}
if (cfg.hidden_service_address) {
var up1_hs_address = cfg.hidden_service_address;
} else {
var up1_hs_address = 'http://6zc6sejeho3fwrd4.onion'
}
if (argv.hiddenService || cfg.hidden_service) {
var service_uri = up1_hs_address
cfg.tor = true;
} else {
var service_uri = up1_address
}
if (cfg.api_key) {
var service_api = cfg.api_key;
} else {
var service_api = '59Mnk5nY6eCn4bi9GvfOXhMH54E7Bh6EMJXtyJfs';
}
var formdata = new FormData()
formdata.append('api_key', '59Mnk5nY6eCn4bi9GvfOXhMH54E7Bh6EMJXtyJfs')
formdata.append('api_key', service_api)
formdata.append('ident', result.ident)
formdata.append('file', result.encrypted, {filename: 'file', contentType: 'text/plain'})
var req = https.request({
host: 'share.riseup.net',
port: 443,
path: '/up',
method: 'POST',
headers: formdata.getHeaders()
});
if (argv.tor || cfg.tor) {
console.log("uploading using Tor");
var req = tr.request.post({
headers: formdata.getHeaders(),
uri: service_uri + '/up'
}, function (err, res, body) {}
);
} else {
var req = request.post({
headers: formdata.getHeaders(),
uri: service_uri + '/up'
}, function (err, res, body) {}
);
}
formdata.pipe(req);
......@@ -149,7 +185,7 @@ function doUpload(data, name, type) {
data_out += chunk;
});
res.on('end', function() {
var res_url = "https://share.riseup.net/#"+result.seed;
var res_url = service_uri+"/#"+result.seed;
console.log(res_url);
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment