mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
Port passwort second round:
- make fhem2fhem sending work - parse telnet parameters: disable echo git-svn-id: https://svn.fhem.de/fhem/trunk@1614 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
811afcbd4f
commit
de1a345e1f
@ -70,7 +70,6 @@ FHEM2FHEM_Define($$)
|
|||||||
$hash->{Host} = $dev;
|
$hash->{Host} = $dev;
|
||||||
$hash->{portpassword} = $a[4] if(@a == 5);
|
$hash->{portpassword} = $a[4] if(@a == 5);
|
||||||
|
|
||||||
|
|
||||||
FHEM2FHEM_CloseDev($hash); # Modify...
|
FHEM2FHEM_CloseDev($hash); # Modify...
|
||||||
return FHEM2FHEM_OpenDev($hash, 0);
|
return FHEM2FHEM_OpenDev($hash, 0);
|
||||||
}
|
}
|
||||||
@ -94,6 +93,8 @@ FHEM2FHEM_Write($$)
|
|||||||
my $conn = IO::Socket::INET->new(PeerAddr => $dev);
|
my $conn = IO::Socket::INET->new(PeerAddr => $dev);
|
||||||
return if(!$conn); # Hopefuly it is reported elsewhere
|
return if(!$conn); # Hopefuly it is reported elsewhere
|
||||||
$hash->{TCPDev2} = $conn;
|
$hash->{TCPDev2} = $conn;
|
||||||
|
syswrite($hash->{TCPDev2}, $hash->{portpassword} . "\n")
|
||||||
|
if($hash->{portpassword});
|
||||||
}
|
}
|
||||||
my $rdev = $hash->{rawDevice};
|
my $rdev = $hash->{rawDevice};
|
||||||
syswrite($hash->{TCPDev2}, "iowrite $rdev $fn $msg\n");
|
syswrite($hash->{TCPDev2}, "iowrite $rdev $fn $msg\n");
|
||||||
|
@ -1339,8 +1339,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<a name="portpassword"></a>
|
<a name="portpassword"></a>
|
||||||
<li>portpassword<br>
|
<li>portpassword<br>
|
||||||
Specify a port password, which has to be entered as the very first
|
Specify a port password, which has to be entered as the very first
|
||||||
string after the connection is established. Note: the password will be
|
string after the connection is established.
|
||||||
visible when you are typing it in a the telnet connection.
|
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
|
||||||
|
11
fhem/fhem.pl
11
fhem/fhem.pl
@ -463,6 +463,9 @@ while (1) {
|
|||||||
$client{$fd}{addr} = "$caddr:$port";
|
$client{$fd}{addr} = "$caddr:$port";
|
||||||
$client{$fd}{buffer} = "";
|
$client{$fd}{buffer} = "";
|
||||||
Log 4, "Connection accepted from $client{$fd}{addr}";
|
Log 4, "Connection accepted from $client{$fd}{addr}";
|
||||||
|
# Telnet is strange: tell "Will echo" to supress password
|
||||||
|
syswrite($fd, sprintf("%c%c%cPassword: ", 255, 251, 1))
|
||||||
|
if($attr{global}{portpassword});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $c (keys %client) {
|
foreach my $c (keys %client) {
|
||||||
@ -480,6 +483,12 @@ while (1) {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$buf =~ s/\r//g;
|
$buf =~ s/\r//g;
|
||||||
|
if($attr{global}{portpassword}) {
|
||||||
|
$buf =~ s/\xff..//g; # Telnet IAC stuff
|
||||||
|
$buf =~ s/\xfd(.)//; # Telnet Do ?
|
||||||
|
syswrite($client{$c}{fd}, sprintf("%c%c%c", 0xff, 0xfc, ord($1)))
|
||||||
|
if(defined($1)) # Wont / ^C handling
|
||||||
|
}
|
||||||
$client{$c}{buffer} .= $buf;
|
$client{$c}{buffer} .= $buf;
|
||||||
AnalyzeInput($c);
|
AnalyzeInput($c);
|
||||||
}
|
}
|
||||||
@ -640,11 +649,11 @@ AnalyzeInput($)
|
|||||||
$client{$c}{buffer} = $rest;
|
$client{$c}{buffer} = $rest;
|
||||||
|
|
||||||
if($attr{global}{portpassword} && !$client{$c}{pwEntered}) {
|
if($attr{global}{portpassword} && !$client{$c}{pwEntered}) {
|
||||||
|
syswrite($client{$c}{fd}, sprintf("%c%c%c\n", 255, 252, 1)); # Wont echo.
|
||||||
if($attr{global}{portpassword} eq $cmd) {
|
if($attr{global}{portpassword} eq $cmd) {
|
||||||
$client{$c}{pwEntered} = 1;
|
$client{$c}{pwEntered} = 1;
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
syswrite($client{$c}{fd}, "Password required\r\n");
|
|
||||||
DoClose($c);
|
DoClose($c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user