2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

optional telnet password

git-svn-id: https://svn.fhem.de/fhem/trunk@1612 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-06-13 10:57:58 +00:00
parent 53de545c0e
commit 886863dfb7
4 changed files with 51 additions and 16 deletions

View File

@ -33,14 +33,16 @@
- change: FHEMWEB support for the new www/pgm2 directroy added (M. Fischer)
- change: Makefile support for for the new www/pgm2 directroy and new targets
backup and uninstall added. More verbose output. (M. Fischer)
- change: backuproutine separated from updatefhem to a new command (M. Fischer)
- change: backup separated from updatefhem to a new command (M. Fischer)
- feature: new command backup added (M. Fischer)
new global attribute <backupsymlink> added
new global attribute <backupcmd> added
new global attribute <backup_before_update> added
- feature: new module 57_Calendar.pm (Boris)
- feature: new module 57_Calendar.pm (Boris)
- feature: new parameter <changed> for updatefhem added (M. Fischer)
new global attribute <exclude_from_update> added (M. Fischer)
- feature: optional telnet password added / telnet port is optional
- 2011-12-31 (5.2)
- bugfix: applying smallscreen attributes to firefox/opera

View File

@ -40,9 +40,9 @@ FHEM2FHEM_Define($$)
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
if(@a != 4 || !($a[3] =~ m/^(LOG|RAW):(.*)$/)) {
if(@a < 4 || @a > 5 || !($a[3] =~ m/^(LOG|RAW):(.*)$/)) {
my $msg = "wrong syntax: define <name> FHEM2FHEM host[:port] ".
"[LOG:regexp|RAW:device]";
"[LOG:regexp|RAW:device] {portpasswort}";
Log 2, $msg;
return $msg;
}
@ -68,6 +68,7 @@ FHEM2FHEM_Define($$)
$hash->{Host} = $dev;
}
$hash->{Host} = $dev;
$hash->{portpassword} = $a[4] if(@a == 5);
FHEM2FHEM_CloseDev($hash); # Modify...
@ -231,6 +232,8 @@ FHEM2FHEM_OpenDev($$)
$hash->{STATE}= "connected";
DoTrigger($name, "CONNECTED") if($reopen);
syswrite($hash->{TCPDev}, $hash->{portpassword} . "\n")
if($hash->{portpassword});
my $msg = $hash->{informType} eq "LOG" ? "inform on" : "inform raw";
syswrite($hash->{TCPDev}, $msg . "\n");
return undef;

View File

@ -1329,12 +1329,21 @@ A line ending with \ will be concatenated with the next one, so long lines
will only listen for connections from the localhost per default. If
there is a second value "global" then the server will listen for
non-localhost connections too.<br><br>
This attribute is optional starting with fhem 5.3.<br><br>
To use IPV6, specify the port as IPV6:&lt;number&gt;, in this
case the perl module IO::Socket:INET6 will be requested.
On Linux you may have to install it with cpan -i IO::Socket::INET6 or
apt-get libio-socket-inet6-perl; the OSX perl already has this module.
</li><br>
<a name="portpassword"></a>
<li>portpassword<br>
Specify a port password, which has to be entered as the very first
string after the connection is established. Note: the password will be
visible when you are typing it in a the telnet connection.
</li><br>
<a name="statefile"></a>
<a name="statefile"></a>
<li>statefile<br>
@ -2785,7 +2794,15 @@ A line ending with \ will be concatenated with the next one, so long lines
</li><br>
<li><a name="hmProtocolEvents">hmProtocolEvents</a><br>
Generate events for HomeMatic protocol messages.
Generate events for HomeMatic protocol messages. These are normally
used for debugging, by activating "inform timer" in a telnet session,
or looking at the "Event Monitor" window in the FHEMWEB frontend.
Example:
<ul>
<code>
2012-05-17 09:44:22.515 CUL CULHM RCV L:0B N:81 CMD:A258 SRC:...... DST:...... 0000 (TYPE=88,WAKEMEUP,BIDI,RPTEN)
</code>
</ul>
</li><br>
</ul>
<br>
@ -8162,7 +8179,7 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK. <br> You need to define an RFXtrx433
<a name="FHEM2FHEMdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; FHEM2FHEM &lt;host:portnr&gt; [LOG:regexp|RAW:devicename]
<code>define &lt;name&gt; FHEM2FHEM &lt;host:portnr&gt; [LOG:regexp|RAW:devicename] {portpassword}
</code>
<br>
<br>
@ -8195,9 +8212,10 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK. <br> You need to define an RFXtrx433
usually with the device-node "none", so it is only a dummy device. All
necessary attributes (e.g. <a href="#rfmode">rfmode</a> if the remote CUL
is in HomeMatic mode) must also be set for the local device.
</li>
</ul>
The last parameter specifies an optional portpassword, if the remote server
activated <a href="#portpassword">portpassword</a>.
<br>
Examples:
<ul>

