X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=212b9a0c4a04c25c9a131f703ed213a0440cdda3;hb=d093531de45491a7515474dcb59494886ad06d00;hp=43dab0535fd0a1430442be5c6f75b3e03ebccacb;hpb=bbcb636f1bc71eb1426685ef64382ea42d27ecfb;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 43dab053..212b9a0c 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -63,7 +63,10 @@ sub new my $pkg = shift; my $call = shift; my @rout = $main::routeroot->add_user($call, Route::here(1)); - DXProt::route_pc16($main::me, $main::routeroot, @rout) if @rout; + + # ALWAYS output the user + my $ref = Route::User::get($call); + DXProt::route_pc16($main::me, $main::routeroot, $ref) if $ref; return $self; } @@ -85,13 +88,11 @@ sub start $self->{name} = $name ? $name : $call; $self->send($self->msg('l2',$self->{name})); - $self->send_file($main::motd) if (-e $main::motd); $self->state('prompt'); # a bit of room for further expansion, passwords etc $self->{priv} = $user->priv || 0; $self->{lang} = $user->lang || $main::lang || 'en'; $self->{pagelth} = $user->pagelth || 20; - $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later - ($self->{width}) = $line =~ /width=(\d+)/; + ($self->{width}) = $line =~ /width=(\d+)/; $line =~ s/\s*width=\d+\s*//; $self->{width} = 80 unless $self->{width} && $self->{width} > 80; $self->{consort} = $line; # save the connection type @@ -107,6 +108,24 @@ sub start $self->{ann_talk} = $user->wantann_talk; $self->{here} = 1; + # sort out registration + if ($main::reqreg == 1) { + $self->{registered} = $user->registered; + } elsif ($main::reqreg == 2) { + $self->{registered} = !$user->registered; + } else { + $self->{registered} = 1; + } + + + # decide which motd to send + my $motd = "${main::motd}_nor" unless $self->{registered}; + $motd = $main::motd unless $motd && -e $motd; + $self->send_file($motd) if -e $motd; + + # sort out privilege reduction + $self->{priv} = 0 if $line =~ /^(ax|te)/ && !$self->conn->{usedpasswd}; + # get the filters $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'user_default', 0); $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'user_default', 0); @@ -123,9 +142,11 @@ sub start } # decide on echo - if (!$user->wantecho) { + my $echo = $user->wantecho; + unless ($echo) { $self->send_now('E', "0"); $self->send($self->msg('echow')); + $self->conn->echo($echo) if $self->conn->can('echo'); } $self->tell_login('loginu'); @@ -195,8 +216,8 @@ sub normal } } elsif ($self->{state} eq 'sysop') { my $passwd = $self->{user}->passwd; - my @pw = split / */, $passwd; if ($passwd) { + my @pw = grep {$_ !~ /\s/} split //, $passwd; my @l = @{$self->{passwd}}; my $str = "$pw[$l[0]].*$pw[$l[1]].*$pw[$l[2]].*$pw[$l[3]].*$pw[$l[4]]"; if ($cmdline =~ /$str/) { @@ -207,7 +228,31 @@ sub normal } else { $self->send($self->msg('sorry')); } - delete $self->{passwd}; + $self->state('prompt'); + } elsif ($self->{state} eq 'passwd') { + my $passwd = $self->{user}->passwd; + if ($passwd && $cmdline eq $passwd) { + $self->send($self->msg('pw1')); + $self->state('passwd1'); + } else { + $self->conn->{echo} = $self->conn->{decho}; + delete $self->conn->{decho}; + $self->send($self->msg('sorry')); + $self->state('prompt'); + } + } elsif ($self->{state} eq 'passwd1') { + $self->{passwd} = $cmdline; + $self->send($self->msg('pw2')); + $self->state('passwd2'); + } elsif ($self->{state} eq 'passwd2') { + if ($cmdline eq $self->{passwd}) { + $self->{user}->passwd($cmdline); + $self->send($self->msg('pw3')); + } else { + $self->send($self->msg('pw4')); + } + $self->conn->{echo} = $self->conn->{decho}; + delete $self->conn->{decho}; $self->state('prompt'); } elsif ($self->{state} eq 'talk') { if ($cmdline =~ m{^(?:/EX|/ABORT)}i) { @@ -244,7 +289,12 @@ sub normal } else { eval { @ans = &{$self->{func}}($self, $cmdline) }; } - $self->send_ans("Syserr: on stored func $self->{func}", $@) if $@; + if ($@) { + $self->send_ans("Syserr: on stored func $self->{func}", $@); + delete $self->{func}; + $self->state('prompt'); + undef $@; + } $self->send_ans(@ans); } else { $self->send_ans(run_cmd($self, $cmdline)); @@ -448,13 +498,13 @@ sub disconnect if ($uref) { @rout = $main::routeroot->del_user($uref); dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route'); + + # issue a pc17 to everybody interested + DXProt::route_pc17($main::me, $main::routeroot, $uref); } else { confess "trying to disconnect a non existant user $call"; } - # issue a pc17 to everybody interested - DXProt::route_pc17($main::me, $main::routeroot, @rout) if @rout; - # I was the last node visited $self->user->node($main::mycall); @@ -677,7 +727,7 @@ sub talk my ($self, $from, $to, $via, $line) = @_; $line =~ s/\\5E/\^/g; $self->local_send('T', "$to de $from: $line") if $self->{talk}; - Log('talk', $to, $from, $main::mycall, $line); + Log('talk', $to, $from, $via?$via:$main::mycall, $line); # send a 'not here' message if required unless ($self->{here} && $from ne $to) { my $key = "$to$from"; @@ -739,7 +789,13 @@ sub dx_spot return unless $filter; } - my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]); + + my $t = ztime($_[2]); + my $ref = DXUser->get_current($_[4]); + my $loc = $ref->qra if $ref && $ref->qra && $self->{user}->wantgrid; + $loc = ' ' . substr($loc, 0, 4) if $loc; + $loc = "" unless $loc; + my $buf = sprintf "DX de %-7.7s%11.1f %-12.12s %-*s $t$loc", "$_[4]:", $_[0], $_[1], $self->{consort} eq 'local' ? 29 : 30, $_[3]; $buf .= "\a\a" if $self->{beep}; $buf =~ s/\%5E/^/g; $self->local_send('X', $buf);