Compare commits
No commits in common. "6e13cef2371e20b9c023f9b9ace4439ee7bfbdf9" and "22fbe53710050822e4bee9f222b50b1c48f9b57f" have entirely different histories.
6e13cef237
...
22fbe53710
9 changed files with 275 additions and 151 deletions
|
|
@ -1,13 +1,9 @@
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tonic_prost_build::configure()
|
tonic_prost_build::configure()
|
||||||
.extern_path(".tripod_id", "::tripod_id::prost")
|
.extern_path(".tripod_id", "::tripod_id::prost::generated")
|
||||||
.compile_protos(
|
.compile_protos(
|
||||||
&[
|
&["proto/caretta_sync.proto", "proto/caretta_sync.common.proto"],
|
||||||
"proto/caretta_sync.authorization_request.proto",
|
&["proto"]
|
||||||
"proto/caretta_sync.peer_info.proto",
|
|
||||||
"proto/caretta_sync.common.proto"
|
|
||||||
],
|
|
||||||
&["proto", "../tripod-id/proto"]
|
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
package caretta_sync;
|
|
||||||
|
|
||||||
import "caretta_sync.common.proto";
|
|
||||||
import "tripod_id.proto";
|
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
import "google/protobuf/duration.proto";
|
|
||||||
|
|
||||||
service AuthorizationRequest {
|
|
||||||
rpc Send(AuthorizationRequestSendRequest) returns (AuthorizationRequestSendResponse);
|
|
||||||
rpc Accept(AuthorizationRequestAcceptRequest) returns (AuthorizationRequestAcceptResponse);
|
|
||||||
rpc Reject(AuthorizationRequestRejectRequest) returns (AuthorizationRequestRejectResponse);
|
|
||||||
rpc Info(AuthorizationRequestInfoRequest) returns (AuthorizationRequestInfoResponse);
|
|
||||||
rpc InfoStream(stream AuthorizationRequestInfoStreamRequest) returns (stream AuthorizationRequestInfoStreamResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum AuthorizationRequestKind {
|
|
||||||
SENT = 0;
|
|
||||||
RECEIVED = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestSendRequest {
|
|
||||||
caretta_sync.common.PeerIdentifier peer = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestSendResponse {
|
|
||||||
string passcode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestInfo {
|
|
||||||
tripod_id.Double id = 1;
|
|
||||||
caretta_sync.common.PublicKey public_key = 2;
|
|
||||||
google.protobuf.Timestamp created_at = 3;
|
|
||||||
AuthorizationRequestKind kind = 4;
|
|
||||||
string node_info = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message AuthorizationRequestIdentifier {
|
|
||||||
oneof identifier {
|
|
||||||
caretta_sync.common.Uuid uuid = 1;
|
|
||||||
tripod_id.Double id = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestAcceptRequest {
|
|
||||||
AuthorizationRequestIdentifier authorization_request = 1;
|
|
||||||
string passcode = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestAcceptResponse {
|
|
||||||
caretta_sync.common.AuthorizedNodeInfo authorized_node_info = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestRejectRequest {
|
|
||||||
AuthorizationRequestIdentifier authorization_request = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestRejectResponse {
|
|
||||||
AuthorizationRequestInfo request_info = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestInfoRequest {
|
|
||||||
AuthorizationRequestIdentifier request = 1;
|
|
||||||
}
|
|
||||||
message AuthorizationRequestInfoResponse{
|
|
||||||
AuthorizationRequestInfo info = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AuthorizationRequestInfoStreamRequest {}
|
|
||||||
|
|
||||||
message AuthorizationRequestInfoStreamResponse {
|
|
||||||
AuthorizationRequestInfo request_info = 1;
|
|
||||||
}
|
|
||||||
|
|
@ -8,27 +8,21 @@ message PublicKey {
|
||||||
bytes key = 1;
|
bytes key = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Uuid {
|
message UuidMessage {
|
||||||
uint64 first_half = 1;
|
uint64 first_half = 1;
|
||||||
uint64 second_half = 2;
|
uint64 second_half = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PeerIdentifier {
|
message PeerIdentifierMessage {
|
||||||
oneof peer_identifier {
|
oneof peer_identifier {
|
||||||
tripod_id.Double id = 1;
|
tripod_id.Double id = 1;
|
||||||
PublicKey public_key = 2;
|
PublicKey public_key = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message AuthorizedNodeIdentifier {
|
message PeerIdentifierErrorMessage {
|
||||||
oneof identifier {
|
oneof error {
|
||||||
tripod_id.Single id = 1;
|
string peer_id_not_found = 1;
|
||||||
PublicKey public_key = 2;
|
string public_key_not_found = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message AuthorizedNodeInfo {
|
|
||||||
tripod_id.Single id = 1;
|
|
||||||
PublicKey public_key = 2;
|
|
||||||
string note = 3;
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
package caretta_sync;
|
|
||||||
|
|
||||||
import "caretta_sync.common.proto";
|
|
||||||
import "tripod_id.proto";
|
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
import "google/protobuf/duration.proto";
|
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
service Peer {
|
|
||||||
rpc Info(PeerInfoRequest) returns (PeerInfoResponse);
|
|
||||||
rpc InfoStream(stream PeerInfoStreamRequest) returns (stream PeerInfoStreamResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
message PeerInfoRequest {
|
|
||||||
caretta_sync.common.PeerIdentifier peer = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PeerInfoStreamRequest {}
|
|
||||||
|
|
||||||
message PeerInfoResponse {
|
|
||||||
PeerInfo peer_info = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PeerInfoStreamResponse {
|
|
||||||
PeerInfo peer_info = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PeerInfo {
|
|
||||||
tripod_id.Double id = 1;
|
|
||||||
caretta_sync.common.PublicKey public_key = 2;
|
|
||||||
string relay_url = 3;
|
|
||||||
repeated DirectAddrInfo addrs = 4;
|
|
||||||
string conn_type = 5;
|
|
||||||
google.protobuf.Duration latency = 6;
|
|
||||||
google.protobuf.Duration last_used = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DirectAddrInfo {
|
|
||||||
string addr = 1;
|
|
||||||
google.protobuf.Duration latency = 2;
|
|
||||||
LastControl last_control = 3;
|
|
||||||
google.protobuf.Duration last_payload = 4;
|
|
||||||
google.protobuf.Duration last_alive = 5;
|
|
||||||
repeated Source sources = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LastControl {
|
|
||||||
google.protobuf.Duration duration = 1;
|
|
||||||
string control_msg = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Source {
|
|
||||||
string source = 1;
|
|
||||||
google.protobuf.Duration duration = 2;
|
|
||||||
}
|
|
||||||
51
core/proto/caretta_sync.proto
Normal file
51
core/proto/caretta_sync.proto
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package caretta_sync;
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
|
|
||||||
|
service CarettaSync {
|
||||||
|
rpc RemoteInfo(RemoteInfoRequest) returns (RemoteInfoResponse);
|
||||||
|
rpc RemoteInfoIter(RemoteInfoIterRequest) returns (stream RemoteInfoResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
message NodeIdMessage {
|
||||||
|
bytes node_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteInfoRequest {
|
||||||
|
NodeIdMessage node_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteInfoIterRequest {}
|
||||||
|
|
||||||
|
message RemoteInfoResponse {
|
||||||
|
RemoteInfoMessage remote_info = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteInfoMessage {
|
||||||
|
NodeIdMessage node_id = 1;
|
||||||
|
string relay_url = 2;
|
||||||
|
repeated DirectAddrInfoMessage addrs = 3;
|
||||||
|
string conn_type = 4;
|
||||||
|
google.protobuf.Duration latency = 5;
|
||||||
|
google.protobuf.Duration last_used = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DirectAddrInfoMessage {
|
||||||
|
string addr = 1;
|
||||||
|
google.protobuf.Duration latency = 2;
|
||||||
|
LastControlMessage last_control = 3;
|
||||||
|
google.protobuf.Duration last_payload = 4;
|
||||||
|
google.protobuf.Duration last_alive = 5;
|
||||||
|
repeated SourceMessage sources = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LastControlMessage {
|
||||||
|
google.protobuf.Duration duration = 1;
|
||||||
|
string control_msg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SourceMessage {
|
||||||
|
string source = 1;
|
||||||
|
google.protobuf.Duration duration = 2;
|
||||||
|
}
|
||||||
97
core/proto/caretta_sync/peer_info.proto
Normal file
97
core/proto/caretta_sync/peer_info.proto
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package caretta_sync;
|
||||||
|
|
||||||
|
import "common.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
service PeerInfo {
|
||||||
|
rpc PeerInfo(PeerInfoRequest) returns (PeerInfoResponse);
|
||||||
|
rpc PeerInfoIter(PeerInfoIterRequest) returns (stream PeerInfoResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message PeerInfoRequest {
|
||||||
|
caretta_sync.common.PeerIdentifierMessage peer = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PeerInfoIterRequest {}
|
||||||
|
|
||||||
|
message PeerInfoResponse {
|
||||||
|
oneof result {
|
||||||
|
PeerInfoMessage remote_info = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message PeerInfoMessage {
|
||||||
|
DoubleIdMessage id = 1;
|
||||||
|
PublicKeyMessage public_key = 2;
|
||||||
|
string relay_url = 3;
|
||||||
|
repeated DirectAddrInfoMessage addrs = 4;
|
||||||
|
string conn_type = 5;
|
||||||
|
google.protobuf.Duration latency = 6;
|
||||||
|
google.protobuf.Duration last_used = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DirectAddrInfoMessage {
|
||||||
|
string addr = 1;
|
||||||
|
google.protobuf.Duration latency = 2;
|
||||||
|
LastControlMessage last_control = 3;
|
||||||
|
google.protobuf.Duration last_payload = 4;
|
||||||
|
google.protobuf.Duration last_alive = 5;
|
||||||
|
repeated SourceMessage sources = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LastControlMessage {
|
||||||
|
google.protobuf.Duration duration = 1;
|
||||||
|
string control_msg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SourceMessage {
|
||||||
|
string source = 1;
|
||||||
|
google.protobuf.Duration duration = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendAuthorizationRequestRequest {
|
||||||
|
PeerMessage peer = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
string passcode = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message AuthorizationRequestMessage {
|
||||||
|
oneof authorization_request {
|
||||||
|
UuidMessage uuid = 1;
|
||||||
|
DoubleIdMessage id = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcceptAuthorizationRequestRequest {
|
||||||
|
AuthorizationRequestMessage authorization_request = 1;
|
||||||
|
string passcode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcceptAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
google.protobuf.Empty ok = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message RejectAuthorizationRequestRequest {
|
||||||
|
AuthorizationRequestMessage authorization_request = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RejectAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
google.protobuf.Empty ok = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
99
core/proto/caretta_sync/service.proto
Normal file
99
core/proto/caretta_sync/service.proto
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package caretta_sync;
|
||||||
|
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
service CarettaSync {
|
||||||
|
rpc SendAuthorizationRequest(SendAuthorizationRequestRequest) returns (SendAuthorizationRequestResponse);
|
||||||
|
rpc AcceptAuthorizationRequest(AcceptAuthorizationRequestRequest) returns (AcceptAuthorizationRequestResponse);
|
||||||
|
rpc RejectAuthorizationRequest(RejectAuthorizationRequestRequest) returns (RejectAuthorizationRequestResponse);
|
||||||
|
rpc RemoteInfo(RemoteInfoRequest) returns (RemoteInfoResponse);
|
||||||
|
rpc RemoteInfoIter(RemoteInfoIterRequest) returns (stream RemoteInfoResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message RemoteInfoRequest {
|
||||||
|
PeerMessage peer = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteInfoIterRequest {}
|
||||||
|
|
||||||
|
message RemoteInfoResponse {
|
||||||
|
oneof result {
|
||||||
|
RemoteInfoMessage remote_info = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteInfoMessage {
|
||||||
|
DoubleIdMessage id = 1;
|
||||||
|
PublicKeyMessage public_key = 2;
|
||||||
|
string relay_url = 3;
|
||||||
|
repeated DirectAddrInfoMessage addrs = 4;
|
||||||
|
string conn_type = 5;
|
||||||
|
google.protobuf.Duration latency = 6;
|
||||||
|
google.protobuf.Duration last_used = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DirectAddrInfoMessage {
|
||||||
|
string addr = 1;
|
||||||
|
google.protobuf.Duration latency = 2;
|
||||||
|
LastControlMessage last_control = 3;
|
||||||
|
google.protobuf.Duration last_payload = 4;
|
||||||
|
google.protobuf.Duration last_alive = 5;
|
||||||
|
repeated SourceMessage sources = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LastControlMessage {
|
||||||
|
google.protobuf.Duration duration = 1;
|
||||||
|
string control_msg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SourceMessage {
|
||||||
|
string source = 1;
|
||||||
|
google.protobuf.Duration duration = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendAuthorizationRequestRequest {
|
||||||
|
PeerMessage peer = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
string passcode = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message AuthorizationRequestMessage {
|
||||||
|
oneof authorization_request {
|
||||||
|
UuidMessage uuid = 1;
|
||||||
|
DoubleIdMessage id = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcceptAuthorizationRequestRequest {
|
||||||
|
AuthorizationRequestMessage authorization_request = 1;
|
||||||
|
string passcode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcceptAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
google.protobuf.Empty ok = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message RejectAuthorizationRequestRequest {
|
||||||
|
AuthorizationRequestMessage authorization_request = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RejectAuthorizationRequestResponse {
|
||||||
|
oneof result {
|
||||||
|
google.protobuf.Empty ok = 1;
|
||||||
|
Error error = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
core/proto/tripod_id.proto
Normal file
17
core/proto/tripod_id.proto
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package tripod_id;
|
||||||
|
|
||||||
|
// Single size tripod id message
|
||||||
|
message Single {
|
||||||
|
uint32 id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Double size tripod id message
|
||||||
|
message Double {
|
||||||
|
uint32 id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Triple size tripod id message
|
||||||
|
message Triple {
|
||||||
|
uint64 id = 1;
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
pub mod generated {
|
pub mod generated {
|
||||||
include!(concat!(env!("OUT_DIR"), "/tripod_id.rs"));
|
include!(concat!(env!("OUT_DIR"), "/fireturtle.tripod_id.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mod single;
|
mod single;
|
||||||
|
|
@ -9,7 +9,7 @@ mod triple;
|
||||||
pub use generated::*;
|
pub use generated::*;
|
||||||
|
|
||||||
use crate::TripodId;
|
use crate::TripodId;
|
||||||
const PACKAGE_NAME: &'static str = "tripod_id";
|
const PACKAGE_NAME: &'static str = "fireturtle.tripod_id";
|
||||||
pub type SingleMessage = Single;
|
pub type SingleMessage = Single;
|
||||||
pub type DoubleMessage = Double;
|
pub type DoubleMessage = Double;
|
||||||
pub type TripleMessage = Triple;
|
pub type TripleMessage = Triple;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue