Skip to content

Commit

Permalink
Supporting YVAD by @inbasic
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-portmen committed Apr 29, 2017
1 parent 793bc52 commit 017a6b1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports.ids = {
'emlgnifoahkaeocfmafkpnfbijoioefh', // Open in Tor Browser (Opera)
'kjoabfljeghcinlpjhdbdfbcflapkccm', // Tor Control (Chrome)
'knfbgpkbkfebddfbklfpgmdjgolnkkfl', // Tor Control (Opera)
'khgbdhkpcapllhgfekjegcinegfhjbmi', // YVAD by @InBasic (Opera)
],
firefox: [
'{5610edea-88c1-4370-b93d-86aa131971d1}', // Open in IE
Expand All @@ -38,5 +39,6 @@ exports.ids = {
'{9a71ec90-d0b6-44af-833f-efe418ff8454}', // Auto Shutdown
'{0bcb72f8-7da8-4071-905c-2de13f5aad3a}', // Open in Vivaldi
'{9d3b260b-886d-4263-b9d6-81d756ee4929}', // Open in Tor Browser
'{f73df109-8fb4-453e-8373-f59e61ca4da3}', // YVAD by @InBasic
]
};
66 changes: 65 additions & 1 deletion host.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var https = lazyRequire('./follow-redirects').https;
var server, files = [], sprocess = [];

var config = {
version: '0.3.6'
version: '0.3.7'
};
// closing node when parent process is killed
process.stdin.resume();
Expand Down Expand Up @@ -292,6 +292,70 @@ function observe (msg, push, done) {
});
msg.commands.forEach(cmd => connection.write(cmd));
}
else if (msg.cmd === 'copy') {
let cbCalled = false;
let end = (error) => {
if (cbCalled === false) {
push(error ? {
error,
code: 1010
} : {
code: 0,
target: msg.target
});
done();
cbCalled = true;
}
};
let rd = fs.createReadStream(msg.source);
rd.on('error', e => end(e));
let wr = fs.createWriteStream(msg.target);
wr.on('error', e => end(e));
wr.on('finish', () => {
if (msg.chmod) {
fs.chmodSync(msg.target, msg.chmod);
}
if (msg.delete) {
fs.unlink(msg.source, (error) => {
if (error) {
return end(error);
}
end();
});
}
else {
end();
}
});
rd.pipe(wr);
}
else if (msg.cmd === 'remove') {
let unlink = (file) => {
return new Promise((resolve, reject) => {
fs.unlink(file, (error) => {
if (error) {
return reject(error);
}
resolve();
});
});
};
Promise.all(msg.files.map(file => unlink(file))).then(
() => {
push({
code: 0
});
done();
},
(error) => {
push({
error,
code: 1011
});
done();
}
);
}
else {
push({
error: 'cmd is unknown',
Expand Down

0 comments on commit 017a6b1

Please sign in to comment.