This commit is contained in:
aozhiwei 2022-04-01 23:07:15 +08:00
parent af6c48e47b
commit f86fdac6fe
3 changed files with 28 additions and 5 deletions

8
server/bin/web3test/gm Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
while true
do
read -p '> ' cmd
curl "http://127.0.0.1:8331/webapp/index.php?c=GM&a=execCmd&cmd=${cmd}" |jq .
echo ""
done

View File

@ -7,11 +7,7 @@ function add(name) {
function init() {
add('proxy');
}
function create(name) {
add('gm');
}
exports.init = init;
exports.create = create;

View File

@ -0,0 +1,19 @@
const app = require('j7/app');
const cmdHash = {};
async function execCmd(session) {
const cmdLine = session.request('cmd').split('.');
const cmd = cmdLine[0];
const params = cmdLine.length > 1 ? [] : cmdLine.slice(1);
if (cmdHash[cmd]) {
cmdHash[cmd](session, params);
} else {
session.rspErr(404, 'not found');
}
}
function init() {
app.registerHandler('GM', 'execCmd', execCmd);
}
exports.init = init;