diff --git a/contrib/tcptee.pl b/contrib/tcptee.pl index 665ad6d09..baaaac1c1 100644 --- a/contrib/tcptee.pl +++ b/contrib/tcptee.pl @@ -13,8 +13,10 @@ my $myPort; my $ssl; my $serverHost; my $serverPort; -my $usage = "Usage: tcptee.pl [--bidi] [--loop] [--ssl] " . +my $IPV6; +my $usage = "Usage: tcptee.pl [--IPV6] [--bidi] [--loop] [--ssl] " . "[myIp:]myPort[:serverHost:serverPort]\n"; +sub tPrint($); while(@ARGV) { my $opt = shift @ARGV; @@ -22,6 +24,15 @@ while(@ARGV) { if($opt =~ m/^--bidi$/i) { $bidi = 1; + } elsif($opt =~ m/^--IPV6$/i) { + eval "require IO::Socket::INET6; use Socket6;"; + if($@) { + tPrint $@; + tPrint "Can't load INET6, falling back to IPV4"; + } else { + $IPV6 = 1; + } + } elsif($opt =~ m/^--loop$/i) { $loop = 1 @@ -80,12 +91,16 @@ for(;;) { # Now open our listener - $myfd = IO::Socket::INET->new( - LocalHost => $myIp, - LocalPort => $myPort, - Listen => 10, - ReuseAddr => 1 - ); + my @opts = ( + Domain => $IPV6 ? AF_INET6() : AF_UNSPEC, + LocalHost => $myIp, + LocalPort => $myPort, + Listen => 10, + ReuseAddr => 1 + ); + $myfd = $IPV6 ? + IO::Socket::INET6->new(@opts) : + IO::Socket::INET->new(@opts); die "Opening port $myPort: $!\n" if(!$myfd); tPrint "Port $myPort opened"; @@ -113,10 +128,12 @@ for(;;) { tPrint "Accept failed: $!"; next; } - my ($port, $iaddr) = sockaddr_in($clientinfo[1]); + my ($port, $iaddr) = ($IPV6 ? sockaddr_in6($clientinfo[1]) : + sockaddr_in($clientinfo[1])); my $fd = $clientinfo[0]; $clients{$fd}{fd} = $fd; - $clients{$fd}{addr} = inet_ntoa($iaddr) . ":$port"; + $clients{$fd}{addr} = ($IPV6 ? inet_ntop(AF_INET6(), $iaddr) : + inet_ntoa($iaddr)) . ":$port"; tPrint "Connection accepted from $clients{$fd}{addr}"; if($ssl) { diff --git a/fhem.pl b/fhem.pl index 1e716a1e3..b23aab9b9 100755 --- a/fhem.pl +++ b/fhem.pl @@ -4,7 +4,7 @@ # # Copyright notice # -# (c) 2005-2018 +# (c) 2005-2019 # Copyright: Rudolf Koenig (r dot koenig at koeniglich dot de) # All rights reserved # @@ -2643,7 +2643,7 @@ GlobalAttr($$$$) my ($type, $me, $name, $val) = @_; if($type eq "del") { - my %noDel = ( modpath=>1, verbose=>1, logfile=>1 ); + my %noDel = ( modpath=>1, verbose=>1, logfile=>1, configfile=>1 ); return "The global attribute $name cannot be deleted" if($noDel{$name}); $featurelevel = 5.9 if($name eq "featurelevel"); $haveInet6 = 0 if($name eq "useInet6"); # IPv6