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
d4e36b8d
Commit
d4e36b8d
authored
7 years ago
by
Matt Traudt
Browse files
Options
Downloads
Patches
Plain Diff
Everything use the same controller; CircuitBuilder use RelayList
parent
1c583a26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/circuitbuilder.py
+15
-14
15 additions, 14 deletions
lib/circuitbuilder.py
lib/relaylist.py
+7
-4
7 additions, 4 deletions
lib/relaylist.py
scanner.py
+5
-2
5 additions, 2 deletions
scanner.py
with
27 additions
and
20 deletions
lib/circuitbuilder.py
+
15
−
14
View file @
d4e36b8d
from
stem
import
(
CircuitExtensionFailed
,
InvalidRequest
)
from
stem
import
Flag
import
random
import
util.stem
as
stem_utils
from
lib.relaylist
import
RelayList
class
PathLengthException
(
Exception
):
...
...
@@ -35,18 +35,20 @@ class CircuitBuilder:
them, but CircuitBuilder will keep track of existing circuits and close
them when it is deleted.
'''
def
__init__
(
self
,
args
,
close_circuits_on_exit
=
True
):
self
.
controller
=
stem_utils
.
init_controller
(
port
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
port
'
else
None
,
path
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
socket
'
else
None
)
self
.
relays
=
self
.
_init_relays
()
def
__init__
(
self
,
args
,
controller
=
None
,
close_circuits_on_exit
=
True
):
if
controller
is
None
:
self
.
controller
=
stem_utils
.
init_controller
(
port
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
port
'
else
None
,
path
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
socket
'
else
None
)
else
:
self
.
controller
=
controller
self
.
relay_list
=
RelayList
(
args
,
controller
=
self
.
controller
)
self
.
built_circuits
=
set
()
self
.
close_circuits_on_exit
=
close_circuits_on_exit
def
_init_relays
(
self
):
c
=
self
.
controller
assert
stem_utils
.
is_controller_okay
(
c
)
return
[
ns
for
ns
in
c
.
get_network_statuses
()]
@property
def
relays
(
self
):
return
self
.
relay_list
.
relays
def
build_circuit
(
self
,
*
a
,
**
kw
):
'''
Implementations of this method should build the circuit and return
...
...
@@ -143,11 +145,10 @@ class ExitCircuitBuilder(CircuitBuilder):
to a specific IP/port.
'''
def
__init__
(
self
,
*
a
,
**
kw
):
super
().
__init__
(
*
a
,
**
kw
)
self
.
exits
=
self
.
_init_exits
()
def
_init_exits
(
self
):
relays
=
self
.
relays
return
[
r
for
r
in
relays
if
Flag
.
EXIT
in
r
.
flags
]
@property
def
exits
(
self
):
return
self
.
relay_list
.
exits
def
build_circuit
(
self
,
length
=
3
):
'''
builds circuit of <length> and returns its (str) ID.
'''
...
...
This diff is collapsed.
Click to expand it.
lib/relaylist.py
+
7
−
4
View file @
d4e36b8d
...
...
@@ -11,10 +11,13 @@ class RelayList:
'''
REFRESH_INTERVAL
=
300
# seconds
def
__init__
(
self
,
args
):
self
.
_controller
=
stem_utils
.
init_controller
(
port
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
port
'
else
None
,
path
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
socket
'
else
None
)
def
__init__
(
self
,
args
,
controller
=
None
):
if
controller
is
None
:
self
.
_controller
=
stem_utils
.
init_controller
(
port
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
port
'
else
None
,
path
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
socket
'
else
None
)
else
:
self
.
_controller
=
controller
self
.
_refresh
()
@property
...
...
This diff is collapsed.
Click to expand it.
scanner.py
+
5
−
2
View file @
d4e36b8d
...
...
@@ -196,8 +196,11 @@ def result_putter_error(target):
def
test_speedtest
(
args
):
cb
=
CB
(
args
)
rl
=
RelayList
(
args
)
controller
=
stem_utils
.
init_controller
(
port
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
port
'
else
None
,
path
=
args
.
control
[
1
]
if
args
.
control
[
0
]
==
'
socket
'
else
None
)
cb
=
CB
(
args
,
controller
=
controller
)
rl
=
RelayList
(
args
,
controller
=
controller
)
rd
=
ResultDump
(
args
.
result_directory
,
end_event
)
max_pending_results
=
args
.
threads
pool
=
Pool
(
max_pending_results
)
...
...
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