mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-11-27 10:00:40 +00:00
Update console.html
This commit is contained in:
parent
1e3059c433
commit
47e3f90e90
64
console.html
64
console.html
|
|
@ -8,7 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>Caterpillar Proxy Web Console</h1>
|
<h1>Caterpillar Proxy Web Console</h1>
|
||||||
<div id="console"></div>
|
<div id="console"></div>
|
||||||
<p>https://github.com/gnh1201/caterpillar</p>
|
<p><a href="https://github.com/gnh1201/caterpillar">Fork me. gnh1201/caterpillar (GitHub)</a></p>
|
||||||
|
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.0/js/jquery.terminal.min.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.0/js/jquery.terminal.min.js"></script>
|
||||||
|
|
@ -38,10 +38,14 @@
|
||||||
xhr.setRequestHeader("X-User-Agent", "php-httpproxy/0.1.5 (Client; WebConsole; abuse@catswords.net)");
|
xhr.setRequestHeader("X-User-Agent", "php-httpproxy/0.1.5 (Client; WebConsole; abuse@catswords.net)");
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (typeof response.result.data === "object") {
|
if ("error" in response) {
|
||||||
term.echo(pretty_jsonify(response.result.data));
|
term.echo(response.error.message);
|
||||||
} else {
|
} else {
|
||||||
term.echo(response.result.data);
|
if (typeof response.result.data === "object") {
|
||||||
|
term.echo(pretty_jsonify(response.result.data));
|
||||||
|
} else {
|
||||||
|
term.echo(response.result.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
|
|
@ -62,6 +66,23 @@
|
||||||
|
|
||||||
if (k == "method") {
|
if (k == "method") {
|
||||||
this.set_prompt('method([[b;red;black]' + env.method + '])> ');
|
this.set_prompt('method([[b;red;black]' + env.method + '])> ');
|
||||||
|
|
||||||
|
if (env.method == "relay_mysql_query") {
|
||||||
|
var _env = {
|
||||||
|
"mysql_hostname": "localhost",
|
||||||
|
"mysql_username": "root",
|
||||||
|
"mysql_password": "",
|
||||||
|
"mysql_database": "mysql",
|
||||||
|
"mysql_port": "3306",
|
||||||
|
"mysql_charset": "utf8"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (k in _env) {
|
||||||
|
if (!(k in env)) {
|
||||||
|
env[k] = _env[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
show: function(k) {
|
show: function(k) {
|
||||||
|
|
@ -80,7 +101,8 @@
|
||||||
this.echo("Please set a method");
|
this.echo("Please set a method");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// method(relay_invoke_method)
|
||||||
if (env.method == "relay_invoke_method") {
|
if (env.method == "relay_invoke_method") {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
this.echo("Please set a callback");
|
this.echo("Please set a callback");
|
||||||
|
|
@ -94,6 +116,38 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// method(relay_dns_get_record)
|
||||||
|
if (env.method == "relay_dns_get_record") {
|
||||||
|
if (args.length < 1) {
|
||||||
|
this.echo("Please set a hostname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonrpc2_request(this, env.method, {
|
||||||
|
"hostname": args[0]
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// method(relay_mysql_query)
|
||||||
|
if (env.method == "relay_mysql_query") {
|
||||||
|
var _this = this;
|
||||||
|
this.read("Enter MySQL query:\r\n", function(query) {
|
||||||
|
jsonrpc2_request(_this, env.method, {
|
||||||
|
"hostname": env.mysql_hostname,
|
||||||
|
"username": env.mysql_username,
|
||||||
|
"password": env.mysql_password,
|
||||||
|
"database": env.mysql_database,
|
||||||
|
"port": env.mysql_port,
|
||||||
|
"charset": env.mysql_charset,
|
||||||
|
"query": query
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// method(*)
|
||||||
jsonrpc2_request(this, env.method, {});
|
jsonrpc2_request(this, env.method, {});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user