Skip to content
Snippets Groups Projects
Commit c7a7a7a3 authored by Matt Traudt's avatar Matt Traudt
Browse files

Set socket timeout in globals; use it

parent 38f843bf
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ from ..lib.relayprioritizer import RelayPrioritizer
from ..lib.helperrelay import HelperRelayList
from ..util.simpleauth import authenticate_to_server
from sbws.globals import (fail_hard, is_initted)
from sbws.globals import (MIN_REQ_BYTES, MAX_REQ_BYTES)
from sbws.globals import (MIN_REQ_BYTES, MAX_REQ_BYTES, SOCKET_TIMEOUT)
import sbws.util.stem as stem_utils
from stem.control import EventType
from argparse import ArgumentDefaultsHelpFormatter
......@@ -32,7 +32,7 @@ def make_socket(socks_host, socks_port):
the socket hasn't connect()ed anywhere '''
s = socks.socksocket()
s.set_proxy(socks.PROXY_TYPE_SOCKS5, socks_host, socks_port)
s.settimeout(10)
s.settimeout(SOCKET_TIMEOUT)
return s
......
from ..util.simpleauth import authenticate_client
from ..util.sockio import read_line
from sbws.globals import (fail_hard, is_initted)
from sbws.globals import SOCKET_TIMEOUT
from argparse import ArgumentDefaultsHelpFormatter
from functools import lru_cache
from threading import Thread
......@@ -152,6 +153,7 @@ def main(args, conf, log_):
try:
while True:
sock, addr = server.accept()
sock.settimeout(SOCKET_TIMEOUT)
log.info('accepting connection from', addr, 'as', sock.fileno())
t = new_thread(args, conf, sock)
t.start()
......
......@@ -19,6 +19,7 @@ G_INIT_FILE_MAP = [
# happens to require an sbws major version bump.
MIN_REQ_BYTES = 1
MAX_REQ_BYTES = 50 * 1024 * 1024 # 50 MiB, tentatively XXX github #11
SOCKET_TIMEOUT = 60 # seconds
def is_initted(d):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment