Skip to content

Commit

Permalink
Merge pull request #243 from whisperfish/server-guid
Browse files Browse the repository at this point in the history
Add server_guid to Metadata
  • Loading branch information
rubdos committed Jan 4, 2024
2 parents 9d55add + 6a8b73a commit daad1fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libsignal-service/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ where
});
};

let server_guid =
envelope.server_guid.as_ref().and_then(|g| match g.parse() {
Ok(uuid) => Some(uuid),
Err(e) => {
log::error!("Unparseable server_guid ({})", e);
None
},
});

use crate::proto::envelope::Type;
let plaintext = match envelope.r#type() {
Type::PrekeyBundle => {
Expand All @@ -118,6 +127,7 @@ where
timestamp: envelope.server_timestamp(),
needs_receipt: false,
unidentified_sender: false,
server_guid,
};

let mut data = message_decrypt_prekey(
Expand Down Expand Up @@ -154,6 +164,7 @@ where
timestamp: envelope.server_timestamp(),
needs_receipt: false,
unidentified_sender: false,
server_guid,
};
Plaintext {
metadata,
Expand All @@ -173,6 +184,7 @@ where
timestamp: envelope.timestamp(),
needs_receipt: false,
unidentified_sender: false,
server_guid,
};

let mut data = message_decrypt_signal(
Expand Down Expand Up @@ -241,6 +253,7 @@ where
timestamp: envelope.timestamp(),
unidentified_sender: true,
needs_receipt,
server_guid,
};

strip_padding(&mut message)?;
Expand Down
6 changes: 6 additions & 0 deletions libsignal-service/src/content.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use libsignal_protocol::ProtocolAddress;
use uuid::Uuid;

pub use crate::{
proto::{
Expand All @@ -22,6 +23,11 @@ pub struct Metadata {
pub timestamp: u64,
pub needs_receipt: bool,
pub unidentified_sender: bool,

/// A unique UUID for this specific message, produced by the Signal servers.
///
/// The server GUID is used to report spam messages.
pub server_guid: Option<Uuid>,
}

impl Metadata {
Expand Down

0 comments on commit daad1fc

Please sign in to comment.