Skip to content

Commit

Permalink
Add Signal protobuf files and compile them to Rust.
Browse files Browse the repository at this point in the history
It would be cleaner to yield the compiled files OUT_DIR, but that gets
ugly very fast because of
rust-lang/rust#48250.
  • Loading branch information
rubdos committed Jun 20, 2020
1 parent 02476a6 commit fa6dd29
Show file tree
Hide file tree
Showing 9 changed files with 556 additions and 0 deletions.
1 change: 1 addition & 0 deletions libsignal-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/proto/*.rs
6 changes: 6 additions & 0 deletions libsignal-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ failure = "0.1.5"
async-trait = "0.1.30"
url = "2.1.1"
thiserror = "1.0"
serde = {version = "1.0", features=["derive"]}
serde_json = "1.0"
prost = "0.6"

[dev-dependencies]
structopt = "0.2.17"
tokio = { version = "0.2", features=["macros"] }

[build-dependencies]
prost-build = "0.6"
25 changes: 25 additions & 0 deletions libsignal-service/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::path::Path;

fn main() {
let protobuf = Path::new("protobuf").to_owned();

let input: Vec<_> = protobuf
.read_dir()
.expect("protobuf directory")
.filter_map(|entry| {
let entry = entry.expect("readable protobuf directory");
let path = entry.path();
if Some("proto")
== path.extension().and_then(std::ffi::OsStr::to_str)
{
assert!(path.is_file());
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
Some(path)
} else {
None
}
})
.collect();

prost_build::compile_protos(&input, &[protobuf]).unwrap();
}
36 changes: 36 additions & 0 deletions libsignal-service/protobuf/Provisioning.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
syntax = "proto2";

package signalservice;

option java_package = "org.whispersystems.signalservice.internal.push";
option java_outer_classname = "ProvisioningProtos";

message ProvisionEnvelope {
optional bytes publicKey = 1;
optional bytes body = 2; // Encrypted ProvisionMessage
}

message ProvisionMessage {
optional bytes identityKeyPublic = 1;
optional bytes identityKeyPrivate = 2;
optional string number = 3;
optional string uuid = 8;
optional string provisioningCode = 4;
optional string userAgent = 5;
optional bytes profileKey = 6;
optional bool readReceipts = 7;
optional uint32 provisioningVersion = 9;
}

enum ProvisioningVersion {
option allow_alias = true;

INITIAL = 0;
TABLET_SUPPORT = 1;
CURRENT = 1;
}
Loading

0 comments on commit fa6dd29

Please sign in to comment.