summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-03-19 14:16:07 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-03-19 14:16:07 +0100
commitca1e18068c61b1473a1f66fae7f24f7aede2e09a (patch)
treeeb5dad15c1635e87fc52860c57799bdf8431d045
parent4chan script fix (diff)
downloadr-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar.gz
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar.bz2
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar.lz
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar.xz
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.tar.zst
r-ca1e18068c61b1473a1f66fae7f24f7aede2e09a.zip
-rwxr-xr-xskripti/ipranges.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/skripti/ipranges.php b/skripti/ipranges.php
new file mode 100755
index 0000000..86fbe43
--- /dev/null
+++ b/skripti/ipranges.php
@@ -0,0 +1,52 @@
+#!/usr/bin/php
+<?php
+/**
+ * program izpiše bind9 aclje za države v ripe območku.
+ * privzeto izpiše vse, vendar bind9 umre ob prevelikem številu acljev
+ * uporaba: ./ipranges.php si de hr it
+ * v argumentih lahko torej povemo, za katere države želimo aclje
+ */
+$a = "";
+$p = [];
+$c = [];
+foreach (explode("\n", file_get_contents("https://ftp.ripe.net/pub/stats/ripencc/membership/alloclist.txt")) as $l) {
+ if ($l == "")
+ continue;
+ if ($l[0] != " ") {
+ $a = trim($l);
+ $p[$a] = [];
+ $c[explode(".", $a)[0]][] = $a;
+ continue;
+ }
+ if (strchr(trim($l), "\t") !== false)
+ $p[$a]["ranges"][] = explode("\t", trim($l));
+ else
+ $p[$a]["name"] = trim($l);
+}
+ksort($p);
+foreach ($p as $k => $v) {
+ if (sizeof($argv) > 1)
+ if (!in_array(explode(".", $k)[0], $argv))
+ continue;
+ echo "acl $k {\t// {$v['name']}" . PHP_EOL;
+ foreach ($v["ranges"] as $r) {
+ echo "\t{$r[1]}; //\t{$r[0]}" . PHP_EOL;
+ }
+ echo "};" . PHP_EOL;
+}
+foreach ($c as $k => $v) {
+ if (sizeof($argv) > 1)
+ if (!in_array($k, $argv))
+ continue;
+ echo "acl $k {" . PHP_EOL;
+ foreach ($v as $a) {
+ echo "\t$a;\t// {$p[$a]["name"]}" . PHP_EOL;
+ }
+ echo "};" . PHP_EOL;
+}
+$n = str_replace("/", "", str_replace(".", "", array_shift($argv)));
+echo "acl $n {" . PHP_EOL;
+foreach ($argv as $a) {
+ echo "\t$a;" . PHP_EOL;
+}
+echo "};" . PHP_EOL;