- my ($self, $line) = @_;
- my $user = $self->{user};
- my $call = $self->{call};
- my $name = $user->{name};
-
- $self->{name} = $name ? $name : $call;
- $self->send($self->msg('l2',$self->{name}));
- $self->send_file($main::motd) if (-e $main::motd);
- $self->send($self->msg('pr', $call));
- $self->state('prompt'); # a bit of room for further expansion, passwords etc
- $self->{priv} = $user->priv;
- $self->{lang} = $user->lang;
- $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;
+ $host ||= "AGW Port #$self->{conn}->{agwport}" if exists $self->{conn}->{agwport};
+ $host ||= "unknown";
+ $self->{hostname} = $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';
+ my $pagelth = $user->pagelth;
+ $pagelth = $default_pagelth unless defined $pagelth;
+ $self->{pagelth} = $pagelth;
+ ($self->{width}) = $line =~ /\s*width=(\d+)/; $line =~ s/\s*width=\d+//;
+ $self->{enhanced} = $line =~ /\s+enhanced/; $line =~ s/\s*enhanced//;
+ if ($line =~ /host=/) {
+ my ($h) = $line =~ /host=(\d+\.\d+\.\d+\.\d+)/;
+ $line =~ s/\s*host=\d+\.\d+\.\d+\.\d+// if $h;
+ unless ($h) {
+ ($h) = $line =~ /host=([\da..fA..F:]+)/;
+ $line =~ s/\s*host=[\da..fA..F:]+// if $h;
+ }
+ $self->{hostname} = $h if $h;
+ }
+ $self->{width} = 80 unless $self->{width} && $self->{width} > 80;
+ $self->{consort} = $line; # save the connection type
+
+ LogDbg('DXCommand', "$call connected from $self->{hostname} cols $self->{width}" . ($self->{enhanced}?" enhanced":''));
+
+ # 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;
+ $self->{lastmsgpoll} = 0;
+
+ # 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 == 2) {
+ $self->{registered} = !$user->registered;
+ } else {
+ $self->{registered} = $user->registered;
+ }
+
+ # establish slug queue, if required
+ $self->{sluggedpcs} = [];
+ $self->{isslugged} = $DXProt::pc92_slug_changes + $DXProt::last_pc92_slug + 5 if $DXProt::pc92_slug_changes;
+ $self->{isslugged} = 0 if $self->{priv} || $user->registered || ($user->homenode && $user->homenode eq $main::mycall);
+
+ # send the relevant MOTD
+ $self->send_motd;
+
+ # sort out privilege reduction
+ $self->{priv} = 0 unless $self->{hostname} eq '127.0.0.1' || $self->{hostname} eq '::1' || $self->conn->{usedpasswd};
+
+ # get the filters
+ my $nossid = $call;
+ $nossid =~ s/-\d+$//;
+
+ $self->{spotsfilter} = Filter::read_in('spots', $call, 0)
+ || Filter::read_in('spots', $nossid, 0)
+ || Filter::read_in('spots', 'user_default', 0);
+ $self->{wwvfilter} = Filter::read_in('wwv', $call, 0)
+ || Filter::read_in('wwv', $nossid, 0)
+ || Filter::read_in('wwv', 'user_default', 0);
+ $self->{wcyfilter} = Filter::read_in('wcy', $call, 0)
+ || Filter::read_in('wcy', $nossid, 0)
+ || Filter::read_in('wcy', 'user_default', 0);
+ $self->{annfilter} = Filter::read_in('ann', $call, 0)
+ || Filter::read_in('ann', $nossid, 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');
+ $self->tell_buddies('loginb');
+
+ # 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
+ $self->send($self->run_cmd("show/cluster"));
+
+ # send prompts for qth, name 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);
+
+ # send out any buddy messages for other people that are online
+ foreach my $call (@{$user->buddies}) {
+ my $ref = Route::User::get($call);
+ if ($ref) {
+ foreach my $node ($ref->parents) {
+ $self->send($self->msg($node eq $main::mycall ? 'loginb' : 'loginbn', $call, $node));
+ }
+ }
+ }
+
+ $self->lastmsgpoll($main::systime);
+ $self->prompt;