1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use futures::future::FutureExt;
use log::info;
use structopt::StructOpt;
use tonic::transport::Server;
#[allow(clippy::wrong_self_convention)]
pub mod proto {
include!("codegen/tink_testing_api.rs");
}
mod aead_service;
use aead_service::*;
mod daead_service;
use daead_service::*;
mod keyset_service;
use keyset_service::*;
mod mac_service;
use mac_service::*;
mod metadata_service;
use metadata_service::*;
mod prf_set_service;
use prf_set_service::*;
mod signature_service;
use signature_service::*;
mod streaming_service;
use streaming_service::*;
#[derive(Debug, StructOpt)]
#[structopt(about = "Tink test server")]
struct Opt {
#[structopt(long, default_value = "10000", help = "Port number.")]
port: u16,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let opt = Opt::from_args();
env_logger::init();
tink_aead::init();
tink_daead::init();
tink_mac::init();
tink_prf::init();
tink_signature::init();
tink_streaming_aead::init();
info!("Running testing server");
let metadata_handler = MetadataServerImpl {};
let keyset_handler = KeysetServerImpl {};
let aead_handler = AeadServerImpl {};
let daead_handler = DaeadServerImpl {};
let mac_handler = MacServerImpl {};
let prf_set_handler = PrfSetServerImpl {};
let signature_handler = SignatureServerImpl {};
let streaming_handler = StreamingAeadServerImpl {};
let address = format!("[::]:{}", opt.port).parse()?;
info!("Starting gRPC server at {:?}", address);
Server::builder()
.add_service(proto::metadata_server::MetadataServer::new(
metadata_handler,
))
.add_service(proto::keyset_server::KeysetServer::new(keyset_handler))
.add_service(proto::aead_server::AeadServer::new(aead_handler))
.add_service(proto::deterministic_aead_server::DeterministicAeadServer::new(daead_handler))
.add_service(proto::mac_server::MacServer::new(mac_handler))
.add_service(proto::prf_set_server::PrfSetServer::new(prf_set_handler))
.add_service(proto::signature_server::SignatureServer::new(
signature_handler,
))
.add_service(proto::streaming_aead_server::StreamingAeadServer::new(
streaming_handler,
))
.serve_with_shutdown(address, tokio::signal::ctrl_c().map(|r| r.unwrap()))
.await?;
Ok(())
}