summaryrefslogtreecommitdiffstats
path: root/pttbbs/innbbsd/inncheck.pl
blob: 2b98a305cd9801ba62d3aa5906007c277553bcc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
use IO::Socket::INET;
$BBSHOME = '/home/bbs';

open NODES, "<$BBSHOME/innd/nodelist.bbs";
while( <NODES> ){
    next if( /^\#/ );

    ($nodename, $host) = $_ =~ /^(\S+)\s+(\S+)/;
    next if( !$nodename );

    $sock = IO::Socket::INET->new(PeerAddr => $host,
                  PeerPort => 119,
                  Proto => 'tcp');
    next if( !$sock );
    $sock->write("list\r\nquit\r\n");
    $sock->read($data, 104857600);

    foreach( split("\n", $data) ){
    $group{$nodename}{$1} = 1
        if( /^([A-Za-z0-9\.]+) \d+ \d+ y/ );
    }
}

open FEEDS, "<$BBSHOME/innd/newsfeeds.bbs";
while( <FEEDS> ){
    ++$line;
    next if( /^\#/ );

    next if( !(($gname, $board, $nodename) =
           $_ =~ /^([\w\.]+)\s+(\w+)\s+(\w+)/) );

    if( !-d ("$BBSHOME/boards/". substr($board, 0, 1). "/$board") ){
    print "$line: board not found ($board)\n";
    next;
    }

    if( !$group{$nodename} ){
    print "$line: node not found ($nodename)\n";
    next;
    }

    if( !$group{$nodename}{$gname} ){
    print "$line: group not found ($gname)\n";
    }
}