Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
52d65305
Commit
52d65305
authored
6 years ago
by
Matt Traudt
Browse files
Options
Downloads
Patches
Plain Diff
Return some ResultError types
parent
09170f32
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sbws/core/scanner.py
+32
-12
32 additions, 12 deletions
sbws/core/scanner.py
with
32 additions
and
12 deletions
sbws/core/scanner.py
+
32
−
12
View file @
52d65305
...
...
@@ -2,9 +2,8 @@
from
..lib.circuitbuilder
import
GapsCircuitBuilder
as
CB
from
..lib.resultdump
import
ResultDump
from
..lib.resultdump
import
ResultSuccess
# from ..lib.resultdump import ResultErrorCircuit
# from ..lib.resultdump import ResultErrorAuth
from
..lib.resultdump
import
ResultSuccess
,
ResultErrorCircuit
from
..lib.resultdump
import
ResultErrorStream
from
..lib.relaylist
import
RelayList
from
..lib.relayprioritizer
import
RelayPrioritizer
from
..lib.destination
import
DestinationList
...
...
@@ -152,11 +151,16 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
return
None
exit
=
random
.
choice
(
exits
)
# Build the circuit
circ_id
=
cb
.
build_circuit
([
relay
.
fingerprint
,
exit
.
fingerprint
])
our_nick
=
conf
[
'
scanner
'
][
'
nickname
'
]
circ_fps
=
[
relay
.
fingerprint
,
exit
.
fingerprint
]
circ_id
=
cb
.
build_circuit
(
circ_fps
)
if
not
circ_id
:
log
.
warning
(
'
Could not build circuit involving %s
'
,
relay
.
nickname
)
# TODO: Return ResultError of some sort
return
None
msg
=
'
Unable to complete circuit
'
return
[
ResultErrorCircuit
(
relay
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
ResultErrorCircuit
(
exit
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
]
log
.
debug
(
'
Built circ %s %s for relay %s %s
'
,
circ_id
,
stem_utils
.
circuit_str
(
cb
.
controller
,
circ_id
),
relay
.
nickname
,
relay
.
fingerprint
[
0
:
8
])
...
...
@@ -168,8 +172,12 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
'
stopped being usable: %s
'
,
relay
.
nickname
,
relay
.
fingerprint
[
0
:
8
],
usable_data
)
cb
.
close_circuit
(
circ_id
)
# TODO: Return ResultError of some sort???
return
None
# TODO: Return a different/new type of ResultError?
msg
=
'
The destination seemed to have stopped being usable
'
return
[
ResultErrorStream
(
relay
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
ResultErrorStream
(
exit
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
]
assert
is_usable
assert
'
content_length
'
in
usable_data
# FIRST: measure RTT
...
...
@@ -178,13 +186,25 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
log
.
warning
(
'
Unable to measure RTT to %s via relay %s %s
'
,
dest
.
url
,
relay
.
nickname
,
relay
.
fingerprint
[
0
:
8
])
cb
.
close_circuit
(
circ_id
)
# TODO: Return ResultError of some sort???
return
None
# TODO: Return a different/new type of ResultError?
msg
=
'
Something bad happened while measuring RTTs
'
return
[
ResultErrorStream
(
relay
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
ResultErrorStream
(
exit
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
]
# SECOND: measure bandwidth
bw_results
=
measure_bandwidth_to_server
(
s
,
conf
,
dest
,
usable_data
[
'
content_length
'
])
circ_fps
=
cb
.
get_circuit_path
(
circ_id
)
our_nick
=
conf
[
'
scanner
'
][
'
nickname
'
]
if
bw_results
is
None
:
log
.
warning
(
'
Unable to measure bandwidth to %s via relay %s %s
'
,
dest
.
url
,
relay
.
nickname
,
relay
.
fingerprint
[
0
:
8
])
cb
.
close_circuit
(
circ_id
)
# TODO: Return a different/new type of ResultError?
msg
=
'
Something bad happened while measuring bandwidth
'
return
[
ResultErrorStream
(
relay
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
ResultErrorStream
(
exit
,
circ_fps
,
dest
.
url
,
our_nick
,
msg
=
msg
),
]
cb
.
close_circuit
(
circ_id
)
# Finally: store result
return
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment