From d5521c6bd294a235c3437ef10df135da0f65b759 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 18 Apr 2012 01:22:39 +0200 Subject: [PATCH] combine.pl: creates a seedlist from several dnsseed.dump files --- combine.pl | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 combine.pl diff --git a/combine.pl b/combine.pl new file mode 100644 index 0000000..5f63bcb --- /dev/null +++ b/combine.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +use strict; + +sub loadFile { + my ($file) = @_; + my %ret; + open FILE,$file; + while () { + my ($addr,$p2h,$p8h,$p1d,$p1w,$p1m) = split(/\s+/,$_); + if ($p1m =~ /\A([1-9.]+)%\Z/) { + my $x = log($1*0.01)/log(0.5); + $ret{$addr} = $x; + } + } + close FILE; + return \%ret; +} + +sub combine { + my ($f1,$f2) = @_; + my %ret; + for my $k1 (keys %{$f1}) { + if (defined $f2->{$k1}) { + $ret{$k1} = $f1->{$k1} + $f2->{$k1}; + } + } + return \%ret; +} + +my $res; +my $n=0; +for my $file (@ARGV) { + my $r = loadFile($file); + if ($res) { + $res = combine($res,$r); + } else { + $res = $r; + } + $n++; +} + +for my $addr (sort { $res->{$a} <=> $res->{$b} } (keys %{$res})) { + if ($addr =~ /\A(\d+)\.(\d+)\.(\d+)\.(\d+):8333/) { + my $a = $1*0x1000000 + $2*0x10000 + $3*0x100 + $4; + printf "0x%08x %s %g%%\n",$a,$addr,exp(log(0.5)*$res->{$addr}/$n)*100; + } +}