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
The Tor Project
Network Health
sbws
Commits
b2eeda23
Commit
b2eeda23
authored
Nov 22, 2018
by
juga
Browse files
destination, scanner: choose exits with same flags
The flags are: not having a badflag and the policy allows to exit to a port.
parent
2e100e81
Changes
3
Hide whitespace changes
Inline
Side-by-side
sbws/core/scanner.py
View file @
b2eeda23
...
...
@@ -136,8 +136,8 @@ def _pick_ideal_second_hop(relay, dest, rl, cont, is_exit):
destination **dest**, pick a second relay that is or is not an exit
according to **is_exit**.
'''
candidates
=
[]
candidates
.
extend
(
rl
.
exits
if
is_exit
else
rl
.
non_exits
)
candidates
=
rl
.
exits_not_bad_allowing_port
(
dest
.
port
)
if
is_exit
\
else
rl
.
non_exits
if
not
len
(
candidates
):
return
None
log
.
debug
(
'Picking a 2nd hop to measure %s from %d choices. is_exit=%s'
,
...
...
@@ -177,8 +177,7 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
# exit, then pick a non-exit. Otherwise pick an exit.
helper
=
None
circ_fps
=
None
if
relay
.
can_exit_to
(
dest
.
hostname
,
dest
.
port
)
and
\
relay
not
in
rl
.
bad_exits
:
if
relay
.
is_exit_not_bad_allowing_port
(
dest
.
port
):
helper
=
_pick_ideal_second_hop
(
relay
,
dest
,
rl
,
cb
.
controller
,
is_exit
=
False
)
if
helper
:
...
...
sbws/lib/destination.py
View file @
b2eeda23
...
...
@@ -179,8 +179,7 @@ class DestinationList:
session
=
requests_utils
.
make_session
(
cont
,
timeout
)
usable_dests
=
[]
for
dest
in
self
.
_all_dests
:
possible_exits
=
[
e
for
e
in
self
.
_rl
.
exits
if
e
.
can_exit_to
(
dest
.
hostname
,
dest
.
port
)]
possible_exits
=
self
.
_rl
.
exits_not_bad_allowing_port
(
dest
.
port
)
# Keep the fastest 10% of exits, or 3, whichever is larger
num_keep
=
int
(
max
(
3
,
len
(
possible_exits
)
*
0.1
))
possible_exits
=
sorted
(
...
...
sbws/lib/relaylist.py
View file @
b2eeda23
...
...
@@ -231,7 +231,6 @@ class RelayList:
self
.
_relays
=
self
.
_init_relays
()
self
.
_last_refresh
=
time
.
time
()
def
exits_not_bad_allowing_port
(
self
,
port
):
return
[
r
for
r
in
self
.
exits
if
r
.
is_exit_not_bad_allowing_port
(
port
)]
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