X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=4da018b0bfd25b8d6b2d55e407288a923acffc62;hb=72e9dcbade3fdb51d9291a2856ca1cc998241f9b;hp=9f03281f998385deb11d0f3b326374d0230a42d1;hpb=f7ce6f45eae627c1368ffea0e1e56e84fec676be;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index 9f03281f..4da018b0 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -58,17 +58,20 @@ use Bands; use Geomag; use CmdAlias; use Filter; -use Local; use DXDb; -use Data::Dumper; +use AnnTalk; +use WCY; +use Data::Dumper; use Fcntl ':flock'; +use Local; + package main; @inqueue = (); # the main input queue, an array of hashes $systime = 0; # the time now (in seconds) -$version = "1.40"; # the version no of the software +$version = "1.42"; # the version no of the software $starttime = 0; # the starting time of the cluster $lockfn = "cluster.lock"; # lock file name @outstanding_connects = (); # list of outstanding connects @@ -103,6 +106,11 @@ sub rec if (!defined $msg || (defined $err && $err)) { if ($dxchan) { + if (defined $err) { + $conn->disconnect; + undef $conn; + $dxchan->conn(undef); + } $dxchan->disconnect; } elsif ($conn) { $conn->disconnect; @@ -112,23 +120,24 @@ sub rec # set up the basic channel info - this needs a bit more thought - there is duplication here if (!defined $dxchan) { - my ($sort, $call, $line) = $msg =~ /^(\w)(\S+)\|(.*)$/; + my ($sort, $call, $line) = DXChannel::decode_input(0, $msg); + return unless defined $sort; # is there one already connected to me - locally? my $user = DXUser->get($call); if (DXChannel->get($call)) { - my $mess = DXM::msg($lang, ($user && $user->sort eq 'A') ? 'concluster' : 'conother', $call); + my $mess = DXM::msg($lang, ($user && $user->is_node) ? 'concluster' : 'conother', $call); already_conn($conn, $call, $mess); return; } # is there one already connected elsewhere in the cluster? if ($user) { - if (($user->sort eq 'A' || $call eq $myalias) && !DXCluster->get_exact($call)) { + if (($user->is_node || $call eq $myalias) && !DXCluster->get_exact($call)) { ; } else { if (DXCluster->get_exact($call)) { - my $mess = DXM::msg($lang, $user->sort eq 'A' ? 'concluster' : 'conother', $call); + my $mess = DXM::msg($lang, $user->is_node ? 'concluster' : 'conother', $call); already_conn($conn, $call, $mess); return; } @@ -151,9 +160,9 @@ sub rec } # create the channel - $dxchan = DXCommandmode->new($call, $conn, $user) if ($user->sort eq 'U'); - $dxchan = DXProt->new($call, $conn, $user) if ($user->sort eq 'A'); - $dxchan = BBS->new($call, $conn, $user) if ($user->sort eq 'B'); + $dxchan = DXCommandmode->new($call, $conn, $user) if $user->is_user; + $dxchan = DXProt->new($call, $conn, $user) if $user->is_node; + $dxchan = BBS->new($call, $conn, $user) if $user->is_bbs; die "Invalid sort of user on $call = $sort" if !$dxchan; } @@ -186,7 +195,7 @@ sub cease # disconnect nodes foreach $dxchan (DXChannel->get_all()) { - next unless $dxchan->is_ak1a; + next unless $dxchan->is_node; disconnect($dxchan) unless $dxchan == $DXProt::me; } Msg->event_loop(1, 0.05); @@ -198,7 +207,7 @@ sub cease # disconnect users foreach $dxchan (DXChannel->get_all()) { - next if $dxchan->is_ak1a; + next if $dxchan->is_node; disconnect($dxchan) unless $dxchan == $DXProt::me; } Msg->event_loop(1, 0.05); @@ -238,17 +247,15 @@ sub process_inqueue my $data = $self->{data}; my $dxchan = $self->{dxchan}; - my ($sort, $call, $line) = $data =~ /^(\w)([A-Z0-9\-]+)\|(.*)$/; my $error; - - # the above regexp must work - return unless ($sort && $call && $line); + my ($sort, $call, $line) = DXChannel::decode_input($dxchan, $data); + return unless defined $sort; # translate any crappy characters into hex characters if ($line =~ /[\x00-\x06\x08\x0a-\x1f\x7f-\xff]/o) { $line =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg; } - + # do the really sexy console interface bit! (Who is going to do the TK interface then?) dbg('chan', "<- $sort $call $line\n") unless $sort eq 'D'; @@ -299,7 +306,7 @@ STDOUT->autoflush(1); Log('cluster', "DXSpider V$version started"); # banner -dbg('err', "DXSpider DX Cluster Version $version", "Copyright (c) 1998-1999 Dirk Koopman G1TLH"); +dbg('err', "DXSpider DX Cluster Version $version", "Copyright (c) 1998-2000 Dirk Koopman G1TLH"); # load Prefixes dbg('err', "loading prefixes ..."); @@ -331,6 +338,7 @@ CmdAlias->init(); # initialise the Geomagnetic data engine Geomag->init(); +WCY->init(); # initial the Spot stuff Spot->init(); @@ -371,6 +379,11 @@ dbg('err', "orft we jolly well go ..."); #open(DB::OUT, "|tee /tmp/aa"); +$SIG{PIPE} = sub { + #$DB::single = 1; + dbg('err', "Broken PIPE signal received"); +}; + for (;;) { my $timenow; # $DB::trace = 1;