|
@@ -29,7 +29,9 @@ from __future__ import (absolute_import, division, print_function,
|
|
|
import argparse
|
|
|
import logging
|
|
|
import os
|
|
|
+import socket
|
|
|
import sys
|
|
|
+import time
|
|
|
|
|
|
from util import ClosingFileHandler
|
|
|
|
|
@@ -90,7 +92,7 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
|
|
neg.send_wont("NAWS")
|
|
|
|
|
|
# Get the data passed through the negotiator
|
|
|
- data = neg.recv(1024)
|
|
|
+ data = neg.recv(4*1024)
|
|
|
log.debug("Incoming data: %r", data)
|
|
|
|
|
|
if VERIFIED_REQ.encode('utf-8') in data:
|
|
@@ -109,6 +111,12 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
|
|
log.debug("Sending %r", response_data)
|
|
|
self.request.sendall(response_data)
|
|
|
|
|
|
+ # put some effort into making a clean socket shutdown
|
|
|
+ # that does not give the client ECONNRESET
|
|
|
+ self.request.settimeout(0.1)
|
|
|
+ self.request.recv(4*1024)
|
|
|
+ self.request.shutdown(socket.SHUT_RDWR)
|
|
|
+
|
|
|
except IOError:
|
|
|
log.exception("IOError hit during request")
|
|
|
|