Skip to content

Commit a73cc2c

Browse files
committed
feat: more checks for stability
1 parent d78df75 commit a73cc2c

File tree

3 files changed

+55
-8
lines changed

3 files changed

+55
-8
lines changed

Cargo.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ license = "GPL-3.0-or-later"
88

99
[dependencies]
1010
etherparse = "0.13.0"
11+
libloading = "0.7.4"
1112
pcap = "1.0.0"
1213
sysinfo = "0.28.2"
1314
winroute = "0.2.0"
1415

1516
[build-dependencies]
1617
reqwest = { version = "0.11", features = ["blocking"] }
1718
zip-extract = "0.1.2"
18-
winres = "0.1.12"
19+
winres = "0.1.12"

src/main.rs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ fn get_sot_ports(pid: u32) -> Vec<u16> {
2121
.output()
2222
.unwrap();
2323

24-
String::from_utf8(cmd.stdout)
24+
// jarringly, netstat output contains non-utf8 characters :)
25+
let filtered_stdout = cmd
26+
.stdout
27+
.iter()
28+
.filter(|c| c.is_ascii())
29+
.copied()
30+
.collect();
31+
32+
String::from_utf8(filtered_stdout)
2533
.unwrap()
2634
.lines()
2735
.filter(|line| line.contains(p))
@@ -34,8 +42,28 @@ fn get_sot_ports(pid: u32) -> Vec<u16> {
3442
}
3543

3644
fn main() {
45+
println!("Making sure you have Npcap installed...");
46+
unsafe {
47+
let try_load_wpcap = libloading::Library::new("wpcap.dll");
48+
if try_load_wpcap.is_err() {
49+
println!("{}", "*".repeat(80));
50+
println!("ERROR: It doesn't seem like you've installed Npcap.");
51+
println!("Please install Npcap from\n https://npcap.com/dist/npcap-1.72.exe\n");
52+
println!("*** MAKE SURE TO INSTALL WITH 'WinPcap API Compatibility' TURNED ON ***");
53+
println!("{}\n", "*".repeat(80));
54+
println!("Want to continue anyway? Enter 'yes' or 'no':");
55+
56+
let mut input = String::new();
57+
std::io::stdin().read_line(&mut input).unwrap();
58+
let input = input.trim().to_lowercase();
59+
if !(input == "y" || input == "yes") {
60+
std::process::exit(1);
61+
}
62+
}
63+
}
64+
3765
// wait until we get a sot pid
38-
println!("Looking for Sea of Thieves...");
66+
println!("Waiting for Sea of Thieves to be running... (you should start it)");
3967
let mut s =
4068
System::new_with_specifics(RefreshKind::new().with_processes(ProcessRefreshKind::new()));
4169

@@ -125,13 +153,16 @@ fn main() {
125153
let ip = ipv4.destination.map(|c| c.to_string()).join(".");
126154

127155
if target == "idk" {
128-
println!("Connected to: {}:{}", ip, udp.destination_port);
156+
println!("You are connected to: {}:{}\n Press Enter to check again.", ip, udp.destination_port);
129157
std::io::stdin().read_line(&mut String::new()).unwrap();
130-
break;
158+
continue;
131159
}
132160

133161
if format!("{}:{}", ip, udp.destination_port) != target {
134-
println!("FAIL {}:{}, not the right server.", ip, udp.destination_port);
162+
println!(
163+
"FAIL {}:{}, not the right server.",
164+
ip, udp.destination_port
165+
);
135166
} else {
136167
println!("SUCCESS {}:{}", ip, udp.destination_port);
137168
std::io::stdin().read_line(&mut String::new()).unwrap();
@@ -156,7 +187,11 @@ fn main() {
156187
println!("Unblocking {}...", ip);
157188

158189
// delete route, route_manager.delete_route doesn't work for some reason
159-
let status = Command::new("route").arg("delete").arg(ip).status().unwrap();
190+
let status = Command::new("route")
191+
.arg("delete")
192+
.arg(ip)
193+
.status()
194+
.unwrap();
160195
if !status.success() {
161196
println!("Failed to delete route.");
162197
}

0 commit comments

Comments
 (0)