Also clarify things like the ultimate hostname if it is an IP based system.
This means that stuff coming in on the web will be identified by the IP
address that they connect to, rather than the IP address of the channel. Basically
a Web interface is a proxy and therefore the connection object needs the address
of the web server, but things like DX spots need the proxy address.
my $ipaddr;
if ($self->conn && $self->conn->peerhost) {
- my $addr = $self->conn->peerhost;
+ my $addr = $self->hostname;
$ipaddr = $addr unless !is_ipaddr($addr) || $addr =~ /^127\./ || $addr =~ /^::[0-9a-f]+$/;
} elsif ($self->inscript) {
$ipaddr = "script";
$sort = "AK1A" if $dxchan->is_ak1a;
my $ipaddr;
- if ($dxchan->conn->peerhost) {
- my $addr = $dxchan->conn->peerhost;
- $ipaddr = $addr if is_ipaddr($addr);
+ my $addr = $dxchan->hostname;
+ if ($addr) {
+ $ipaddr = $addr if is_ipaddr($addr);
$ipaddr = 'local' if $addr =~ /^127\./ || $addr =~ /^::[0-9a-f]+$/;
}
$ipaddr = 'ax25' if $dxchan->conn->ax25;
my $type = $dxchan->is_node ? "NODE" : "USER";\r
my $sort = " ";\r
if ($dxchan->is_node) {\r
- $sort = 'ANEA' if $dxchan->is_aranea;\r
$sort = "DXSP" if $dxchan->is_spider;\r
$sort = "CLX " if $dxchan->is_clx;\r
$sort = "DXNT" if $dxchan->is_dxnet;\r
$sort = "AR-C" if $dxchan->is_arcluster;\r
$sort = "AK1A" if $dxchan->is_ak1a;\r
+ } else {\r
+ $sort = "LOCL" if $dxchan->conn->isa('IntMsg');\r
+ $sort = "WEB " if $dxchan->is_web;\r
+ $sort = "EXT " if $dxchan->conn->isa('ExtMsg');\r
}\r
my $name = $dxchan->user->name || " ";\r
my $ping = $dxchan->is_node && $dxchan != $main::me ? sprintf("%5.2f", $dxchan->pingave) : " ";\r
my $conn = $dxchan->conn;\r
my $ip = '';\r
if ($conn) {\r
- $ip = $conn->{peerhost} if exists $conn->{peerhost};\r
+ $ip = $dxchan->hostname;\r
$ip = "AGW Port ($conn->{agwport})" if exists $conn->{agwport};\r
}\r
push @out, sprintf "%10s $type $sort $t %-10.10s $ping $ip", $call, $name;\r
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',
);
$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection
$self->normal($line);
} elsif ($sort eq 'G') {
$self->enhanced($line);
- } elsif ($sort eq 'A' || $sort eq 'O') {
+ } elsif ($sort eq 'A' || $sort eq 'O' || $sort eq 'W') {
$self->start($line, $sort);
} elsif ($sort eq 'Z') {
$self->disconnect;
use AsyncMsg;
use JSON;
use Time::HiRes qw(gettimeofday tv_interval);
+use Regexp::IPv6 qw($IPv6_re);
use Mojo::IOLoop;
use Mojo::IOLoop::ForkCall;
$pagelth = $default_pagelth unless defined $pagelth;
$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//;
+ }
+ }
$self->{width} = 80 unless $self->{width} && $self->{width} > 80;
$self->{consort} = $line; # save the connection type
my $host = $self->{conn}->peerhost;
$host ||= "AGW Port #$self->{conn}->{agwport}" if exists $self->{conn}->{agwport};
$host ||= "unknown";
+ $self->{hostname} = $host if is_ipaddr($host);
Log('DXProt', "$call connected from $host");
sub peerhost
{
my $conn = shift;
- $conn->{peerhost} ||= 'ax25' if $conn->ax25;
- $conn->{peerhost} ||= $conn->{sock}->handle->peerhost if $conn->{sock};
- $conn->{peerhost} ||= 'UNKNOWN';
+ unless ($conn->{peerhost}) {
+ $conn->{peerhost} ||= 'ax25' if $conn->ax25;
+ $conn->{peerhost} ||= $conn->{sock}->handle->peerhost if $conn->{sock};
+ $conn->{peerhost} ||= 'UNKNOWN';
+ }
return $conn->{peerhost};
}
$user->wantbeep(0);
$user->name('web');
$user->qth('on the web');
- $user->homenode($main::call);
+ $user->homenode($main::mycall);
$user->lat($main::mylatitude);
$user->long($main::mylongitude);
$user->qra($main::mylocator);
- $user->put;
}
+ $conn->conns($call);
$dxchan = Web->new($call, $conn, $user);
- $dxchan->sort('W');
$dxchan->enhanced(1);
$dxchan->ve7cc(1);
- $conn->conns($call);
$msg =~ s/^A#WEB|/A$call|/;
$conn->send_now("C$call");
} else {
$dxchan = DXProt->new($call, $conn, $user);
} elsif ($user->is_user) {
$dxchan = DXCommandmode->new($call, $conn, $user);
- # } elsif ($user->is_bbs) { # there is no support so
- # $dxchan = BBS->new($call, $conn, $user); # don't allow it!!!
} else {
die "Invalid sort of user on $call = $sort";
}
$conn->set_error(sub {my $err = shift; LogDbg('DXCommand', "Comms error '$err' received for call $dxchan->{call}"); $dxchan->disconnect(1);});
$conn->set_on_eof(sub {$dxchan->disconnect});
$conn->set_rproc(sub {my ($conn,$msg) = @_; $dxchan->rec($msg);});
+ if ($sort eq 'W') {
+ $dxchan->enhanced(1);
+ $dxchan->sort('W');
+ }
$dxchan->rec($msg);
}