- my ($self, $line) = @_;
- my $user = $self->{user};
- my $call = $self->{call};
- my $name = $user->{name};
-
- $self->{name} = $name ? $name : $call;
- $self->msg('l2',$self->{name});
- $self->send_file($main::motd) if (-e $main::motd);
- $self->msg('pr', $call);
- $self->state('prompt'); # a bit of room for further expansion, passwords etc
- $self->{priv} = $user->priv;
- $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later
- $self->{consort} = $line; # save the connection type
-
- # set some necessary flags on the user if they are connecting
- $self->{wwv} = $self->{talk} = $self->{ann} = $self->{here} = $self->{dx} = 1;
- $self->prompt() if $self->{state} =~ /^prompt/o;
-
- # add yourself to the database
- my $node = DXNode->get($main::mycall) or die "$main::mycall not allocated in DXNode database";
- my $cuser = DXNodeuser->new($self, $node, $call, 0, 1);
- $node->dxchan($self) if $call eq $main::myalias; # send all output for mycall to myalias
-
- # issue a pc16 to everybody interested
- my $nchan = DXChannel->get($main::mycall);
- my @pc16 = DXProt::pc16($nchan, $cuser);
- DXProt::broadcast_ak1a(@pc16);
+ my ($self, $line, $sort) = @_;
+ my $user = $self->{user};
+ my $call = $self->{call};
+ my $name = $user->{name};
+
+ # log it
+ my $host = $self->{conn}->{peerhost} || "unknown";
+ Log('DXCommand', "$call connected from $host");
+
+ $self->{name} = $name ? $name : $call;
+ $self->send($self->msg('l2',$self->{name}));
+ $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->{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
+
+ # set some necessary flags on the user if they are connecting
+ $self->{beep} = $user->wantbeep;
+ $self->{ann} = $user->wantann;
+ $self->{wwv} = $user->wantwwv;
+ $self->{wcy} = $user->wantwcy;
+ $self->{talk} = $user->wanttalk;
+ $self->{wx} = $user->wantwx;
+ $self->{dx} = $user->wantdx;
+ $self->{logininfo} = $user->wantlogininfo;
+ $self->{ann_talk} = $user->wantann_talk;
+ $self->{here} = 1;
+ $self->{prompt} = $user->prompt if $user->prompt;
+
+ # sort out new dx spot stuff
+ $user->wantdxcq(0) unless defined $user->{wantdxcq};
+ $user->wantdxitu(0) unless defined $user->{wantdxitu};
+ $user->wantusstate(0) unless defined $user->{wantusstate};
+
+ # 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);
+ $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'user_default', 0);
+ $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'user_default', 0) ;
+
+ # clean up qra locators
+ my $qra = $user->qra;
+ $qra = undef if ($qra && !DXBearing::is_qra($qra));
+ unless ($qra) {
+ my $lat = $user->lat;
+ my $long = $user->long;
+ $user->qra(DXBearing::lltoqra($lat, $long)) if (defined $lat && defined $long);
+ }
+
+ # decide on echo
+ 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');
+
+ # do we need to send a forward/opernam?
+ my $lastoper = $user->lastoper || 0;
+ my $homenode = $user->homenode || "";
+ if ($homenode eq $main::mycall && $main::systime >= $lastoper + $DXUser::lastoperinterval) {
+ run_cmd($main::me, "forward/opernam $call");
+ $user->lastoper($main::systime + ((int rand(10)) * 86400));
+ }
+
+ # run a script send the output to the punter
+ my $script = new Script(lc $call) || new Script('user_default');
+ $script->run($self) if $script;
+
+ # send cluster info
+ my $info = Route::cluster();
+ $self->send("Cluster:$info");
+
+ # send prompts and things
+ $self->send($self->msg('namee1')) if !$user->name;
+ $self->send($self->msg('qthe1')) if !$user->qth;
+ $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long);
+ $self->send($self->msg('hnodee1')) if !$user->qth;
+ $self->send($self->msg('m9')) if DXMsg::for_me($call);
+ $self->prompt;