mirror of
https://github.com/fhem/fhem-mirror.git
synced 2024-11-22 02:59:49 +00:00
fhem.pl: minor changes (Forum #95146)
git-svn-id: https://svn.fhem.de/fhem/trunk@18110 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ce9c491b8d
commit
b5af42f784
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user