Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slixmpp-omemo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
slixmpp-omemo
Commits
2dc08c9d
Verified
Commit
2dc08c9d
authored
Sep 02, 2019
by
Maxime Buquet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Echo_bot: prevent loops when decrypting/encrypting
Signed-off-by:
Maxime “pep” Buquet
<
pep@bouah.net
>
parent
79a4f417
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
examples/echo_client.py
examples/echo_client.py
+5
-0
No files found.
examples/echo_client.py
View file @
2dc08c9d
...
...
@@ -88,6 +88,7 @@ class EchoBot(ClientXMPP):
encrypted
=
msg
[
'omemo_encrypted'
]
body
=
self
[
'xep_0384'
].
decrypt_message
(
encrypted
,
mfrom
,
allow_untrusted
)
await
self
.
encrypted_reply
(
msg
,
'Thanks for sending
\n
%s'
%
body
.
decode
(
"utf8"
))
return
None
except
(
MissingOwnKey
,):
# The message is missing our own key, it was not encrypted for
# us, and we can't decrypt it.
...
...
@@ -95,6 +96,7 @@ class EchoBot(ClientXMPP):
msg
,
'I can
\'
t decrypt this message as it is not encrypted for me.'
,
)
return
None
except
(
NoAvailableSession
,)
as
exn
:
# We received a message from that contained a session that we
# don't know about (deleted session storage, etc.). We can't
...
...
@@ -107,6 +109,7 @@ class EchoBot(ClientXMPP):
'I can
\'
t decrypt this message as it uses an encrypted '
'session I don
\'
t know about.'
,
)
return
None
except
(
UndecidedException
,
UntrustedException
)
as
exn
:
# We received a message from an untrusted device. We can
# choose to decrypt the message nonetheless, with the
...
...
@@ -122,11 +125,13 @@ class EchoBot(ClientXMPP):
)
# We resend, setting the `allow_untrusted` parameter to True.
await
self
.
message
(
msg
,
allow_untrusted
=
True
)
return
None
except
(
EncryptionPrepareException
,):
# Slixmpp tried its best, but there were errors it couldn't
# resolve. At this point you should have seen other exceptions
# and given a chance to resolve them already.
await
self
.
plain_reply
(
msg
,
'I was not able to decrypt the message.'
)
return
None
except
(
Exception
,)
as
exn
:
await
self
.
plain_reply
(
msg
,
'An error occured while attempting decryption.
\n
%r'
%
exn
)
raise
...
...
Write
Preview
Markdown
is supported
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