Better handling of bots hitting bad Gopher selectors
This commit is contained in:
parent
9d837cde4d
commit
31f94efdd8
|
@ -27,7 +27,6 @@ const _ = require('lodash');
|
|||
const fs = require('graceful-fs');
|
||||
const paths = require('path');
|
||||
const moment = require('moment');
|
||||
const async = require('async');
|
||||
|
||||
const ModuleInfo = exports.moduleInfo = {
|
||||
name : 'Gopher',
|
||||
|
@ -89,7 +88,15 @@ exports.getModule = class GopherModule extends ServerModule {
|
|||
socket.setEncoding('ascii');
|
||||
|
||||
socket.on('data', data => {
|
||||
// sanitize a bit - bots like to inject garbage
|
||||
data = data.replace(/[^ -~]/g, '');
|
||||
if (data) {
|
||||
this.routeRequest(data, socket);
|
||||
} else {
|
||||
this.notFoundGenerator('**invalid selector**', res => {
|
||||
return socket.end(`${res}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('error', err => {
|
||||
|
|
Loading…
Reference in New Issue