44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
const express = require("express");
|
|
const { NetHelperModule } = global.moduleApi;
|
|
|
|
const HTTPServer = require("../components/_http");
|
|
|
|
module.exports = class CgiBanPage extends NetHelperModule {
|
|
constructor() {
|
|
super();
|
|
this.router = express.Router();
|
|
|
|
this.cgiban = new this.statics.Operator(
|
|
"cgiban",
|
|
(argv) => {
|
|
return argv.length === 0;
|
|
},
|
|
(argv, self, syntaxTree) => {
|
|
if (!(syntaxTree.Type.prototype instanceof HTTPServer)) {
|
|
throw new SyntaxError("Unsupported type of server");
|
|
}
|
|
|
|
const router = this.router;
|
|
router.use("/cgi-bin/*", (req, res, next) => {
|
|
res
|
|
.status(400)
|
|
.send(
|
|
"<h1>CGI Scripts denied</h1><hr/><p>Perl is the language of dinosaurs and faggots, shove your query up your ass, piece of shit</p>",
|
|
);
|
|
});
|
|
router.use("*", (req, res, n) => n());
|
|
},
|
|
);
|
|
|
|
this.operators.push(this.cgiban);
|
|
|
|
this.emit("runned", () => {
|
|
this.serverType.app.use(router);
|
|
});
|
|
}
|
|
|
|
bind(type) {
|
|
super.bind(type);
|
|
this.serverType.routelist.push(this.router);
|
|
}
|
|
}; |