Update console.html

This commit is contained in:
Namhyeon Go 2024-06-21 12:41:18 +09:00
parent 1e3059c433
commit 47e3f90e90

View File

@ -8,7 +8,7 @@
<body>
<h1>Caterpillar Proxy Web Console</h1>
<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.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)");
},
success: function(response) {
if (typeof response.result.data === "object") {
term.echo(pretty_jsonify(response.result.data));
if ("error" in response) {
term.echo(response.error.message);
} 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) {
@ -62,6 +66,23 @@
if (k == "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) {
@ -80,7 +101,8 @@
this.echo("Please set a method");
return;
}
// method(relay_invoke_method)
if (env.method == "relay_invoke_method") {
if (args.length < 1) {
this.echo("Please set a callback");
@ -94,6 +116,38 @@
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, {});
}
}, {