commit 051773e45e0c677f84fbc83dd48020a4df8b310d Merge: 149e236 216b29b Author: juga0 juga@riseup.net Date: Fri Feb 15 17:38:21 2019 +0000
Merge branch 'bug28788'
Solved conflicts in: docs/source/examples/sbws.example.ini sbws/globals.py applying both theirs and ours.
docs/source/examples/sbws.example.ini | 5 ++++- docs/source/man_sbws.ini.rst | 3 +++ sbws/globals.py | 1 + sbws/lib/destination.py | 11 +++++++++-- 4 files changed, 17 insertions(+), 3 deletions(-)
diff --cc docs/source/examples/sbws.example.ini index cf6ff79,d11343a..1325bc8 --- a/docs/source/examples/sbws.example.ini +++ b/docs/source/examples/sbws.example.ini @@@ -10,31 -10,5 +10,34 @@@ foo = o [destinations.foo] # the domain and path to the 1GB file. url = https://example.com/does/not/exist.bin + + +## The following logging options are set by default. +## There is no need to change them unless other options are prefered. +; [logging] +; # Whether or not to log to a rotating file the directory paths.log_dname +; to_file = yes +; # Whether or not to log to stdout +; to_stdout = yes +; # Whether or not to log to syslog +; # NOTE that when sbws is launched by systemd, stdout goes to journal and +; # syslog. +; to_syslog = no + +; # Level to log at. Debug, info, warning, error, critical. +; # `level` must be set to the lower of all the handler levels. +; level = debug +; to_file_level = debug +; to_stdout_level = info +; to_syslog_level = info +; # Format string to use when logging +; format = %(module)s[%(process)s]: <%(levelname)s> %(message)s +; # verbose formatter useful for debugging +; to_file_format = %(asctime)s %(levelname)s %(threadName)s %(filename)s:%(lineno)s - %(funcName)s - %(message)s +; # Not adding %(asctime)s to to stdout since it'll go to syslog when using +; # systemd, and it'll have already the date. +; to_stdout_format = ${format} - ; to_syslog_format = ${format} ++; to_syslog_format = ${format} ++ + # To disable certificate validation, uncomment the following + # verify = False diff --cc sbws/globals.py index 5493b07,f4373b9..60e56f5 --- a/sbws/globals.py +++ b/sbws/globals.py @@@ -61,31 -53,7 +61,32 @@@ MAX_BW_DIFF_PERC = 5
BW_LINE_SIZE = 510
+# Metadata to send in every requests, so that data servers can know which +# scanners are using them. +# In Requests these keys are case insensitive. +HTTP_HEADERS = { + # This would be ignored if changing to HTTP/2 + 'Connection': 'keep-alive', + # Needs to get Tor version from the controller + 'User-Agent': 'sbws/{} ({}) Python/{} Requests/{} Stem/{} Tor/'.format( + __version__, platform.platform(), + platform.python_version(), + requests_version, stem_version), + # Organization defined names (:rfc:`7239`) + # Needs to get the nickname from the user config file. + 'Tor-Bandwidth-Scanner-Nickname': '{}', + 'Tor-Bandwidth-Scanner-UUID': '{}', + # In case of including IP address. + # 'Forwarded': 'for={}' # IPv6 part, if there's + } +# In the case of having ipv6 it's concatenated to forwarder. +IPV6_FORWARDED = ', for="[{}]"' + +HTTP_GET_HEADERS = { + 'Range': '{}', + 'Accept-Encoding': 'identity', +} + DESTINATION_VERIFY_CERTIFICATE = True
def fail_hard(*a, **kw):