View File

@ -190,12 +190,13 @@ $init_done = 0;
$modules{Global}{ORDER} = -1;
$modules{Global}{LOADED} = 1;
$modules{Global}{AttrList} =
"archivecmd allowfrom apiversion archivedir configfile lastinclude logfile " .
"modpath nrarchive pidfilename port statefile title userattr " .
"verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " .
"autoload_undefined_devices dupTimeout latitude longitude " .
"backupcmd backupdir backupsymlink backup_before_update " .
"exclude_from_update ";
"archivecmd allowfrom apiversion archivedir configfile lastinclude logfile " .
"modpath nrarchive pidfilename port portpassword statefile title userattr " .
"verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " .
"autoload_undefined_devices dupTimeout latitude longitude " .
"backupcmd backupdir backupsymlink backup_before_update " .
"exclude_from_update ";
$modules{Global}{AttrFn} = "GlobalAttr";
%cmds = (
@ -333,7 +334,7 @@ while(time() < 2*3600) {
my $ret = CommandInclude(undef, $attr{global}{configfile});
Log 1, "configfile: $ret" if($ret);
die("No port specified in the configfile.\n") if(!$server);
#die("No port specified in the configfile.\n") if(!$server);
if($attr{global}{statefile} && -r $attr{global}{statefile}) {
$ret = CommandInclude(undef, $attr{global}{statefile});
@ -368,7 +369,7 @@ while (1) {
my $timeout = HandleTimeout();
vec($rin, $server->fileno(), 1) = 1;
vec($rin, $server->fileno(), 1) = 1 if($server);
foreach my $p (keys %selectlist) {
vec($rin, $selectlist{$p}{FD}, 1) = 1;
}
@ -433,7 +434,7 @@ while (1) {
}
}
if(vec($rout, $server->fileno(), 1)) {
if($server && vec($rout, $server->fileno(), 1)) {
my @clientinfo = $server->accept();
if(!@clientinfo) {
Log 1, "Accept failed: $!";
@ -637,6 +638,18 @@ AnalyzeInput($)
while($client{$c}{buffer} =~ m/\n/) {
my ($cmd, $rest) = split("\n", $client{$c}{buffer}, 2);
$client{$c}{buffer} = $rest;
if($attr{global}{portpassword} && !$client{$c}{pwEntered}) {
if($attr{global}{portpassword} eq $cmd) {
$client{$c}{pwEntered} = 1;
next;
} else {
syswrite($client{$c}{fd}, "Password required\r\n");
DoClose($c);
return;
}
}
if($cmd) {
if($cmd =~ m/\\ *$/) { # Multi-line
$client{$c}{prevlines} .= $cmd . "\n";
@ -866,7 +879,6 @@ CommandInclude($$)
if(!open($fh, $arg)) {
return "Can't open $arg: $!";
}
if(!$init_done &&
$arg ne AttrVal("global", "statefile", "") &&
$arg ne AttrVal("global", "configfile", "")) {