3 # A thing that implements dxcluster 'protocol'
5 # This is a perl module/program that sits on the end of a dxcluster
6 # 'protocol' connection and deals with anything that might come along.
8 # this program is called by ax25d and gets raw ax25 text on its input
10 # Copyright (c) 1998 Dirk Koopman G1TLH
24 @inqueue = (); # the main input queue, an array of hashes
26 # handle disconnections
30 return if !defined $dxchan;
31 my ($user) = $dxchan->{user};
32 my ($conn) = $dxchan->{conn};
33 $user->close() if defined $user;
34 $conn->disconnect() if defined $conn;
38 # handle incoming messages
41 my ($conn, $msg, $err) = @_;
42 my $dxchan = DXChannel->get_by_cnum($conn); # get the dxconnnect object for this message
44 if (defined $err && $err) {
45 disconnect($dxchan) if defined $dxchan;
49 # set up the basic channel info
50 if (!defined $dxchan) {
51 my $user = DXUser->get($call);
52 $user = DXUser->new($call) if !defined $user;
53 $dxchan = DXChannel->new($call, $conn, $user);
56 # queue the message and the channel object for later processing
58 my $self = bless {}, "inqueue";
59 $self->{dxchan} = $dxchan;
70 # cease running this program, close down all the connections nicely
74 foreach $dxchan (DXChannel->get_all()) {
79 # this is where the input queue is dealt with and things are dispatched off to other parts of
83 my $self = shift @inqueue;
86 my $data = $self->{data};
87 my $dxchan = $self->{dxchan};
88 my ($sort, $call, $line) = $data =~ /^(\w)(\S+)|(.*)$/;
90 # do the really sexy console interface bit! (Who is going to do the TK interface then?)
91 print DEBUG atime, " < $sort $call $line\n" if defined DEBUG;
92 print "< $sort $call $line\n";
96 my $user = $dxchan->{user};
97 $user->{sort} = 'U' if !defined $user->{sort};
98 if ($user->{sort} eq 'U') {
99 $dxchan->send_later('D', m('l2', $call, $mycall, $myqth));
100 $dxchan->send_file($motd) if (-e $motd);
102 } elsif (sort eq 'D') {
104 } elsif ($sort eq 'Z') {
109 #############################################################
111 # The start of the main line of code
113 #############################################################
115 # open the debug file, set various FHs to be unbuffered
116 open(DEBUG, ">>$debugfn") or die "can't open $debugfn($!)\n";
117 select DEBUG; $| = 1;
118 select STDOUT; $| = 1;
120 # initialise User file system
121 DXUser->init($userfn);
123 # start listening for incoming messages/connects
124 Msg->new_server("$clusteraddr", $clusterport, \&login);
127 $SIG{'INT'} = \&cease;
128 $SIG{'TERM'} = \&cease;
129 $SIG{'HUP'} = 'IGNORE';
131 # this, such as it is, is the main loop!
133 Msg->event_loop(1, 0.001);