+20Jan23=======================================================================
+1. Add the variable @main::localhost_names to allow other IP addresses to
+ be treated in the same way as localhost in item 1 on 19Jan23 below. NOTE
+ you must include ALL the normal localhost names + any other interface
+ names that you might want to include:
+
+ set/var @main::localhost_names qw(127.0.0.1 ::1 192.168.1.30)
+
+ using the qw() construction is easier than:
+
+ set/var @main::localhost_names ('127.0.0.1', '::1', '192.168.1.30')
+
+ but either will work. You can define as many IP addresses as you like and
+ they can be IPV4 or 6.
+
+ You do NOT need to fiddle with this unless you specifically have more
+ than just the normal definitions of localhost. So for 'normal' nodes with
+ one external interface, you DO NOT NEED TO DO ANY OF THIS.
19Jan23=======================================================================
1. Introduce aliasing for localhost in DX Spots and outgoing PC92 A records
on login. There are two variables which can be set with the alias to use:
return (1, $self->msg('e28')) unless $self->isregistered;
-my $addr = $self->hostname || '127.0.0.1';
-$addr = $main::localhost_alias_ipv6 if $addr eq '::1' && $main::localhost_alias_ipv6;
-$addr = $main::localhost_alias_ipv4 if $addr =~ /^127\./ && $main::localhost_alias_ipv4;
+my $addr = DXCommandmode::alias_localhost($self->hostname || '127.0.0.1');
Log('cmd', "$self->{call}|$addr|dx|$line");
use strict;
use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug
- $maxbadcount $msgpolltime $default_pagelth $cmdimportdir $users $maxusers);
+ $maxbadcount $msgpolltime $default_pagelth $cmdimportdir $users $maxusers
+);
%Cache = (); # cache of dynamically loaded routine's mod times
%cmd_cache = (); # cache of short names
my $pkg = shift;
my $call = shift;
# my @rout = $main::routeroot->add_user($call, Route::here(1));
- my $ipaddr = $self->hostname;
- $ipaddr = $main::localhost_alias_ipv6 if $ipaddr eq '::1' && $main::localhost_alias_ipv6;
- $ipaddr = $main::localhost_alias_ipv4 if $ipaddr =~ /^127\./ && $main::localhost_alias_ipv4;
+ my $ipaddr = alias_localhost($self->hostname);
DXProt::_add_thingy($main::routeroot, [$call, 0, 0, 1, undef, undef, $ipaddr], );
# ALWAYS output the user
return ($users, $maxusers);
}
+# alias localhost if required. This is designed to repress all localhost and other
+# internal interfaces to a fixed (outside) IPv4 or IPV6 address
+sub alias_localhost
+{
+ my $hostname = shift;
+ if ($hostname =~ /./) {
+ return $hostname unless $main::localhost_alias_ipv4;
+ return (grep $hostname eq $_, @main::localhost_names) ? $main::localhost_alias_ipv4 : $hostname;
+ } elsif ($hostname =~ /:/) {
+ return $hostname unless $main::localhost_alias_ipv6;
+ return (grep $hostname eq $_, @main::localhost_names) ? $main::localhost_alias_ipv6 : $hostname;
+ }
+ return $hostname;
+}
+
1;
__END__
our $cldsecs; # the amount of cpu time any child processes have consumed
our $allowslashcall; # Allow / in connecting callsigns (ie PA0/G1TLH, or even PA0/G1TLH/2)
+our @localhost_names = qw(127.0.0.1 ::1); # all ip addresses that will need to be aliased below (ipv4 or ipv6)
+
our $localhost_alias_ipv4; # these are the IPV4 & 6 aliases for localhost connected clients
our $localhost_alias_ipv6; # for things (PC92, PC61 etc) that expose IP addresses. These *may*
# be set by Msg.pm stuff if they are left undefined but, if you need