Difference between revisions of "Talk:Nodes.dat file"

From AMule Project FAQ
Jump to: navigation, search
 
Line 6: Line 6:
  
 
Hola
 
Hola
 +
----
 +
 +
I wrote this Perl version of the unpacker for shits and giggles...
 +
 +
#!/usr/bin/perl
 +
# this code belongs to public domain
 +
 +
use strict;
 +
use warnings;
 +
 +
open (NODES, "<nodes.dat");
 +
my $count;
 +
read (NODES, $count, 4) or die ("Can't read nodes.dat: $!");
 +
$count = unpack ('V', $count);
 +
print " idx type    ip address    udp  tcp\n";
 +
for(1..$count) {
 +
  my $data;
 +
  my $read = read (NODES, $data, 25);
 +
  if ($read==0) {
 +
    die ("Counted $count entries but read only $_!");
 +
  } elsif ($read<25) {
 +
    die ("Short read for entry $_ (counted $count entries)!");
 +
  }
 +
  my ($clientid, $ip1, $ip2, $ip3, $ip4, $udpport, $tcpport, $type) = unpack ('a16CCCCvvC', $data);
 +
  my $ipaddr = sprintf("%d.%d.%d.%d", $ip1, $ip2, $ip3, $ip4);
 +
  printf ("%4d %4d %-15s %5d %5d\n", $_, $type, $ipaddr, $udpport, $tcpport);
 +
}
 +
 +
--[[User:66.36.128.235|66.36.128.235]] 05:55, 24 March 2008 (CET)

Latest revision as of 06:55, 24 March 2008

I have just started aMule and there is an error message at the bottom: CFile: Error when opening file (/home/myuser/aMule/nodes.dat): No such file

How do I create this file?

Hola


I wrote this Perl version of the unpacker for shits and giggles...

#!/usr/bin/perl
# this code belongs to public domain

use strict;
use warnings;

open (NODES, "<nodes.dat");
my $count;
read (NODES, $count, 4) or die ("Can't read nodes.dat: $!");
$count = unpack ('V', $count);
print " idx type    ip address    udp   tcp\n";
for(1..$count) {
  my $data;
  my $read = read (NODES, $data, 25);
  if ($read==0) {
    die ("Counted $count entries but read only $_!");
  } elsif ($read<25) {
    die ("Short read for entry $_ (counted $count entries)!");
  }
  my ($clientid, $ip1, $ip2, $ip3, $ip4, $udpport, $tcpport, $type) = unpack ('a16CCCCvvC', $data);
  my $ipaddr = sprintf("%d.%d.%d.%d", $ip1, $ip2, $ip3, $ip4);
  printf ("%4d %4d %-15s %5d %5d\n", $_, $type, $ipaddr, $udpport, $tcpport);
}

--66.36.128.235 05:55, 24 March 2008 (CET)