diff --git a/build.rs b/build.rs index 1557229..b1e1916 100644 --- a/build.rs +++ b/build.rs @@ -7,11 +7,7 @@ fn main() -> Result<(), Box> { "#[derive(serde::Serialize, serde::Deserialize)]", ) .type_attribute( - ".vm_proto.MappedPort", - "#[derive(serde::Serialize, serde::Deserialize)]", - ) - .type_attribute( - ".app_proto.MappedPort", + ".common_proto.MappedPort", "#[derive(serde::Serialize, serde::Deserialize)]", ) .type_attribute( diff --git a/proto/sgx/app.proto b/proto/sgx/app.proto index 68a6240..bc46b35 100644 --- a/proto/sgx/app.proto +++ b/proto/sgx/app.proto @@ -11,7 +11,7 @@ message AppContract { string node_pubkey = 4; string public_ipv4 = 5; AppResource resource = 6; - repeated MappedPort mapped_ports = 7; + repeated common_proto.MappedPort mapped_ports = 7; string created_at = 8; string updated_at = 9; uint64 nano_per_minute = 10; @@ -44,16 +44,11 @@ message AppResource { message NewAppRes { string uuid = 1; - string status = 2; - string ip_address = 3; - repeated MappedPort mapped_ports = 4; - string error = 5; + string ip_address = 2; + repeated common_proto.MappedPort mapped_ports = 3; + string error = 4; } -message MappedPort { - uint32 host_port = 1; - uint32 app_port = 2; -} message DelAppReq { string uuid= 1; @@ -76,6 +71,7 @@ message AppNodeFilters { string city = 6; string ip = 7; string node_pubkey = 8; + uint32 free_ports = 9; } message AppNodeListResp { @@ -90,7 +86,7 @@ message AppNodeListResp { } service BrainAppCli { - rpc DeployApp (NewAppReq) returns (NewAppRes); + rpc NewApp (NewAppReq) returns (NewAppRes); rpc DeleteApp (DelAppReq) returns (common_proto.Empty); rpc ListAppContracts (ListAppContractsReq) returns (stream AppContract); rpc ListAppNodes (AppNodeFilters) returns (stream AppNodeListResp); diff --git a/proto/shared/common.proto b/proto/shared/common.proto index 65d8b1e..8db07c6 100644 --- a/proto/shared/common.proto +++ b/proto/shared/common.proto @@ -7,3 +7,8 @@ message Empty { message Pubkey { string pubkey = 1; } + +message MappedPort { + uint32 host_port = 1; + uint32 guest_port = 2; +} diff --git a/proto/snp/vm.proto b/proto/snp/vm.proto index 06a09a5..fd886d8 100644 --- a/proto/snp/vm.proto +++ b/proto/snp/vm.proto @@ -3,11 +3,6 @@ package vm_proto; import "shared/common.proto"; -message MappedPort { - uint32 host_port = 1; - uint32 guest_port = 2; -} - message VmContract { string uuid = 1; string hostname = 2; @@ -15,7 +10,7 @@ message VmContract { string node_pubkey = 4; string node_ip = 5; string location = 6; - repeated MappedPort mapped_ports = 7; + repeated common_proto.MappedPort mapped_ports = 7; string vm_public_ipv4 = 8; string vm_public_ipv6 = 9; uint32 disk_size_gb = 10; diff --git a/src/sgx/types/brain.rs b/src/sgx/types/brain.rs index 904b452..53c525d 100644 --- a/src/sgx/types/brain.rs +++ b/src/sgx/types/brain.rs @@ -1,5 +1,6 @@ use crate::app_proto::{daemon_message_app, AppNodeResources, DaemonMessageApp}; -use crate::app_proto::{AppResource, DaemonAuth, MappedPort, NewAppReq, NewAppRes}; +use crate::app_proto::{AppResource, DaemonAuth, NewAppReq, NewAppRes}; +use crate::common_proto::MappedPort; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] @@ -93,14 +94,14 @@ impl From<(u16, u16)> for MappedPort { fn from(val: (u16, u16)) -> Self { Self { host_port: val.0 as u32, - app_port: val.1 as u32, + guest_port: val.1 as u32, } } } impl From for (u16, u16) { fn from(val: MappedPort) -> Self { - (val.host_port as u16, val.app_port as u16) + (val.host_port as u16, val.guest_port as u16) } }