Get basic web protocol working
authorDirk Koopman <djk@tobit.co.uk>
Thu, 26 Oct 2017 23:04:24 +0000 (00:04 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Thu, 26 Oct 2017 23:04:24 +0000 (00:04 +0100)
Changes
perl/DXChannel.pm
perl/DXCommandmode.pm
perl/cluster.pl

diff --git a/Changes b/Changes
index 49fda7c18f580eb813501bfbcd9dabfa8bc903e8..ae2b6875305737ecb9f63227ba87d19fba657f39 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,4 +1,6 @@
-26Aug17=======================================================================
+27Oct17=======================================================================
+1. Get correct hostname support and privilege levels on web connects.
+26Oct17=======================================================================
 1. Start (serious) work on web interface. Make the necessary changes to allow
    a local webserver to connect and get its own style of messages.
 11Aug17=======================================================================
index f8af917e7e3241b43b5e3b03a8c802355fa735c0..a9dbd86d48eb2de34b2f2646ce14cbef07048568 100644 (file)
@@ -125,7 +125,7 @@ $count = 0;
                  inqueue => '9,Input Queue,parray',
                  next_pc92_update => '9,Next PC92 Update,atime',
                  next_pc92_keepalive => '9,Next PC92 KeepAlive,atime',
-                 hostname => '0,(Proxied)Hostname',
+                 hostname => '0,Hostname',
                 );
 
 $maxerrors = 20;                               # the maximum number of concurrent errors allowed before disconnection
index 9a00febbf44ca90c58afabacf49980e10afedb97..cbba3b79210bf5ebfa0a77f8377ad57ff80816a6 100644 (file)
@@ -41,7 +41,6 @@ use DXXml;
 use AsyncMsg;
 use JSON;
 use Time::HiRes qw(gettimeofday tv_interval);
-use Regexp::IPv6 qw($IPv6_re);
 
 use Mojo::IOLoop;
 use Mojo::IOLoop::ForkCall;
@@ -74,7 +73,7 @@ sub new
        my $pkg = shift;
        my $call = shift;
 #      my @rout = $main::routeroot->add_user($call, Route::here(1));
-       DXProt::_add_thingy($main::routeroot, [$call, 0, 0, 1, undef, undef, $self->{conn}->peerhost], );
+       DXProt::_add_thingy($main::routeroot, [$call, 0, 0, 1, undef, undef, $self->hostname], );
 
        # ALWAYS output the user
        my $ref = Route::User::get($call);
@@ -101,7 +100,7 @@ sub start
        my $host = $self->{conn}->peerhost;
        $host ||= "AGW Port #$self->{conn}->{agwport}" if exists $self->{conn}->{agwport};
        $host ||= "unknown";
-       LogDbg('DXCommand', "$call connected from $host");
+       $self->{hostname} = $host;
 
        $self->{name} = $name ? $name : $call;
        $self->send($self->msg('l2',$self->{name}));
@@ -113,15 +112,19 @@ sub start
        $self->{pagelth} = $pagelth;
        ($self->{width}) = $line =~ /width=(\d+)/; $line =~ s/\s*width=\d+\s*//;
        if ($line =~ /host=/) {
-               ($self->{hostname}) = $line =~ /host=(\d+\.\d+\.\d+\.\d+)/; $line =~ s/\s*host=\d+\.\d+\.\d+\.\d+//;
-               unless ($self->{hostname}) {
-                       ($self->{hostname}) = $line =~ /host=($IPv6_re)/; 
-            $line =~ s/\s*host=$IPv6_re//;
+               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}");
+
        # set some necessary flags on the user if they are connecting
        $self->{beep} = $user->wantbeep;
        $self->{ann} = $user->wantann;
@@ -154,7 +157,7 @@ sub start
        $self->send_motd;
 
        # sort out privilege reduction
-       $self->{priv} = 0 if $line =~ /^(ax|te)/ && !$self->conn->{usedpasswd};
+       $self->{priv} = 0 unless $self->{hostname} eq '127.0.0.1' || $self->{hostname} eq '::1' || $self->conn->{usedpasswd};
 
        # get the filters
        my $nossid = $call;
index ef565eb7ddebae52ad0dac1246500f1b87b4d52a..1c7466a8a2a59f18581a1501b0d1304210abd2d4 100755 (executable)
@@ -239,7 +239,7 @@ sub new_channel
                                return;
                        }
                        if ($bumpexisting) {
-                               my $ip = $conn->peerhost || 'unknown';
+                               my $ip = $dxchan->hostname;
                                $dxchan->send_now('D', DXM::msg($lang, 'conbump', $call, $ip));
                                LogDbg('DXCommand', "$call bumped off by $ip, disconnected");
                                $dxchan->disconnect;
@@ -272,7 +272,7 @@ sub new_channel
                my $lock = $user->lockout if $user;
                if ($baseuser && $baseuser->lockout || $lock) {
                        if (!$user || !defined $lock || $lock) {
-                               my $host = $conn->peerhost || "unknown";
+                               my $host = $conn->peerhost;
                                LogDbg('DXCommand', "$call on $host is locked out, disconnected");
                                $conn->disconnect;
                                return;