Refactor MappedPort usage to common_proto and update related structures

This commit is contained in:
Noor 2025-05-09 15:55:43 +05:30
parent d0d4622c52
commit 0d4b712fad
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
5 changed files with 13 additions and 20 deletions

@ -7,11 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"#[derive(serde::Serialize, serde::Deserialize)]", "#[derive(serde::Serialize, serde::Deserialize)]",
) )
.type_attribute( .type_attribute(
".vm_proto.MappedPort", ".common_proto.MappedPort",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".app_proto.MappedPort",
"#[derive(serde::Serialize, serde::Deserialize)]", "#[derive(serde::Serialize, serde::Deserialize)]",
) )
.type_attribute( .type_attribute(

@ -11,7 +11,7 @@ message AppContract {
string node_pubkey = 4; string node_pubkey = 4;
string public_ipv4 = 5; string public_ipv4 = 5;
AppResource resource = 6; AppResource resource = 6;
repeated MappedPort mapped_ports = 7; repeated common_proto.MappedPort mapped_ports = 7;
string created_at = 8; string created_at = 8;
string updated_at = 9; string updated_at = 9;
uint64 nano_per_minute = 10; uint64 nano_per_minute = 10;
@ -46,14 +46,10 @@ message NewAppRes {
string uuid = 1; string uuid = 1;
string status = 2; string status = 2;
string ip_address = 3; string ip_address = 3;
repeated MappedPort mapped_ports = 4; repeated common_proto.MappedPort mapped_ports = 4;
string error = 5; string error = 5;
} }
message MappedPort {
uint32 host_port = 1;
uint32 app_port = 2;
}
message DelAppReq { message DelAppReq {
string uuid= 1; string uuid= 1;

@ -7,3 +7,8 @@ message Empty {
message Pubkey { message Pubkey {
string pubkey = 1; string pubkey = 1;
} }
message MappedPort {
uint32 host_port = 1;
uint32 guest_port = 2;
}

@ -3,11 +3,6 @@ package vm_proto;
import "shared/common.proto"; import "shared/common.proto";
message MappedPort {
uint32 host_port = 1;
uint32 guest_port = 2;
}
message VmContract { message VmContract {
string uuid = 1; string uuid = 1;
string hostname = 2; string hostname = 2;
@ -15,7 +10,7 @@ message VmContract {
string node_pubkey = 4; string node_pubkey = 4;
string node_ip = 5; string node_ip = 5;
string location = 6; string location = 6;
repeated MappedPort mapped_ports = 7; repeated common_proto.MappedPort mapped_ports = 7;
string vm_public_ipv4 = 8; string vm_public_ipv4 = 8;
string vm_public_ipv6 = 9; string vm_public_ipv6 = 9;
uint32 disk_size_gb = 10; uint32 disk_size_gb = 10;

@ -1,5 +1,6 @@
use crate::app_proto::{daemon_message_app, AppNodeResources, DaemonMessageApp}; 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}; use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
@ -93,14 +94,14 @@ impl From<(u16, u16)> for MappedPort {
fn from(val: (u16, u16)) -> Self { fn from(val: (u16, u16)) -> Self {
Self { Self {
host_port: val.0 as u32, host_port: val.0 as u32,
app_port: val.1 as u32, guest_port: val.1 as u32,
} }
} }
} }
impl From<MappedPort> for (u16, u16) { impl From<MappedPort> for (u16, u16) {
fn from(val: MappedPort) -> Self { 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)
} }
} }