]> git.openstreetmap.org Git - dns.git/blob - bin/mksshfp
7c0f518034332dd72c1111ea9bb6f79bf12068ff
[dns.git] / bin / mksshfp
1 #!/usr/bin/perl
2
3
4 open(SSHFP_JS, ">", "include/sshfp.js") || die $!;
5
6 print SSHFP_JS qq|var SSHFP_RECORDS = [\n|;
7
8 if (-f "/etc/ssh/ssh_known_hosts")
9 {
10     open(SSHFP, "-|","sshfp", "-k", "/etc/ssh/ssh_known_hosts") || die $!;
11
12     while (my $line = <SSHFP>)
13     {
14         if ($line =~ /^(\S+) IN SSHFP (\d+) (\d+) ([0-9A-F]+)$/)
15         {
16             my $host = $1;
17             my $algorithm = $2;
18             my $type = $3;
19             my $value = $4;
20
21             if ($type == 2 &&
22                 ($algorithm == 3 || $algorithm == 4))
23             {
24                 print SSHFP_JS qq|  SSHFP("${host}", ${algorithm}, ${type}, "${value}"),\n|;
25             }
26         }
27         else
28         {
29             warn $line;
30         }
31     }
32
33     close(SSHFP);
34 }
35
36 print SSHFP_JS qq|];\n|;
37
38 close(SSHFP_JS);
39
40 exit 0;