Commit a8787934 authored by Matt Traudt's avatar Matt Traudt Committed by Matt Traudt
Browse files

Move most globals back to sbws/globals.py

parent fb8544e0
import os
__version__ = '0.1.0'
RESULT_VERSION = 1
WIRE_VERSION = 1
SPEC_VERSION = '1.1.0'
PKG_DIR = os.path.abspath(os.path.dirname(__file__))
SOCKET_TIMEOUT = 60 # seconds
# Minimum and maximum number of bytes a scanner is allowed to request from a
# server. If these are changed, a WIRE_VERSION bump is required, which also
# happens to require an sbws major version bump.
#
# Note for smart people and people who pull out Wireshark: Even if the scanner
# requests 1 byte, that request and the 1 byte response will each be carried
# over the Internet in 514 byte Tor cells. Theoretically we could bump the
# minimum request size up to ~498 bytes, but I see no reason why we should.
# Trying to hit the maximum cell size just makes sbws server send more, us read
# more, and it runs the risk of standards changing underneath us and sbws
# suddenly creating more than one cell.
MIN_REQ_BYTES = 1
MAX_REQ_BYTES = 1 * 1024 * 1024 * 1024 # 1 GiB
......@@ -11,7 +11,7 @@ from ..lib.helperrelay import HelperRelayList
from ..util.simpleauth import authenticate_to_server
from ..util.sockio import (make_socket, close_socket)
from sbws.globals import (fail_hard, is_initted)
from sbws import MIN_REQ_BYTES, MAX_REQ_BYTES
from sbws.globals import MIN_REQ_BYTES, MAX_REQ_BYTES
import sbws.util.stem as stem_utils
from argparse import ArgumentDefaultsHelpFormatter
from multiprocessing.dummy import Pool
......
from ..util.simpleauth import authenticate_scanner
from ..util.sockio import read_line
from sbws.globals import (fail_hard, is_initted)
from sbws import MIN_REQ_BYTES, MAX_REQ_BYTES, SOCKET_TIMEOUT
from sbws.globals import MIN_REQ_BYTES, MAX_REQ_BYTES, SOCKET_TIMEOUT
from argparse import ArgumentDefaultsHelpFormatter
from functools import lru_cache
from threading import Thread
......
......@@ -3,6 +3,28 @@ import logging
log = logging.getLogger(__name__)
RESULT_VERSION = 1
WIRE_VERSION = 1
SPEC_VERSION = '1.1.0'
PKG_DIR = os.path.abspath(os.path.dirname(__file__))
SOCKET_TIMEOUT = 60 # seconds
# Minimum and maximum number of bytes a scanner is allowed to request from a
# server. If these are changed, a WIRE_VERSION bump is required, which also
# happens to require an sbws major version bump.
#
# Note for smart people and people who pull out Wireshark: Even if the scanner
# requests 1 byte, that request and the 1 byte response will each be carried
# over the Internet in 514 byte Tor cells. Theoretically we could bump the
# minimum request size up to ~498 bytes, but I see no reason why we should.
# Trying to hit the maximum cell size just makes sbws server send more, us read
# more, and it runs the risk of standards changing underneath us and sbws
# suddenly creating more than one cell.
MIN_REQ_BYTES = 1
MAX_REQ_BYTES = 1 * 1024 * 1024 * 1024 # 1 GiB
def is_initted(d):
if not os.path.isdir(d):
......
......@@ -12,7 +12,7 @@ from datetime import datetime
from datetime import timedelta
from enum import Enum
from stem.descriptor.router_status_entry import RouterStatusEntryV3
from sbws import RESULT_VERSION
from sbws.globals import RESULT_VERSION
from sbws.util.filelock import DirectoryLock
log = logging.getLogger(__name__)
......
......@@ -4,7 +4,8 @@
import time
import logging
from sbws import __version__, SPEC_VERSION
from sbws import __version__
from sbws.globals import SPEC_VERSION
log = logging.getLogger(__name__)
......
......@@ -4,7 +4,7 @@ import logging
import logging.config
from string import Template
from tempfile import NamedTemporaryFile
from sbws import PKG_DIR
from sbws.globals import PKG_DIR
_ALPHANUM = 'abcdefghijklmnopqrstuvwxyz'
_ALPHANUM += _ALPHANUM.upper()
......
from ..util.sockio import read_line
import socket
import logging
from sbws import WIRE_VERSION
from sbws.globals import WIRE_VERSION
MAGIC_BYTES = b'SBWS'
SUCCESS_BYTES = b'.'
......
from sbws import SOCKET_TIMEOUT
from sbws.globals import SOCKET_TIMEOUT
import socket
import socks
import logging
......
from unittest.mock import patch
from sbws import RESULT_VERSION
from sbws.globals import RESULT_VERSION
from sbws.lib.resultdump import Result
from sbws.lib.resultdump import ResultSuccess
from sbws.lib.resultdump import ResultError
......
from sbws.util.simpleauth import authenticate_scanner
from sbws.util.simpleauth import authenticate_to_server
from sbws.util.simpleauth import (MAGIC_BYTES, PW_LEN, SUCCESS_BYTES)
from sbws import WIRE_VERSION
from sbws.globals import WIRE_VERSION
from configparser import ConfigParser
import socket
import logging
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment