#!/usr/bin/perl
use HTML::Template;
undef $/;
my $VAR1;
my $code = <>;
my $tls_data = eval $code;
my $data;
for my $remailer (sort {$a->{'nick'} cmp $b->{'nick'}} @$tls_data) {
for my $mx (@{$remailer->{'mx'}}) {
for my $key (keys %{$mx->{'res'}->{'smtp'}}) {
$mx->{$key} = $mx->{'res'}->{'smtp'}->{$key};
};
for my $type (qw{submission smtps 2525}) {
#for my $type (qw{submission smtps 2525 25000}) {
#for my $type (qw{submission smtps 2525 22222}) {
$mx->{$type} = $mx->{'res'}->{$type}->{'result'};
};
$mx->{'ssl'} = $mx->{'res'}->{'smtps'}->{'tls'};
if ($mx->{'tls'}) {
my $basename = $mx->{'mx'};
$basename =~ s/[^A-Za-z0-9\.-]//g;
$basename =~ s/\.\././;
$basename = 'cert-' . $basename . '.txt';
open (F, '>'.$basename) or die ("Cannot open $basename: $!\n");
print F $mx->{'tls'};
close (F);
$mx->{'cert_url'} = $basename;
($mx->{'tls-cipher'}) = $mx->{'tls'} =~ /Cipher is (.*)$/m;
};
if ($mx->{'ssl'}) {
my $basename = $mx->{'mx'};
$basename =~ s/[^A-Za-z0-9\.-]//g;
$basename =~ s/\.\././;
$basename = 'cert-' . $basename . '.ssl.txt';
open (F, '>'.$basename) or die ("Cannot open $basename: $!\n");
print F $mx->{'ssl'};
close (F);
$mx->{'ssl_url'} = $basename;
($mx->{'ssl-cipher'}) = $mx->{'ssl'} =~ /Cipher is (.*)$/m;
};
$mx->{'result-defined'} = defined $mx->{'result'};
};
push @{$data->{'remailer'}}, $remailer;
};
$data->{'now'} = gmtime();
#require Data::Dumper;
#print Data::Dumper->Dump([$tls_data]);
my $template = HTML::Template->new(filename => 'template.tmpl', die_on_bad_params => 0);
$template->param( $data );
my $out = $template->output;
print $out;