添加报复社会模式:)
This commit is contained in:
@@ -22,6 +22,7 @@ pub struct LANToolkit {
|
||||
pub test_message: TestState,
|
||||
pub spoof_state: SpoofState,
|
||||
pub spoof_btn_text: String,
|
||||
pub mode: Mode,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@@ -29,7 +30,9 @@ pub enum Messages {
|
||||
RefreshIfaces,
|
||||
IfaceSelected(Option<usize>),
|
||||
TestIface,
|
||||
StartSpoof(bool),
|
||||
// Running, Random
|
||||
StartSpoof(bool, bool),
|
||||
ModeSwitch,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@@ -50,6 +53,21 @@ pub enum SpoofState {
|
||||
Online,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum Mode {
|
||||
Standard,
|
||||
Random
|
||||
}
|
||||
|
||||
impl Display for Mode {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Standard => write!(f, "标准模式"),
|
||||
Self::Random => write!(f, "随机模式"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for SpoofState {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
@@ -107,6 +125,7 @@ impl LANToolkit {
|
||||
test_message: TestState::NotSelected,
|
||||
spoof_state: SpoofState::Unchecked,
|
||||
spoof_btn_text: SpoofState::Unchecked.get_btn_text(),
|
||||
mode: Mode::Standard,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,7 +158,7 @@ impl LANToolkit {
|
||||
row![
|
||||
button(self.spoof_btn_text.as_str())
|
||||
.width(515)
|
||||
.on_press(Messages::StartSpoof(false)),
|
||||
.on_press(Messages::StartSpoof(false, false)),
|
||||
].padding(10),
|
||||
column![
|
||||
text("警告: 在未经过配置的设备上使用该程序可能导致连接的网络瘫痪")
|
||||
@@ -151,6 +170,19 @@ impl LANToolkit {
|
||||
text(self.spoof_state.to_string())
|
||||
.width(300)
|
||||
.color(self.spoof_state.get_color()),
|
||||
].padding(10),
|
||||
row![
|
||||
text("当前模式: ").width(130),
|
||||
text(self.mode.to_string()).width(300),
|
||||
button("切换").on_press(Messages::ModeSwitch),
|
||||
].padding(10),
|
||||
column![
|
||||
text("标准模式: 局域网所有流量发送至本机,由本机处理"),
|
||||
text("随机模式: 报复社会用,开启后局域网所有流量发送至随机地址,相当于断网"),
|
||||
text("(当然,如果你的目的是断网,那么随机模式不会泄露你的mac地址,这意味着溯源难度会更大)")
|
||||
].padding(10),
|
||||
row![
|
||||
text("开发者: Starrynight @ StarryForge")
|
||||
].padding(10)
|
||||
].padding(20)
|
||||
).width(WINDOW_WIDTH)
|
||||
@@ -262,7 +294,7 @@ impl LANToolkit {
|
||||
if !matches!(self.spoof_state, SpoofState::Unchecked) {
|
||||
self.spoof_state = SpoofState::NotReady;
|
||||
}
|
||||
self.state.tx.send(Messages::StartSpoof(false)).unwrap();
|
||||
self.state.tx.send(Messages::StartSpoof(false, false)).unwrap();
|
||||
}
|
||||
|
||||
pub fn update(&mut self, message: Messages) {
|
||||
@@ -289,7 +321,13 @@ impl LANToolkit {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Messages::StartSpoof(_) = messages {
|
||||
if matches!(messages, Messages::ModeSwitch) {
|
||||
self.mode = match self.mode {
|
||||
Mode::Standard => Mode::Random,
|
||||
Mode::Random => Mode::Standard,
|
||||
}
|
||||
}
|
||||
if let Messages::StartSpoof(_, _) = messages {
|
||||
match self.spoof_state {
|
||||
SpoofState::Unchecked => {
|
||||
self.spoof_state = if self.raw_packet_available {
|
||||
@@ -300,11 +338,11 @@ impl LANToolkit {
|
||||
},
|
||||
SpoofState::NotReady => {},
|
||||
SpoofState::Ready => {
|
||||
messages = Messages::StartSpoof(true);
|
||||
messages = Messages::StartSpoof(true, self.mode == Mode::Random);
|
||||
self.spoof_state = SpoofState::Online
|
||||
},
|
||||
SpoofState::Online => {
|
||||
messages = Messages::StartSpoof(false);
|
||||
messages = Messages::StartSpoof(false, false);
|
||||
self.spoof_state = SpoofState::Ready
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user