Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
juga
sbws
Commits
a8787934
Commit
a8787934
authored
Apr 27, 2018
by
Matt Traudt
Committed by
Matt Traudt
Apr 27, 2018
Browse files
Move most globals back to sbws/globals.py
parent
fb8544e0
Changes
11
Hide whitespace changes
Inline
Side-by-side
sbws/__init__.py
View file @
a8787934
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
sbws/core/scanner.py
View file @
a8787934
...
...
@@ -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
...
...
sbws/core/server.py
View file @
a8787934
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
...
...
sbws/globals.py
View file @
a8787934
...
...
@@ -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
):
...
...
sbws/lib/resultdump.py
View file @
a8787934
...
...
@@ -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__
)
...
...
sbws/lib/v3bwfile.py
View file @
a8787934
...
...
@@ -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__
)
...
...
sbws/util/config.py
View file @
a8787934
...
...
@@ -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
()
...
...
sbws/util/simpleauth.py
View file @
a8787934
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
'.'
...
...
sbws/util/sockio.py
View file @
a8787934
from
sbws
import
SOCKET_TIMEOUT
from
sbws
.globals
import
SOCKET_TIMEOUT
import
socket
import
socks
import
logging
...
...
tests/lib/test_results.py
View file @
a8787934
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
...
...
tests/util/test_simpleauth.py
View file @
a8787934
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment