cargo clippy
This commit is contained in:
@@ -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)]
|
#[derive(Clone, Copy, Debug, Default, Display, EnumIter, PartialEq)]
|
||||||
pub enum BlockedStatus {
|
pub enum BlockedStatus {
|
||||||
#[default]
|
#[default]
|
||||||
NotBlocked,
|
Unblocked,
|
||||||
ServerBlocked,
|
Server,
|
||||||
ExeBlocked,
|
Executable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -29,11 +29,11 @@ impl Default for GameNetworking {
|
|||||||
let firewall = Firewall::default();
|
let firewall = Firewall::default();
|
||||||
Self {
|
Self {
|
||||||
blocked: if firewall.is_blocked(FILTER_NAME_SAVE_SERVER).unwrap() {
|
blocked: if firewall.is_blocked(FILTER_NAME_SAVE_SERVER).unwrap() {
|
||||||
BlockedStatus::ServerBlocked
|
BlockedStatus::Server
|
||||||
} else if firewall.is_blocked(FILTER_NAME_EXE).unwrap() {
|
} else if firewall.is_blocked(FILTER_NAME_EXE).unwrap() {
|
||||||
BlockedStatus::ExeBlocked
|
BlockedStatus::Executable
|
||||||
} else {
|
} else {
|
||||||
BlockedStatus::NotBlocked
|
BlockedStatus::Unblocked
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,13 +52,13 @@ impl GameNetworking {
|
|||||||
RuleDirection::Out,
|
RuleDirection::Out,
|
||||||
RuleProtocol::Any,
|
RuleProtocol::Any,
|
||||||
)
|
)
|
||||||
.inspect(|_| self.blocked = BlockedStatus::ExeBlocked)
|
.inspect(|_| self.blocked = BlockedStatus::Executable)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unblock_exe(&mut self, firewall: &Firewall) -> Result<()> {
|
pub fn unblock_exe(&mut self, firewall: &Firewall) -> Result<()> {
|
||||||
firewall
|
firewall
|
||||||
.remove(FILTER_NAME_EXE)
|
.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<()> {
|
pub fn block_save_server(&mut self, save_server_ip: &str, firewall: &Firewall) -> Result<()> {
|
||||||
@@ -69,13 +69,13 @@ impl GameNetworking {
|
|||||||
RuleDirection::Out,
|
RuleDirection::Out,
|
||||||
RuleProtocol::Any,
|
RuleProtocol::Any,
|
||||||
)
|
)
|
||||||
.inspect(|_| self.blocked = BlockedStatus::ServerBlocked)
|
.inspect(|_| self.blocked = BlockedStatus::Server)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unblock_save_server(&mut self, firewall: &Firewall) -> Result<()> {
|
pub fn unblock_save_server(&mut self, firewall: &Firewall) -> Result<()> {
|
||||||
firewall
|
firewall
|
||||||
.remove(FILTER_NAME_SAVE_SERVER)
|
.remove(FILTER_NAME_SAVE_SERVER)
|
||||||
.inspect(|_| self.blocked = BlockedStatus::NotBlocked)
|
.inspect(|_| self.blocked = BlockedStatus::Unblocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_block_exclusivity(
|
pub fn ensure_block_exclusivity(
|
||||||
@@ -85,12 +85,12 @@ impl GameNetworking {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match block_method {
|
match block_method {
|
||||||
BlockMethod::EntireGame => {
|
BlockMethod::EntireGame => {
|
||||||
if self.blocked == BlockedStatus::ServerBlocked {
|
if self.blocked == BlockedStatus::Server {
|
||||||
self.unblock_save_server(firewall)?;
|
self.unblock_save_server(firewall)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockMethod::SaveServer => {
|
BlockMethod::SaveServer => {
|
||||||
if self.blocked == BlockedStatus::ExeBlocked {
|
if self.blocked == BlockedStatus::Executable {
|
||||||
self.unblock_exe(firewall)?;
|
self.unblock_exe(firewall)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -164,12 +164,12 @@ impl App {
|
|||||||
};
|
};
|
||||||
ui.add_space(1.0);
|
ui.add_space(1.0);
|
||||||
ui.create_indicator_dot(match self.game_networking.blocked {
|
ui.create_indicator_dot(match self.game_networking.blocked {
|
||||||
BlockedStatus::ExeBlocked
|
BlockedStatus::Executable
|
||||||
if self.settings.block_method == BlockMethod::EntireGame =>
|
if self.settings.block_method == BlockMethod::EntireGame =>
|
||||||
{
|
{
|
||||||
colours::RED
|
colours::RED
|
||||||
}
|
}
|
||||||
BlockedStatus::ServerBlocked
|
BlockedStatus::Server
|
||||||
if self.settings.block_method == BlockMethod::SaveServer =>
|
if self.settings.block_method == BlockMethod::SaveServer =>
|
||||||
{
|
{
|
||||||
colours::RED
|
colours::RED
|
||||||
|
|||||||
+2
-2
@@ -42,9 +42,9 @@ impl Logger {
|
|||||||
|
|
||||||
fn log_to_file(&self, record: &log::Record) {
|
fn log_to_file(&self, record: &log::Record) {
|
||||||
let mut file = self.file.lock().unwrap();
|
let mut file = self.file.lock().unwrap();
|
||||||
write!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
"[{}][{}] {}\n",
|
"[{}][{}] {}",
|
||||||
humantime::format_rfc3339_seconds(SystemTime::now()),
|
humantime::format_rfc3339_seconds(SystemTime::now()),
|
||||||
record.level(),
|
record.level(),
|
||||||
record.args()
|
record.args()
|
||||||
|
|||||||
Reference in New Issue
Block a user