diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b51a413..4f7993cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # Rojo Changelog ## Unreleased Changes +* Added support for specifying an address to be used by default in the .project.json file ([#447]) * Added support for the new Open Cloud API when uploading. ([#486]) +[#447]: https://github.com/rojo-rbx/rojo/issues/447 +[#486]: https://github.com/rojo-rbx/rojo/issues/486 + ## [7.0.0] - December 10, 2021 * Fixed Rojo's interactions with properties enabled by FFlags that are not yet enabled. ([#493]) * Improved output in Roblox Studio plugin when bad property data is encountered. @@ -10,7 +14,6 @@ * Connection settings are now remembered when reconnecting in Roblox Studio. ([#500]) * Updated reflection database to Roblox v503. -[#486]: https://github.com/rojo-rbx/rojo/issues/486 [#430]: https://github.com/rojo-rbx/rojo/issues/430 [#493]: https://github.com/rojo-rbx/rojo/pull/493 [#500]: https://github.com/rojo-rbx/rojo/pull/500 diff --git a/src/cli/serve.rs b/src/cli/serve.rs index abd3dd8e..56b46121 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -41,7 +41,10 @@ impl ServeCommand { let session = Arc::new(ServeSession::new(vfs, &project_path)?); - let ip = self.address.unwrap_or(DEFAULT_BIND_ADDRESS.into()); + let ip = self + .address + .or_else(|| session.serve_address()) + .unwrap_or(DEFAULT_BIND_ADDRESS.into()); let port = self .port diff --git a/src/project.rs b/src/project.rs index 088e6d97..d9edc820 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,6 +1,7 @@ use std::{ collections::{BTreeMap, HashMap, HashSet}, fs, io, + net::IpAddr, path::{Path, PathBuf}, }; @@ -67,6 +68,11 @@ pub struct Project { #[serde(skip_serializing_if = "Option::is_none")] pub game_id: Option, + /// If specified, this address will be used in place of the default address + /// As long as --address is unprovided. + #[serde(skip_serializing_if = "Option::is_none")] + pub serve_address: Option, + /// A list of globs, relative to the folder the project file is in, that /// match files that should be excluded if Rojo encounters them. #[serde(default, skip_serializing_if = "Vec::is_empty")] diff --git a/src/serve_session.rs b/src/serve_session.rs index 13b8037c..2643cffd 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -2,6 +2,7 @@ use std::{ borrow::Cow, collections::HashSet, io, + net::IpAddr, path::{Path, PathBuf}, sync::{Arc, Mutex, MutexGuard}, time::Instant, @@ -212,6 +213,10 @@ impl ServeSession { pub fn serve_place_ids(&self) -> Option<&HashSet> { self.root_project.serve_place_ids.as_ref() } + + pub fn serve_address(&self) -> Option { + self.root_project.serve_address + } } #[derive(Debug, Error)]