Move doc/node.js to the r2pipe repository and define engine node>16

This commit is contained in:
pancake 2022-10-14 10:24:01 +02:00 committed by pancake
parent 103c28ccc5
commit fee1a457c1
5 changed files with 4 additions and 105 deletions

View File

@ -13,6 +13,10 @@
"type": "git",
"url": "git+https://github.com/radareorg/radare2.git"
},
"engines": {
"node": ">=16",
"npm": ">=7"
},
"keywords": [
"radare2"
],

View File

@ -1,7 +0,0 @@
all: node_modules
(sleep 1; open http://localhost:8080/p/ ) &
r2 -qc '#!pipe node index.js' /bin/ls
node_modules:
mkdir -p node_modules
npm install

View File

@ -1,32 +0,0 @@
Node.JS express based webserver
===============================
Author : pancake <pancake@nopcode.org>
Date: 2015-03-31
Description
-----------
This is the nodejs implementation of a websever
for radare2. This script can be executed from
inside r2 by using the following command:
> #!pipe node .
If you don't have any other .js handler (like duktape)
you can run it directly like this:
$ . index.js
From the shell you can run the script like this:
$ r2 -c '#!pipe node index.js' /bin/ls
Or just run it from nodejs:
$ node .
Or specify a different file to open
$ node . /bin/awk

View File

@ -1,55 +0,0 @@
/*
Author : pancake <pancake@nopcode.org>
Date: 2015-03-31
From inside r2
r2 -c '#!pipe node index.js' /bin/ls
Or from the shell:
node .
*/
var r2p = require ("r2pipe")
var http = require('http');
var express = require('express');
function runWebServer(r) {
r.cmd ("e http.root", function(wwwroot) {
wwwroot = wwwroot.trim ();
r.cmd ("e http.port", function(port) {
port = +port.trim ();
r.cmd ("e scr.color=0", function() {});
r.cmd ("e scr.interactive=false", function() {});
r.cmd ("e scr.html=true", function(){});
var app = express();
app.all('/cmd/*', function(req,res) {
var cmd = unescape (req.url.substring (5));
console.log ("cmd:", cmd);
r.cmd (cmd, function (data) {
res.send(data);
});
});
app.use(express.static(wwwroot));
r.cmd ("?e http://localhost:`e http.port`/p", function (data) {
console.log (data.replace(' ','').trim());
})
app.listen (port);
});
});
}
if (process.env.R2PIPE_IN) {
var r = r2p.rlangpipe(runWebServer);
} else {
var targetfile = "/bin/ls";
if (process.argv.length>2) {
targetfile = process.argv[2];
}
var r = r2p.pipe (targetfile, runWebServer);
}

View File

@ -1,11 +0,0 @@
{
"name": "r2-express.js",
"version": "0.0.1",
"description": "Express-based webserver for radare2",
"author": "pancake <pancake@nopcode.org>",
"dependencies": {
"express": "*",
"r2pipe": "*"
},
"license": "MIT"
}