diff --git a/fhem/CHANGED b/fhem/CHANGED index 728f442e3..3858ac38e 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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 added new global attribute added new global attribute added - feature: new module 57_Calendar.pm (Boris) + - feature: new module 57_Calendar.pm (Boris) - feature: new parameter for updatefhem added (M. Fischer) new global attribute added (M. Fischer) + - feature: optional telnet password added / telnet port is optional - 2011-12-31 (5.2) - bugfix: applying smallscreen attributes to firefox/opera diff --git a/fhem/FHEM/93_FHEM2FHEM.pm b/fhem/FHEM/93_FHEM2FHEM.pm index 0ab64b0e5..48c08bf04 100755 --- a/fhem/FHEM/93_FHEM2FHEM.pm +++ b/fhem/FHEM/93_FHEM2FHEM.pm @@ -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 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; diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index d18198137..813d38ee0 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -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.

+ This attribute is optional starting with fhem 5.3.

To use IPV6, specify the port as IPV6:<number>, 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.
+ +
  • portpassword
    + 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. +

  • + +
  • statefile
    @@ -2785,7 +2794,15 @@ A line ending with \ will be concatenated with the next one, so long lines

  • hmProtocolEvents
    - 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: +
      + + 2012-05-17 09:44:22.515 CUL CULHM RCV L:0B N:81 CMD:A258 SRC:...... DST:...... 0000 (TYPE=88,WAKEMEUP,BIDI,RPTEN) + +


  • @@ -8162,7 +8179,7 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK.
    You need to define an RFXtrx433 Define
      - define <name> FHEM2FHEM <host:portnr> [LOG:regexp|RAW:devicename] + define <name> FHEM2FHEM <host:portnr> [LOG:regexp|RAW:devicename] {portpassword}

      @@ -8195,9 +8212,10 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK.
      You need to define an RFXtrx433 usually with the device-node "none", so it is only a dummy device. All necessary attributes (e.g. rfmode if the remote CUL is in HomeMatic mode) must also be set for the local device. -
    + The last parameter specifies an optional portpassword, if the remote server + activated portpassword.
    Examples:
      diff --git a/fhem/fhem.pl b/fhem/fhem.pl index c44c72bdc..8305027c8 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -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", "")) {