Skip to content

Instantly share code, notes, and snippets.

@rg443a
rg443a / inet_aton_ntoa.js
Last active January 2, 2020 06:37
inet_aton, inet_ntoa, ip2int, int2ip
function inet_aton(a) {
return a.split(".").reduce(function(a, b) {
return (a << 8) + parseInt(b, 10);
}, 0) >>> 0;
}
function inet_ntoa(a) {
return (a >>> 24) + "." + (a >> 16 & 255) + "." + (a >> 8 & 255) + "." + (a & 255);
}
@rg443a
rg443a / psping.txt
Created December 5, 2019 22:25
psping examples
icmp fast ping (50)
psping -i 0 -n 50 www.google.com
tcp ping
psping -i 0 -n 10 www.google.com:443
tcp server for latency and bandwidth tests
psping -s 10.0.0.1:5000
tcp latency test (8KB)
psping -l 8k -n 1000 10.0.0.1:5000
tcp bandwidth test
psping -b -l 8k -n 30s 10.0.0.1:5000
@rg443a
rg443a / suffix-black-list.js
Created January 10, 2019 05:41
suffix blacklist (tld filter)
var suffix_black_list=[
"xml",
"atom",
"rss",
"mml",
"txt",
"jad",
"wml",
"htc",
"woff",
@rg443a
rg443a / ip4ToInt.js
Created June 20, 2018 22:55
ip4ToInt, intToIp4, intToBin, isIp4InCidr, calculateCidrRange
const ip4ToInt = ip =>
ip.split('.').reduce((int, oct) => (int << 8) + parseInt(oct, 10), 0) >>> 0;
const isIp4InCidr = ip => cidr => {
const [range, bits = 32] = cidr.split('/');
const mask = ~(2 ** (32 - bits) - 1);
return (ip4ToInt(ip) & mask) === (ip4ToInt(range) & mask);
};
const isIp4InCidrs = (ip, cidrs) => cidrs.some(isIp4InCidr(ip));
jq -r "[.value, .name, .timestamp] | @tsv" 2018-04-27-1524816001-fdns_a.json
@rg443a
rg443a / iblocklist-dl.sh
Last active May 12, 2018 13:14
iblocklist download lists
#!/usr/bin/env sh
curl -s https://www.iblocklist.com/lists.php | sed -n "s/.*value='\(http:.*\)'.*/\1/p" | xargs curl -L -s | gunzip | grep -P '\d+\.\d+\.\d+\.\d+'
@rg443a
rg443a / powershell_Get-DnsClientCache.cmd
Last active May 19, 2019 12:20
powershell Get-DnsClientCache
powershell Get-DnsClientCache ^| Export-Csv dnclientcache-1.txt &node c:\rgr\bsync2.js dnclientcache-1.txt