forked from p15670423/monkey
Agent: Extract proxy timeout to const, change it to 2.5
This commit is contained in:
parent
0b1b829cd7
commit
7fc49196d7
|
@ -2,6 +2,7 @@ import time
|
|||
from threading import Thread
|
||||
|
||||
g_last_served = None
|
||||
PROXY_TIMEOUT = 2.5
|
||||
|
||||
|
||||
class TransportProxyBase(Thread):
|
||||
|
|
|
@ -7,7 +7,11 @@ from logging import getLogger
|
|||
from urllib.parse import urlsplit
|
||||
|
||||
from infection_monkey.network.tools import get_interface_to_target
|
||||
from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time
|
||||
from infection_monkey.transport.base import (
|
||||
PROXY_TIMEOUT,
|
||||
TransportProxyBase,
|
||||
update_last_serve_time,
|
||||
)
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
@ -227,6 +231,6 @@ class LockedHTTPServer(threading.Thread):
|
|||
class HTTPConnectProxy(TransportProxyBase):
|
||||
def run(self):
|
||||
httpd = http.server.HTTPServer((self.local_host, self.local_port), HTTPConnectProxyHandler)
|
||||
httpd.timeout = 10
|
||||
httpd.timeout = PROXY_TIMEOUT
|
||||
while not self._stopped:
|
||||
httpd.handle_request()
|
||||
|
|
|
@ -3,16 +3,20 @@ import socket
|
|||
from logging import getLogger
|
||||
from threading import Thread
|
||||
|
||||
from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time
|
||||
from infection_monkey.transport.base import (
|
||||
PROXY_TIMEOUT,
|
||||
TransportProxyBase,
|
||||
update_last_serve_time,
|
||||
)
|
||||
|
||||
READ_BUFFER_SIZE = 8192
|
||||
DEFAULT_TIMEOUT = 10
|
||||
SOCKET_READ_TIMEOUT = 10
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
||||
class SocketsPipe(Thread):
|
||||
def __init__(self, source, dest, timeout=DEFAULT_TIMEOUT):
|
||||
def __init__(self, source, dest, timeout=SOCKET_READ_TIMEOUT):
|
||||
Thread.__init__(self)
|
||||
self.source = source
|
||||
self.dest = dest
|
||||
|
@ -51,7 +55,7 @@ class TcpProxy(TransportProxyBase):
|
|||
pipes = []
|
||||
l_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
l_socket.bind((self.local_host, self.local_port))
|
||||
l_socket.settimeout(DEFAULT_TIMEOUT)
|
||||
l_socket.settimeout(PROXY_TIMEOUT)
|
||||
l_socket.listen(5)
|
||||
|
||||
while not self._stopped:
|
||||
|
|
Loading…
Reference in New Issue