blob: 209f83b0fb44696d2f63c0c98ac5183000c19eee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
export PATH=$PATH:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin
echo '<svg id="map" width="500" height="500">'
cat > /var/cache/svgmap/data.tmp
nodes=$(cat /var/cache/svgmap/data.tmp \
| /var/www/libexec/svgmap/paths-to-edges \
| tr ' ' '\n' \
| sort \
| uniq )
nn=$(echo $nodes | tr ' ' '\n' | wc -l | tr -d ' ')
scale=200
xoff=250
yoff=250
cat /var/cache/svgmap/data.tmp | /var/www/libexec/svgmap/paths-to-edges > /var/cache/svgmap/edges.list
nsin=""
ncos=""
lsin=""
lcos=""
for i in $(seq 0 $nn);do
tmpsin="$(echo | awk "{ print ( ( sin( ( ${i}.0 / ${nn}.0) * 2.0 * atan2(0,-1) ) ) ) }")"
tmpcos="$(echo | awk "{ print ( ( cos( ( ${i}.0 / ${nn}.0) * 2.0 * atan2(0,-1) )) ) }")"
scale=200
nsin="$nsin $(echo | awk "{print $scale * $tmpsin + $xoff}")"
ncos="$ncos $(echo | awk "{print $scale * $tmpcos + $yoff}")"
scale=180
lsin="$lsin $(echo | awk "{print $scale * $tmpsin + $xoff}")"
lcos="$lcos $(echo | awk "{print $scale * $tmpcos + $yoff}")"
done
for i in $nodes;do
node1n=$(echo $nodes | tr ' ' '\n' | grep -n '^'$i'$' | cut -d: -f1)
x="$(echo $nsin | cut '-d ' -f$node1n)"
y="$(echo $ncos | cut '-d ' -f$node1n)"
printf '<g class="node_and_links">'
printf '<a xlink:href="/cgi-bin/whois.cgi?q=AS%s">' "$i"
printf '<circle name="%s" cx="%f" cy="%f" r="20"/>' "$i" "$x" "$y"
printf '<text x="%f" y="%f" fill="red" transform="rotate(0 %f,%f)">%s</text>' "$x" "$y" "$x" "$y" "$i"
echo "</a>"
cat /var/cache/svgmap/edges.list | grep "\b$i\b" | while read edge;do
node1=$(echo $edge | cut '-d ' -f1)
node2=$(echo $edge | cut '-d ' -f2)
node1n=$(echo $nodes | tr ' ' '\n' | grep -n '^'$node1'$' | cut -d: -f1)
node2n=$(echo $nodes | tr ' ' '\n' | grep -n '^'$node2'$' | cut -d: -f1)
x1="$(echo $lsin | cut '-d ' -f$node1n)"
y1="$(echo $lcos | cut '-d ' -f$node1n)"
x2="$(echo $lsin | cut '-d ' -f$node2n)"
y2="$(echo $lcos | cut '-d ' -f$node2n)"
printf '<line x1="%f" y1="%f" x2="%f" y2="%f"/>\n' "$x1" "$y1" "$x2" "$y2"
done
printf "</g>\n"
done
echo '</svg>'
|