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
ca37185e
Commit
ca37185e
authored
Jun 03, 2018
by
Matt Traudt
Browse files
Get rid of default destination path
parent
56488bdb
Changes
4
Hide whitespace changes
Inline
Side-by-side
sbws/config.default.ini
View file @
ca37185e
...
...
@@ -4,13 +4,6 @@ v3bw_fname = ${sbws_home}/v3bw.txt
started_filepath
=
${sbws_home}/started_at
[destinations]
# The path part of the URL for a destination if not specified. For example,
# if defaul_path is /sbws.bin, then the following URLs will be treated the
# same.
# - http://example.com
# - http://example.com/sbws.bin
# Note that "https://example.com/" is not on the list. It's path is "/"
default_path
=
/sbws.bin
# How often to check if a destional is usable
usability_test_interval
=
300
...
...
sbws/lib/destination.py
View file @
ca37185e
...
...
@@ -95,16 +95,12 @@ def connect_to_destination_over_circuit(dest, circ_id, session, cont, max_dl):
class
Destination
:
def
__init__
(
self
,
url
,
default_path
,
max_dl
,
verify
):
def
__init__
(
self
,
url
,
max_dl
,
verify
):
self
.
_max_dl
=
max_dl
u
=
urlparse
(
url
)
# these things should have been verified in verify_config
assert
u
.
scheme
in
[
'http'
,
'https'
]
assert
u
.
netloc
if
not
u
.
path
:
assert
default_path
[
0
]
==
'/'
parts
=
u
[
0
:
2
]
+
default_path
+
u
[
2
:]
u
=
urlparse
(
'{}://{}{}{}{}{}'
.
format
(
*
parts
))
self
.
_url
=
u
self
.
_verify
=
verify
...
...
@@ -146,11 +142,11 @@ class Destination:
return
p
@
staticmethod
def
from_config
(
conf_section
,
default_path
,
max_dl
):
def
from_config
(
conf_section
,
max_dl
):
assert
'url'
in
conf_section
url
=
conf_section
[
'url'
]
verify
=
_parse_verify_option
(
conf_section
)
return
Destination
(
url
,
default_path
,
max_dl
,
verify
)
return
Destination
(
url
,
max_dl
,
verify
)
class
DestinationList
:
...
...
@@ -220,10 +216,9 @@ class DestinationList:
def
from_config
(
conf
,
circuit_builder
,
relay_list
,
controller
):
assert
'destinations'
in
conf
section
=
conf
[
'destinations'
]
default_path
=
section
[
'default_path'
]
dests
=
[]
for
key
in
section
.
keys
():
if
key
in
[
'default_path'
,
'usability_test_interval'
]:
if
key
in
[
'usability_test_interval'
]:
continue
if
not
section
.
getboolean
(
key
):
log
.
debug
(
'%s is disabled; not loading it'
,
key
)
...
...
@@ -232,7 +227,7 @@ class DestinationList:
assert
dest_sec
in
conf
# validate_config should require this
log
.
debug
(
'Loading info for destination %s'
,
key
)
dests
.
append
(
Destination
.
from_config
(
conf
[
dest_sec
],
default_path
,
conf
[
dest_sec
],
conf
.
getint
(
'scanner'
,
'max_download_size'
)))
if
len
(
dests
)
<
1
:
return
None
,
'No enabled destinations in config'
...
...
sbws/util/config.py
View file @
ca37185e
...
...
@@ -224,13 +224,6 @@ def _validate_destinations(conf):
err_tmpl
=
Template
(
'$sec/$key ($val): $e'
)
dest_sections
=
[]
for
key
in
section
.
keys
():
if
key
==
'default_path'
:
value
=
section
[
key
]
valid
,
error_msg
=
_validate_string
(
section
,
key
,
starts_with
=
'/'
)
if
not
valid
:
errors
.
append
(
err_tmpl
.
substitute
(
sec
=
sec
,
key
=
key
,
val
=
value
,
e
=
error_msg
))
continue
if
key
==
'usability_test_interval'
:
value
=
section
[
key
]
valid
,
error_msg
=
_validate_int
(
section
,
key
,
minimum
=
1
)
...
...
tests/unit/util/test_config.py
View file @
ca37185e
...
...
@@ -190,8 +190,10 @@ def test_validate_bool():
def
test_validate_url
():
goods
=
[
'http://example.com'
,
'http://example.com'
,
'http://example.com/'
,
'http://example.com/foo.bar'
,
'http://example.com/foo/bar'
,
'http://user@example.com'
,
]
bads
=
[
'ftp://example.com/foo.bar'
,
...
...
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