Comments (3)
or--
// ZmEu (whitehat.ro) 03022021
// - RTT getter program for RTT-based actions (ARouteServer)
//
// $ gcc -o rtt_getter rtt_getter.c && ./rtt_getter 185.1.176.1
// 0.481
//
// I am not responsible for any damage.
// For educational purposes only, use at your own responsibility.
//
// Don't hate me, hate the code!#
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
int cmd(char *ip) {
char buf[124];
char *ping;
if (inet_pton(AF_INET, ip, buf)) {
ping = "ping";
} else if (inet_pton(AF_INET6, ip, buf)) {
ping = "ping6";
} else {
ping = '\0';
}
if (ip == NULL || ping == NULL) {
printf("None\n");
return 0;
}
int result;
FILE *isalive;
memset(buf, 0, 124);
sprintf(buf, "%s -c 1 -n -q -w 1 %s | grep 'packets'", ping, ip);
isalive = popen(buf, "r");
while (fgets(buf, sizeof(buf), isalive)) {
if (!strstr(buf, "0 packets")) {
// interval lower than =< 1 needs super user access
snprintf(buf, sizeof(buf), "%s -c 3 -i 1 -n -q -w 1 %s | grep min/avg/max | egrep -o ' [0-9./]+ ms' | cut -d '/' -f 2", ping, ip);
system(buf);
} else {
printf("None\n");
}
return 0;
}
pclose(isalive);
return 0;
}
int main (int argc, char **argv) {
int error;
if (argc < 2) {
fprintf(stderr, "[-] Syntax:\n<%s %%i>\t\t- peer IP address\n", argv[0]);
return 1;
}
if (error = cmd(argv[1])) {
fprintf(stderr, "[-] exec() returned an error: %s\n", strerror(errno));
}
return error;
}
ARouteServer 2021-03-02 18:39:57,678 INFO Enricher 'RTTGetter' started
ARouteServer 2021-03-02 18:40:07,787 INFO Enricher 'RTTGetter', 4 tasks left
ARouteServer 2021-03-02 18:40:10,013 INFO Enricher 'RTTGetter' completed successfully after 13 seconds
$ grep -i rtt /etc/bgpd.conf
# RTT: 2.483 ms (normalized value: 2)
# RTT: 1.209 ms (normalized value: 1)
# RTT: 41.403 ms (normalized value: 41)
# RTT: 40.268 ms (normalized value: 40)
# RTT: 42.503 ms (normalized value: 43)
# RTT: 43.711 ms (normalized value: 44)
# do_not_announce_to_peers_with_rtt_lower_than 5 ms
# do_not_announce_to_peers_with_rtt_lower_than 10 ms
# do_not_announce_to_peers_with_rtt_lower_than 15 ms
# do_not_announce_to_peers_with_rtt_lower_than 20 ms
# do_not_announce_to_peers_with_rtt_lower_than 30 ms
# do_not_announce_to_peers_with_rtt_lower_than 50 ms
# do_not_announce_to_peers_with_rtt_lower_than 100 ms
# do_not_announce_to_peers_with_rtt_lower_than 200 ms
# do_not_announce_to_peers_with_rtt_lower_than 500 ms
from arouteserver.
Hi @happyhater, that's great, thanks for your contribution.
Would you like to open a PR and propose the addition of the two files? They could go inside the config.d directory, where the bash version already exists.
You may add both the ksh script and the C program. I could make the changes to the doc where the usage of rtt-getter is explained and get everything merged in the next release. WDYT?
from arouteserver.
Hi @pierky , sure!
I guess it's better to use just C program, don't you think ?
There is it: #67
from arouteserver.
Related Issues (20)
- configuration for two RS in same ASN HOT 2
- 4Byte to 2Byte ASN conversion issue for BGP community HOT 9
- bird local preference HOT 2
- import limit is not set if peeringdb not found HOT 2
- Jinja2 / markupsafe version missmatch leads to errors HOT 1
- PeeringDB anonymous API throttling HOT 10
- Allow configuration of the PeeringDB URL
- Add support for peeringdb-py
- __init__() got an unexpected keyword argument 'allowed_methods' after upgrade to 1.16 HOT 9
- Remove RGNET from whois sources HOT 1
- as_macro not added to IX-F JSON if read from PeeringDB HOT 8
- Route-Servers with Peer Active to ASNs that were excluded
- Double "AS" in comment for ASN without IPv6 in ARIN HOT 1
- Deprecate ARIN-WHOIS data source HOT 5
- Can I run bgp route-server and route-client in one docker? HOT 2
- Option "-3" not supported in bgpq4, results in Errors at the script HOT 3
- Script returns same error with different ID despite the ignore-issues option HOT 4
- New-line character missing on OpenBGPd template HOT 1
- Refactor ext-communities for OpenBGPd HOT 7
- OpenBGPD: use wildcard matching to delete extended communities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arouteserver.