Merge pull request #35 from zp/scgi-socket

Add scgi socket support
This commit is contained in:
John Furrow
2016-06-18 16:08:41 -07:00
committed by GitHub
3 changed files with 12 additions and 4 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ It's a work-in-progress, and it might not have all of the features you want (yet
* I recommend managing different Node versions with [nvm](https://github.com/creationix/nvm) or [n](https://github.com/tj/n).
#### Configuration
1. Add your rTorrent SCGI hostname and port in `config.js`. Defaults are `localhost` and `5000`.
1. Set your rTorrent SCGI hostname and port in `config.js`. Defaults are `localhost` and `5000`.
* If you want to use a socket, change `socket` to true and set `socketPath` to the absolute file path of your rTorrent socket, make sure Flood has read/write access.
2. Copy `server/db/users.js.example` to `server/db/users.js` and add a username and password (password is stored in plain text for now, but this file is not accessible publicly).
#### Start It
+6 -2
View File
@@ -3,8 +3,12 @@ const config = {
dbPath: './server/db/',
maxHistoryStates: 30,
pollInterval: 1000 * 5,
scgiHost: 'localhost',
scgiHostPort: 5000
scgi: {
host: 'localhost',
port: 5000,
socket: false,
socketPath: '/tmp/rtorrent.sock'
}
};
module.exports = config;
+4 -1
View File
@@ -9,11 +9,14 @@ let config = require('../../config');
let scgi = {
methodCall: (methodName, parameters) => {
let connectMethod = config.scgi.socket
? {path: config.scgi.socketPath}
: {port: config.scgi.port, host: config.scgi.host};
let deferred = Q.defer();
let deserializer = new Deserializer('utf8');
let headerLength = 0;
let nullChar = String.fromCharCode(0);
let stream = net.connect({port: config.scgiHostPort, host: config.scgiHost});
let stream = net.connect(connectMethod);
let xml = Serializer.serializeMethodCall(methodName, parameters);
stream.setEncoding('UTF8');