add setting csort to to_connected
[spider.git] / perl / ExtMsg.pm
index 15f875a7facf6f514d29785d4121a22f1c71b599..71957817240f3793c229fecc1ba4729eaece1d1e 100644 (file)
@@ -5,7 +5,6 @@
 # This is where the cluster handles direct connections coming both in
 # and out
 #
-# $Id$
 #
 # Copyright (c) 2001 - Dirk Koopman G1TLH
 #
@@ -73,7 +72,7 @@ sub dequeue
        my $conn = shift;
        my $msg;
 
-       if ($conn->{csort} eq 'ax25' && exists $conn->{msg}) {
+       if ($conn->ax25 && exists $conn->{msg}) {
                $conn->{msg} =~ s/\cM/\cJ/g;
        }
        if ($conn->{state} eq 'WC') {
@@ -105,9 +104,9 @@ sub dequeue
                                $msg = uc $msg;
                                if (is_callsign($msg) && $msg !~ m|/| ) {
                                        my $sort = $conn->{csort};
-                                       $sort = 'local' if $conn->{peerhost} eq "127.0.0.1";
+                                       $sort = 'local' if $conn->{peerhost} =~ /127\.\d+\.\d+\.\d+$/ || $conn->{peerhost} eq '::1';
                                        my $uref;
-                                       if ($main::passwdreq || ($uref = DXUser->get_current($msg)) && $uref->passwd ) {
+                                       if ($main::passwdreq || ($uref = DXUser::get_current($msg)) && $uref->passwd ) {
                                                $conn->conns($msg);
                                                $conn->{state} = 'WP';
                                                $conn->{decho} = $conn->{echo};
@@ -121,13 +120,13 @@ sub dequeue
                                        $conn->disconnect;
                                }
                        } elsif ($conn->{state} eq 'WP' ) {
-                               my $uref = DXUser->get_current($conn->{call});
+                               my $uref = DXUser::get_current($conn->{call});
                                $msg =~ s/[\r\n]+$//;
                                if ($uref && $msg eq $uref->passwd) {
                                        my $sort = $conn->{csort};
                                        $conn->{echo} = $conn->{decho};
                                        delete $conn->{decho};
-                                       $sort = 'local' if $conn->{peerhost} eq "127.0.0.1";
+                                       $sort = 'local' if $conn->{peerhost} =~ /127\.\d+\.\d+\.\d+$/ || $conn->{peerhost} eq '::1';
                                        $conn->{usedpasswd} = 1;
                                        $conn->to_connected($conn->{call}, 'A', $sort);
                                } else {
@@ -154,7 +153,8 @@ sub to_connected
        delete $conn->{cmd};
        $conn->{timeout}->del if $conn->{timeout};
        delete $conn->{timeout};
-       $conn->nolinger unless $conn->isa('AGWMsg');
+       $conn->{csort} = $sort;
+       $conn->nolinger unless $conn->ax25;
        &{$conn->{rproc}}($conn, "$dir$call|$sort");
        $conn->_send_file("$main::data/connected") unless $conn->{outgoing};
 }