Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Add new UDP specific options
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Sep 11, 2022
1 parent 882ab1f commit fa66bb2
Show file tree
Hide file tree
Showing 19 changed files with 4,841 additions and 383 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 48 additions & 15 deletions core/src/config/version/mm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,57 @@ pub mod game_mode {
#[derive(Debug, Deserialize)]
pub struct Docker {
pub build: Option<String>,
pub ports: HashMap<String, Port>,
#[serde(default)]
pub args: Vec<String>,
#[serde(default)]
pub env: HashMap<String, String>,
pub ports: HashMap<String, Port>,
pub network_mode: NetworkMode,
}

#[derive(Debug, Deserialize)]
pub struct Port {
pub target: u32,
pub target: Option<u32>,
pub range: Option<PortRange>,
pub proto: ProxyProtocol,
}

#[derive(Debug, Deserialize)]
pub struct PortRange {
pub min: u16,
pub max: u16,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ProxyProtocol {
Http,
Https,
Udp,
}

impl ProxyProtocol {
pub fn build_model(&self) -> rivet_cloud::model::ProxyProtocol {
match self {
ProxyProtocol::Http => rivet_cloud::model::ProxyProtocol::Http,
ProxyProtocol::Https => rivet_cloud::model::ProxyProtocol::Https,
ProxyProtocol::Udp => rivet_cloud::model::ProxyProtocol::Udp,
}
}
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum NetworkMode {
Bridge,
Host,
}

impl NetworkMode {
pub fn build_model(&self) -> rivet_cloud::model::NetworkMode {
match self {
NetworkMode::Bridge => rivet_cloud::model::NetworkMode::Bridge,
NetworkMode::Host => rivet_cloud::model::NetworkMode::Host,
}
}
}
Expand Down Expand Up @@ -141,19 +167,6 @@ pub mod game_mode {
})?,
)
.set_args(Some(docker.args.clone()))
.set_ports(Some(
docker
.ports
.iter()
.map(|(label, port)| {
LobbyGroupRuntimeDockerPort::builder()
.label(label)
.target_port(port.target as i32)
.proxy_protocol(port.proto.build_model())
.build()
})
.collect(),
))
.set_env_vars(Some(
docker
.env
Expand All @@ -166,6 +179,26 @@ pub mod game_mode {
})
.collect(),
))
.network_mode(docker.network_mode.build_model())
.set_ports(Some(
docker
.ports
.iter()
.map(|(label, port)| {
LobbyGroupRuntimeDockerPort::builder()
.label(label)
.set_target_port(port.target.map(|x| x as i32))
.set_port_range(port.range.as_ref().map(|range| {
PortRange::builder()
.min(range.min as i32)
.max(range.max as i32)
.build()
}))
.proxy_protocol(port.proto.build_model())
.build()
})
.collect(),
))
.build(),
),
};
Expand Down
16 changes: 16 additions & 0 deletions lib/rivet-cloud-server/rust-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
[package]
name = "rivet-cloud-server"
version = "0.0.1"
authors = ["Rivet <developer@rivet.gg>"]
edition = "2021"
license = "Apache-2.0"

[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = "0.4"
1 change: 1 addition & 0 deletions lib/rivet-cloud-server/rust-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod models;
Loading

0 comments on commit fa66bb2

Please sign in to comment.