挖坑系列
tomcat 防dos攻击
在tomcat-embed-core-8.5.24.jar!\org\apache\catalina\core\StandardServer.class文件的489行
这块的功能是监听 8005
端口是否有 SHUTDOWN
信号送进来
// Read a set of characters from the socket
int expected = 1024; // Cut off to avoid DoS attack
while (expected < shutdown.length()) {
if (random == null)
random = new Random();
expected += (random.nextInt() % 1024);
}
while (expected > 0) {
int ch = -1;
try {
ch = stream.read();
} catch (IOException e) {
log.warn("StandardServer.await: read: ", e);
ch = -1;
}
// Control character or EOF (-1) terminates loop
if (ch < 32 || ch == 127) {
break;
}
command.append((char) ch);
expected--;
}
解释:
(坑挖好了,有空来填)