Peer to peer connection setup goes like this:
A wants to send a packet to B, but since it has no direct path it sends it upstream to R (a root).
If R has a direct link to B, it forwards the packet there. Otherwise it sends the packet upstream until planetary roots are reached. Planetary roots know about all nodes, so eventually the packet will reach B if B is online.
R also sends a message called rendezvous to A containing hints about how it might reach B. Meanwhile the root that forwards the packet to B sends rendezvous informing B how it might reach A.
A and B get their rendezvous messages and attempt to send test messages to each other, possibly accomplishing hole punching of any NATs or stateful firewalls that happen to be in the way. If this works a direct link is established and packets no longer need to take the scenic route.
open my ($ip) = (IPlist, "iplist" or die "can't open iplist: $!");
my ($username) = 'admin';
while (@ lines = "<IPlist>")
use Encode qw(decode);
print decode("MIME-Header", 'Subject: =?windows-1251?B?yuDqIOTuIOLg8SDk7vXn4u7t6PLx/w==?=')."\n";
print decode("MIME-Header", 'Subject: =?koi8-r?B?8NLBytMtzMnT1CDEzNEg4czYwsXS1ME=?=')."\n"
print decode("MIME-Header", 'Subject: =?UTF-8?B?0J3QtdC00L7RgdGC0LDQstC70LXQvdC90L7QtSDRgdC+0L7QsdGJ0LXQvdC40LU=?=')."\n";
Subject: Как до вас дохзвонится
Subject: Прайс-лист для Альберта
Subject: Недоставленное сообщение