Added rudementary win support - not recommended

master
parent 3e042e19f9
commit 18f34bf954

@ -9,16 +9,21 @@ if ($ARGV[0] !~ /[a-z0-9\.]+/) {
$dns=$ARGV[0]; $dns=$ARGV[0];
my $regex="";
if ($^O == "linux") { if ($^O == "linux") {
$regex=qr/(?<bytes>[0-9]+ bytes) from (?<rhost>[a-z\.-]+) \((?<rip>[0-9\.]+)\).*seq=(?<rseq>[0-9]+).*time=(?<rms>[0-9\.]+) ms/; $regex=qr/(?<bytes>[0-9]+ bytes) from (?<rhost>[a-z\.-]+) \((?<rip>[0-9\.]+)\).*seq=(?<rseq>[0-9]+).*time=(?<rms>[0-9\.]+) ms/;
$dedjex=qr/no answer yet for icmp_seq=(?<rseq>[0-9]+)/ $dedjex=qr/no answer yet for icmp_seq=(?<rseq>[0-9]+)/
$pingcmd="ping -O"
} elsif ($^O == "MSWin32") { } elsif ($^O == "MSWin32") {
print "win!\n"; # untested lol
$regex=qr/Reply from (?<rip>[0-9\.]+).*bytes time=(?<rms>[0-9\.]+)ms.*/;
$dedjex=qr/Request timed out|Destination host unreachable/
$pingcmd="ping -t"
} else {
print "IDK WHAT OS YOU ARE :(";
exit 1;
} }
open(my $PING, "ping -O $dns|") or die "Cannot execute $!"; open(my $PING, "$pingcmd $dns|") or die "Cannot execute $!";
while (my $line = <$PING>) { while (my $line = <$PING>) {
if ($line =~ $regex) { if ($line =~ $regex) {

Loading…
Cancel
Save