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

Allowedfrom added

git-svn-id: https://svn.fhem.de/fhem/trunk@145 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2008-01-08 20:15:58 +00:00
parent f693a6b452
commit 5833bc1e61
4 changed files with 35 additions and 10 deletions

View File

@ -378,6 +378,7 @@
- bugfix: 99_SUNRISE_EL.pm: may schedule double events
- bugfix: 62_EMEM.pl, contrib/em1010.pl: correct readings for energy_kWh
and energy_kWh_w (Boris, 06.01.08)
- feature: gloabl attr allowfrom, as wished by Holger (8.1.2008)
- TODO
emem -2.5kW / getDevData for emwz -1

View File

@ -189,7 +189,11 @@
- Boris Sun Jan 06 13:35:00 CET 2008
- bugfix: 62_EMEM.pm: changed reading energy_total_kWh to energy_kWh_w,
added energy_kWh (formerly energy_total_kWh)
- changed em1010.pl accordingly, added em1000em doc for getDevStatus reply from
device
- changed em1010.pl accordingly, added em1000em doc for getDevStatus reply
from device
- minor changes in fhem.html
- Rudi Tue Jan 8 21:13:08 MET 2008
- feature: attr global allowfrom <ip-adresses/hostnames>
If set, only connects from these addresses are allowed. This is to
"simulate" a little bit of security.

View File

@ -193,6 +193,13 @@ split in multiple lines<br><br>
non-localhost connections too.
</li><br>
<a name="allowfrom"></a>
<li>allowfrom<br>
Comma (,) separated list of ip-addresses or hostnames. If set,
only connections from these addresses are allowed.
</li><br>
<a name="statefile"></a>
<a name="statefile"></a>
<li>statefile<br>
Set the filename where the state and certain <a href="#at">at</a>

View File

@ -138,15 +138,15 @@ my %intAt; # Internal at timer hash.
my $intAtCnt=0;
my $reread_active = 0;
my $AttrList = "room comment";
my $cvsid = '$Id: fhem.pl,v 1.36 2007-12-31 14:43:02 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.37 2008-01-08 20:15:58 rudolfkoenig Exp $';
$init_done = 0;
$modules{_internal_}{ORDER} = -1;
$modules{_internal_}{AttrList} = "configfile logfile lastinclude modpath " .
"pidfilename port statefile title userattr " .
"nrarchive archivedir archivecmd " .
"verbose:1,2,3,4,5 version";
$modules{_internal_}{AttrList} =
"archivecmd allowfrom archivedir configfile lastinclude logfile " .
"modpath nrarchive pidfilename port statefile title userattr " .
"verbose:1,2,3,4,5 version";
my %cmds = (
@ -295,10 +295,23 @@ while (1) {
Log 1, "Accept failed: $!";
next;
}
my @clientsock = sockaddr_in($clientinfo[1]);
my ($port, $iaddr) = sockaddr_in($clientinfo[1]);
my $caddr = inet_ntoa($iaddr);
my $af = $attr{global}{allowfrom};
if($af) {
if(",$af," !~ m/,$caddr,/) {
my $hostname = gethostbyaddr($iaddr, AF_INET);
if(!$hostname || ",$af," !~ m/,$hostname,/) {
Log 1, "Connection refused from $caddr:$port";
close($clientinfo[0]);
next;
}
}
}
my $fd = $clientinfo[0];
$client{$fd}{fd} = $fd;
$client{$fd}{addr} = inet_ntoa($clientsock[1]) . ":" . $clientsock[0];
$client{$fd}{addr} = "$caddr:$port";
$client{$fd}{buffer} = "";
Log 4, "Connection accepted from $client{$fd}{addr}";
}