Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View digizeph's full-sized avatar
🌟

Mingwei Zhang digizeph

🌟
View GitHub Profile
@digizeph
digizeph / 2023-05-25-37468-pfxs.txt
Last active May 25, 2023 17:04
Prefixes announced on May 25th 2023 between 9 to 13 UTC with AS paths matches "37468 3356 16509". Data collected from all public route-views and ripe ris collectors. Used `monocle search --start-ts 2023-05-25T09:00:00Z --end-ts 2023-05-25T13:00:00Z --as-path ".*37468 3356 16509.*" --sqlite-path angola.sqlite3` to generate the data.
130.137.121.0/24
52.20.0.0/14
18.232.0.0/14
52.4.0.0/14
54.80.0.0/14
54.144.0.0/14
54.160.0.0/14
54.156.0.0/14
18.204.0.0/14
130.137.102.0/24
@digizeph
digizeph / pfxs.txt
Created May 25, 2023 17:03
Prefixes announced on May 25th 2023 between 9 to 13 UTC with AS paths matches "37468 3356 16509". Data collected from all public route-views and ripe ris collectors.
130.137.121.0/24
52.20.0.0/14
18.232.0.0/14
52.4.0.0/14
54.80.0.0/14
54.144.0.0/14
54.160.0.0/14
54.156.0.0/14
18.204.0.0/14
130.137.102.0/24
@digizeph
digizeph / pfx2as.rs
Created May 9, 2023 15:50
Parse a RIB dump file into prefix-to-AS mapping HashMap
fn pfx2as(url: &str) -> Result<HashMap<IpNet, HashSet<u32>>> {
let mut data: HashMap<IpNet, HashSet<u32>> = HashMap::new();
for elem in bgpkit_parser::BgpkitParser::new(url)? {
let prefix = elem.prefix.prefix;
let origins = elem
.origin_asns
.unwrap()
.into_iter()
.map(|v| v.asn)
.collect::<Vec<u32>>();
OTC found: 15562 for path 23673:6939:15562
A|1678932008|203.189.128.233|23673|67.221.245.0/24|23673 6939 15562|IGP|203.189.128.233|0|0||NAG||
OTC found: 15562 for path 293:6939:15562
A|1678932008|198.129.33.85|293|67.221.245.0/24|293 6939 15562|IGP|198.129.33.85|0|710||NAG||
OTC found: 15562 for path 11686:6939:15562
A|1678932008|96.4.0.55|11686|67.221.245.0/24|11686 6939 15562|IGP|96.4.0.55|0|0|11686:195|NAG||
OTC found: 15562 for path 18106:6939:15562
@digizeph
digizeph / country-to-emoji.js
Created October 5, 2022 17:32
Country code to emoji conversion function
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
@digizeph
digizeph / hegemony-2022-01-01.csv
Created August 3, 2022 00:59
global IHR hegemony score for 2022-01-01
We can't make this file beautiful and searchable because it's too large.
asn,score
41583,0.0000000832982923058288
13744,0.00000016659591938094
15738,0.00000485721161558585
204489,0.0000000832980944379421
40768,0.0000000832980944379421
52989,0.00000145343505139675
46793,0.000000166595179383151
397335,0.000000333193169223315
263348,0.000000333193169223315
@digizeph
digizeph / msgs-3.json
Created May 4, 2022 14:54
BGP messages originated from AS47598 from 2022-05-04T00:06:00 -- 2022-05-04T00:08:00
{
"count": 52,
"error": null,
"msgs": [
{
"timestamp": 1651643873,
"elem_type": "A",
"peer_ip": "49.12.70.222",
"peer_asn": 44393,
"prefix": "91.206.110.0/23",
@digizeph
digizeph / msgs-2.json
Created May 3, 2022 17:38
BGP messages originated from AS47598 between 2022-05-01T16:00:00 and 2022-05-01T16:15:00 UTC
{
"count": 105,
"error": null,
"msgs": [
{
"timestamp": 1651420950,
"elem_type": "A",
"peer_ip": "185.181.60.126",
"peer_asn": 207564,
"prefix": "91.206.110.0/23",
@digizeph
digizeph / msgs-1.json
Created May 3, 2022 17:36
BGP messages originated from AS47598 between 2022-04-30T16:00:00 and 2022-04-30T16:15:00 UTC
{
"count": 120,
"error": null,
"msgs": [
{
"timestamp": 1651335121,
"elem_type": "A",
"peer_ip": "185.181.60.126",
"peer_asn": 207564,
"prefix": "91.206.110.0/23",
@digizeph
digizeph / parallel-parsing.rs
Created March 16, 2022 04:37
Parallel parsing of BGP MRT files with BGPKIT and Rayon.
use bgpkit_broker::{BgpkitBroker, BrokerItem, QueryParams};
use bgpkit_parser::BgpkitParser;
use rayon::prelude::*;
fn main() {
let broker = BgpkitBroker::new_with_params(
"https://api.broker.bgpkit.com/v1",
QueryParams {
start_ts: Some(1640995200),
end_ts: Some(1640998799),