Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions src/features/game_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
},
}
}
Expand All @@ -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<()> {
Expand All @@ -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(
Expand All @@ -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)?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/util/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down