Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
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
Monitor
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
Maunium
synapse
Commits
a5b41b80
Commit
a5b41b80
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Plain Diff
Merge pull request #273 from matrix-org/erikj/key_fetch_fix
Various bug fixes to crypto.keyring
parents
c0d1f37b
dd0867f5
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
synapse/crypto/keyring.py
+17
-10
17 additions, 10 deletions
synapse/crypto/keyring.py
with
17 additions
and
10 deletions
synapse/crypto/keyring.py
+
17
−
10
View file @
a5b41b80
...
@@ -162,7 +162,9 @@ class Keyring(object):
...
@@ -162,7 +162,9 @@ class Keyring(object):
def
remove_deferreds
(
res
,
server_name
,
group_id
):
def
remove_deferreds
(
res
,
server_name
,
group_id
):
server_to_gids
[
server_name
].
discard
(
group_id
)
server_to_gids
[
server_name
].
discard
(
group_id
)
if
not
server_to_gids
[
server_name
]:
if
not
server_to_gids
[
server_name
]:
server_to_deferred
.
pop
(
server_name
).
callback
(
None
)
d
=
server_to_deferred
.
pop
(
server_name
,
None
)
if
d
:
d
.
callback
(
None
)
return
res
return
res
for
g_id
,
deferred
in
deferreds
.
items
():
for
g_id
,
deferred
in
deferreds
.
items
():
...
@@ -200,8 +202,15 @@ class Keyring(object):
...
@@ -200,8 +202,15 @@ class Keyring(object):
else
:
else
:
break
break
for
server_name
,
deferred
in
server_to_deferred
:
for
server_name
,
deferred
in
server_to_deferred
.
items
():
self
.
key_downloads
[
server_name
]
=
ObservableDeferred
(
deferred
)
d
=
ObservableDeferred
(
deferred
)
self
.
key_downloads
[
server_name
]
=
d
def
rm
(
r
,
server_name
):
self
.
key_downloads
.
pop
(
server_name
,
None
)
return
r
d
.
addBoth
(
rm
,
server_name
)
def
get_server_verify_keys
(
self
,
group_id_to_group
,
group_id_to_deferred
):
def
get_server_verify_keys
(
self
,
group_id_to_group
,
group_id_to_deferred
):
"""
Takes a dict of KeyGroups and tries to find at least one key for
"""
Takes a dict of KeyGroups and tries to find at least one key for
...
@@ -220,9 +229,8 @@ class Keyring(object):
...
@@ -220,9 +229,8 @@ class Keyring(object):
merged_results
=
{}
merged_results
=
{}
missing_keys
=
{
missing_keys
=
{
group
.
server_name
:
key_id
group
.
server_name
:
set
(
group
.
key_id
s
)
for
group
in
group_id_to_group
.
values
()
for
group
in
group_id_to_group
.
values
()
for
key_id
in
group
.
key_ids
}
}
for
fn
in
key_fetch_fns
:
for
fn
in
key_fetch_fns
:
...
@@ -279,16 +287,15 @@ class Keyring(object):
...
@@ -279,16 +287,15 @@ class Keyring(object):
def
get_keys_from_store
(
self
,
server_name_and_key_ids
):
def
get_keys_from_store
(
self
,
server_name_and_key_ids
):
res
=
yield
defer
.
gatherResults
(
res
=
yield
defer
.
gatherResults
(
[
[
self
.
store
.
get_server_verify_keys
(
server_name
,
key_ids
)
self
.
store
.
get_server_verify_keys
(
server_name
,
key_ids
).
addCallback
(
lambda
ks
,
server
:
(
server
,
ks
),
server_name
)
for
server_name
,
key_ids
in
server_name_and_key_ids
for
server_name
,
key_ids
in
server_name_and_key_ids
],
],
consumeErrors
=
True
,
consumeErrors
=
True
,
).
addErrback
(
unwrapFirstError
)
).
addErrback
(
unwrapFirstError
)
defer
.
returnValue
(
dict
(
zip
(
defer
.
returnValue
(
dict
(
res
))
[
server_name
for
server_name
,
_
in
server_name_and_key_ids
],
res
)))
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_keys_from_perspectives
(
self
,
server_name_and_key_ids
):
def
get_keys_from_perspectives
(
self
,
server_name_and_key_ids
):
...
...
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