@@ -21,7 +21,15 @@ fn get_sot_ports(pid: u32) -> Vec<u16> {
21
21
. output ( )
22
22
. unwrap ( ) ;
23
23
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)
25
33
. unwrap ( )
26
34
. lines ( )
27
35
. filter ( |line| line. contains ( p) )
@@ -34,8 +42,28 @@ fn get_sot_ports(pid: u32) -> Vec<u16> {
34
42
}
35
43
36
44
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
+
37
65
// 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) " ) ;
39
67
let mut s =
40
68
System :: new_with_specifics ( RefreshKind :: new ( ) . with_processes ( ProcessRefreshKind :: new ( ) ) ) ;
41
69
@@ -125,13 +153,16 @@ fn main() {
125
153
let ip = ipv4. destination . map ( |c| c. to_string ( ) ) . join ( "." ) ;
126
154
127
155
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) ;
129
157
std:: io:: stdin ( ) . read_line ( & mut String :: new ( ) ) . unwrap ( ) ;
130
- break ;
158
+ continue ;
131
159
}
132
160
133
161
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
+ ) ;
135
166
} else {
136
167
println ! ( "SUCCESS {}:{}" , ip, udp. destination_port) ;
137
168
std:: io:: stdin ( ) . read_line ( & mut String :: new ( ) ) . unwrap ( ) ;
@@ -156,7 +187,11 @@ fn main() {
156
187
println ! ( "Unblocking {}..." , ip) ;
157
188
158
189
// 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 ( ) ;
160
195
if !status. success ( ) {
161
196
println ! ( "Failed to delete route." ) ;
162
197
}
0 commit comments