Last active
September 16, 2017 04:23
-
-
Save daurnimator/8b8e5d1203445efee2a7433f724e7644 to your computer and use it in GitHub Desktop.
https://dn42.us/peers/script.sh in mikrotik scripting lanaguage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
:local peerid $dn42peerid | |
:local nbpings 5 | |
/tool fetch url=("https://dn42.us/peers/pending/" . $peerid) dst-path=dn42-peerfinder | |
:local pending [/file get dn42-peerfinder contents] | |
/file remove dn42-peerfinder | |
:local reqidstart [:find $pending "\"req_id\": \"" -1] | |
:if ($reqidstart > 0) do={ | |
:set reqidstart ($reqidstart+11) | |
:local reqid [:pick $pending $reqidstart [:find $pending "\"" $reqidstart]] | |
:local reqipstart ([:find $pending "\"req_ip\": \"" -1]+11) | |
:local reqip [:pick $pending $reqipstart [:find $pending "\"" $reqipstart]] | |
:put ("PINGING TO: " . $reqip . " for " . $reqid . "..."); | |
:local avgRtt NULL | |
/tool flood-ping $reqip count=$nbpings do={ | |
:if ($sent = $nbpings) do={ | |
:set avgRtt $"avg-rtt" | |
} | |
} | |
:put ("RTT to target " . $reqid . " (" . $reqip . ") is " . $avgRtt) | |
/tool fetch url=("https://dn42.us/peers/req/" . $reqid) http-data=("peer_id=" . $peerid . "&res_latency=" . $avgRtt) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment