From 0de1a272bd43c887020d9e03a4f56f44ab4bb080 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Fri, 27 Oct 2017 00:04:24 +0100 Subject: [PATCH] Get basic web protocol working --- Changes | 4 +++- perl/DXChannel.pm | 2 +- perl/DXCommandmode.pm | 21 ++++++++++++--------- perl/cluster.pl | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 49fda7c1..ae2b6875 100644 --- 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======================================================================= diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index f8af917e..a9dbd86d 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -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 diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 9a00febb..cbba3b79 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -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; diff --git a/perl/cluster.pl b/perl/cluster.pl index ef565eb7..1c7466a8 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -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; -- 2.43.0