diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..25a489e --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,26 @@ +name: Build + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --release --verbose + - name: Check formatting + run: cargo fmt --check + - name: Clippy + run: cargo clippy + - name: Upload + uses: actions/upload-artifact@v6 + with: + name: gta-tools + path: target/release/gta-tools.exe diff --git a/src/features/game_networking.rs b/src/features/game_networking.rs index ced99c8..9d98045 100644 --- a/src/features/game_networking.rs +++ b/src/features/game_networking.rs @@ -14,9 +14,9 @@ const FILTER_NAME_SAVE_SERVER: &str = "[GTA Tools] Block outbound traffic to Roc #[derive(Clone, Copy, Debug, Default, Display, EnumIter, PartialEq)] pub enum BlockedStatus { #[default] - NotBlocked, - ServerBlocked, - ExeBlocked, + Unblocked, + Server, + Executable, } #[derive(Debug)] @@ -29,11 +29,11 @@ impl Default for GameNetworking { let firewall = Firewall::default(); Self { blocked: if firewall.is_blocked(FILTER_NAME_SAVE_SERVER).unwrap() { - BlockedStatus::ServerBlocked + BlockedStatus::Server } else if firewall.is_blocked(FILTER_NAME_EXE).unwrap() { - BlockedStatus::ExeBlocked + BlockedStatus::Executable } else { - BlockedStatus::NotBlocked + BlockedStatus::Unblocked }, } } @@ -52,13 +52,13 @@ impl GameNetworking { RuleDirection::Out, RuleProtocol::Any, ) - .inspect(|_| self.blocked = BlockedStatus::ExeBlocked) + .inspect(|_| self.blocked = BlockedStatus::Executable) } pub fn unblock_exe(&mut self, firewall: &Firewall) -> Result<()> { firewall .remove(FILTER_NAME_EXE) - .inspect(|_| self.blocked = BlockedStatus::NotBlocked) + .inspect(|_| self.blocked = BlockedStatus::Unblocked) } pub fn block_save_server(&mut self, save_server_ip: &str, firewall: &Firewall) -> Result<()> { @@ -69,13 +69,13 @@ impl GameNetworking { RuleDirection::Out, RuleProtocol::Any, ) - .inspect(|_| self.blocked = BlockedStatus::ServerBlocked) + .inspect(|_| self.blocked = BlockedStatus::Server) } pub fn unblock_save_server(&mut self, firewall: &Firewall) -> Result<()> { firewall .remove(FILTER_NAME_SAVE_SERVER) - .inspect(|_| self.blocked = BlockedStatus::NotBlocked) + .inspect(|_| self.blocked = BlockedStatus::Unblocked) } pub fn ensure_block_exclusivity( @@ -85,12 +85,12 @@ impl GameNetworking { ) -> Result<()> { match block_method { BlockMethod::EntireGame => { - if self.blocked == BlockedStatus::ServerBlocked { + if self.blocked == BlockedStatus::Server { self.unblock_save_server(firewall)?; } } BlockMethod::SaveServer => { - if self.blocked == BlockedStatus::ExeBlocked { + if self.blocked == BlockedStatus::Executable { self.unblock_exe(firewall)?; } } diff --git a/src/gui/app.rs b/src/gui/app.rs index da3f097..70fad35 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -164,12 +164,12 @@ impl App { }; ui.add_space(1.0); ui.create_indicator_dot(match self.game_networking.blocked { - BlockedStatus::ExeBlocked + BlockedStatus::Executable if self.settings.block_method == BlockMethod::EntireGame => { colours::RED } - BlockedStatus::ServerBlocked + BlockedStatus::Server if self.settings.block_method == BlockMethod::SaveServer => { colours::RED diff --git a/src/util/logging.rs b/src/util/logging.rs index 60f2147..c738554 100644 --- a/src/util/logging.rs +++ b/src/util/logging.rs @@ -42,9 +42,9 @@ impl Logger { fn log_to_file(&self, record: &log::Record) { let mut file = self.file.lock().unwrap(); - write!( + writeln!( file, - "[{}][{}] {}\n", + "[{}][{}] {}", humantime::format_rfc3339_seconds(SystemTime::now()), record.level(), record.args()