Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BridgeDB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
The Tor Project
Anti-censorship
BridgeDB
Commits
049a9d95
Unverified
Commit
049a9d95
authored
Oct 29, 2019
by
Philipp Winter
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/32203' into develop
parents
d4fad3ed
18c96a66
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bridgedb/metrics.py
+10
-7
10 additions, 7 deletions
bridgedb/metrics.py
bridgedb/test/test_metrics.py
+11
-0
11 additions, 0 deletions
bridgedb/test/test_metrics.py
with
21 additions
and
7 deletions
bridgedb/metrics.py
+
10
−
7
View file @
049a9d95
...
...
@@ -83,17 +83,20 @@ def setSupportedTransports(supportedTransports):
SUPPORTED_TRANSPORTS
=
supportedTransports
def
isTransportSupported
(
transport
):
"""
Return `True
'
if the given transport is supported or `False
'
otherwise.
def
isBridgeTypeSupported
(
bridgeType
):
"""
Return `True
'
or `False
'
depending on if the given bridge type is
supported.
:param str
transport: The transport protocol
.
:param str
bridgeType: The bridge type, e.g.,
"
vanilla
"
or
"
obfs4
"
.
"""
if
SUPPORTED_TRANSPORTS
is
None
:
logging
.
error
(
"
Bug: Variable SUPPORTED_TRANSPORTS is None.
"
)
return
False
return
transport
in
SUPPORTED_TRANSPORTS
# Note that "vanilla" isn't a transport protocol (in fact, it's the absence
# of a transport), which is why it isn't in SUPPORTED_TRANSPORTS.
return
(
bridgeType
in
SUPPORTED_TRANSPORTS
)
or
(
bridgeType
==
"
vanilla
"
)
def
export
(
fh
,
measurementInterval
):
...
...
@@ -334,7 +337,7 @@ class HTTPSMetrics(Metrics):
# BridgeDB's HTTPS interface exposes transport types as a drop down
# menu but users can still request anything by manipulating HTTP
# parameters.
if
not
is
Transport
Supported
(
bridgeType
):
if
not
is
BridgeType
Supported
(
bridgeType
):
logging
.
warning
(
"
User requested unsupported transport type %s
"
"
over HTTPS.
"
%
bridgeType
)
return
...
...
@@ -393,7 +396,7 @@ class EmailMetrics(Metrics):
# Over email, transports are requested by typing them. Typos happen
# and users can request anything, really.
if
not
is
Transport
Supported
(
bridgeType
):
if
not
is
BridgeType
Supported
(
bridgeType
):
logging
.
warning
(
"
User requested unsupported transport type %s
"
"
over email.
"
%
bridgeType
)
return
...
...
@@ -439,7 +442,7 @@ class MoatMetrics(Metrics):
logging
.
warning
(
"
Could not decode request: %s
"
%
err
)
return
if
not
is
Transport
Supported
(
bridgeType
):
if
not
is
BridgeType
Supported
(
bridgeType
):
logging
.
warning
(
"
User requested unsupported transport type %s
"
"
over moat.
"
%
bridgeType
)
return
...
...
This diff is collapsed.
Click to expand it.
bridgedb/test/test_metrics.py
+
11
−
0
View file @
049a9d95
...
...
@@ -202,3 +202,14 @@ class StateTest(unittest.TestCase):
key2
=
"
moat.obfs4.us.fail.none
"
self
.
assertTrue
(
metrix
.
hotMetrics
[
key1
]
==
1
)
self
.
assertTrue
(
metrix
.
hotMetrics
[
key2
]
==
1
)
def
test_is_bridge_type_supported
(
self
):
oldTransports
=
metrics
.
SUPPORTED_TRANSPORTS
metrics
.
setSupportedTransports
({})
self
.
assertFalse
(
metrics
.
isBridgeTypeSupported
(
"
obfs4
"
))
metrics
.
setSupportedTransports
(
oldTransports
)
self
.
assertTrue
(
metrics
.
isBridgeTypeSupported
(
"
obfs4
"
))
self
.
assertTrue
(
metrics
.
isBridgeTypeSupported
(
"
vanilla
"
))
self
.
assertFalse
(
metrics
.
isBridgeTypeSupported
(
"
xxx
"
))
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