File tree 3 files changed +31
-3
lines changed
3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -16,5 +16,7 @@ This script came about after missing IPv6 GEO location functionality in Palo Alt
16
16
It is also way easier to setup a ASN blocklist for questionable hosting such as "Limenet" https://bgp.tools/as/394711
17
17
18
18
Contact seth dot mos at dds dot nl
19
+ Guthub: https://github.com/smos/ip-edl/
19
20
20
21
13-04-2024 Add newline when selecting multiple ASN or Countries
22
+ 25-05-2024 Add RIR files to the output, and fetch from feed.php
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ function validateCidr($cidr)
139
139
}
140
140
141
141
142
+ $ rip = array ();
142
143
$ cip = array ();
143
144
$ guid = array ();
144
145
$ asn = array ();
@@ -182,9 +183,10 @@ function validateCidr($cidr)
182
183
$ cidr = "{$ el [3 ]}/ {$ bits }" ;
183
184
if (!validateCidr ($ cidr )) {
184
185
echo "Address ' {$ el [3 ]}/ {$ bits }' is not valid in {$ info ['file ' ]}, skipping \n" ;
185
- continue ;
186
+ continue 2 ;
186
187
} else {
187
188
$ cip [$ el [1 ]][] = $ cidr ;
189
+ $ rip [$ rir ][] = $ cidr ;
188
190
// echo "{$el[3]}/{$bits} \n";
189
191
// also save by guid for ASN lookup
190
192
$ guid [$ el [7 ]][] = $ cidr ;
@@ -238,14 +240,18 @@ function validateCidr($cidr)
238
240
// exit(0);
239
241
240
242
// print_r($res);
243
+ echo "Write Aggregate RIR lists \n" ;
244
+ foreach ($ rip as $ rir => $ arr ) {
245
+ file_put_contents ("{$ outdir }/rir/ {$ rir }.txt " , implode ("\n" , $ arr ));
246
+
247
+ }
248
+
241
249
echo "Write Aggregate country lists from all RIRs \n" ;
242
250
foreach ($ cip as $ country => $ arr ) {
243
251
file_put_contents ("{$ outdir }/country/ {$ country }.txt " , implode ("\n" , $ arr ));
244
252
245
253
}
246
254
247
-
248
-
249
255
echo "Parse RIR DB for ASN routes \n" ;
250
256
foreach ($ dbs as $ rir => $ db ) {
251
257
$ i = 0 ;
Original file line number Diff line number Diff line change 11
11
12
12
}
13
13
14
+ function rlimit ($ cl ) {
15
+ return substr ($ cl , 0 , 7 );
16
+ }
17
+
14
18
function climit ($ cl ) {
15
19
return substr ($ cl , 0 , 2 );
16
20
}
@@ -19,6 +23,22 @@ function aslimit($as) {
19
23
return substr ($ as , 0 , 6 );
20
24
}
21
25
26
+ // Process Country value
27
+ if (isset ($ _GET ['rir ' ])) {
28
+ $ val = strtoupper (strip_tags ($ _GET ['rir ' ]));
29
+ $ items = preg_split ("/;/ " , $ val );
30
+ $ items = array_map ('trim ' , $ items );
31
+ $ items = array_map ('rlimit ' , $ items );
32
+ // print_r($items);
33
+
34
+ foreach ($ items as $ rir ) {
35
+ if (is_readable ("{$ outdir }/rir/ {$ rir }.txt " )) {
36
+ echo file_get_contents ("{$ outdir }/rir/ {$ rir }.txt " );
37
+ }
38
+ }
39
+
40
+ }
41
+
22
42
// Process Country value
23
43
if (isset ($ _GET ['country ' ])) {
24
44
$ val = strtoupper (strip_tags ($ _GET ['country ' ]));
You can’t perform that action at this time.
0 commit comments