mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-12 02:39:57 +00:00
HttpUtils.pm: add global dnsHostsFile attribute
git-svn-id: https://svn.fhem.de/fhem/trunk@15284 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1e0f2f1777
commit
5859b2cd4b
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: global dnsHostsFile attribute added (Forum #78025)
|
||||
- feature: 98_DOIFtools: add getter hsvColorGradient, returns a table of
|
||||
value, colornumber, RGB values and color bar using Color::hsv2rgb
|
||||
- new: 46_TeslaPowerwall2AC: retrieves data from a Tesla Powerwall 2AC
|
||||
|
@ -214,6 +214,24 @@ HttpUtils_gethostbyname($$$$)
|
||||
if($HU_dnsCache{$host} &&
|
||||
$HU_dnsCache{$host}{TS}+$HU_dnsCache{$host}{TTL} > gettimeofday());
|
||||
|
||||
my $dh = AttrVal("global", "dnsHostsFile", "undef");
|
||||
if($dh) {
|
||||
my $fh;
|
||||
if(open($fh, $dh)) {
|
||||
while(my $line = <$fh>) {
|
||||
if($line =~ m/^([^# \t]+).*\b\Q$host\E\b/) {
|
||||
if($1 =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ && # IP-Address
|
||||
$1<256 && $2<256 && $3<256 && $4<256) {
|
||||
$fn->($hash, undef, pack("CCCC", $1, $2, $3, $4));
|
||||
close($fh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
}
|
||||
|
||||
# Direct DNS Query via UDP
|
||||
my $c = IO::Socket::INET->new(Proto=>'udp', PeerAddr=>"$dnsServer:53");
|
||||
return $fn->($hash, "Cant create UDP socket:$!", undef) if(!$c);
|
||||
|
@ -1428,6 +1428,13 @@ The following local attributes are used by a wider range of devices:
|
||||
dynamically.
|
||||
</li><br>
|
||||
|
||||
<a name="dnsHostsFile"></a>
|
||||
<li>dnsHostsFile<br>
|
||||
If dnsServer is set, check the contents of the file specified as
|
||||
argument. To use the system hosts file, set it to /etc/hosts on
|
||||
Linux/Unix/OSX and C:\windows\system32\drivers\etc\hosts on Windows.
|
||||
</li><br>
|
||||
|
||||
<a name="dnsServer"></a>
|
||||
<li>dnsServer<br>
|
||||
Contains the IP address of the DNS Server. If some of the modules or
|
||||
|
@ -1520,6 +1520,14 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
waehrend der Laufzeit per JavaScript geladen.
|
||||
</li><br>
|
||||
|
||||
<a name="dnsHostsFile"></a>
|
||||
<li>dnsHostsFile<br>
|
||||
Falls dnsServer gesetzt ist, wird die angegebene Datei nach dem
|
||||
Hostnamen durchsucht. Um die vom System verwendete Datei zu benutzen,
|
||||
ist es unter Linux/Unix/OSX auf /etc/hosts und unter Windows auf
|
||||
C:\windows\system32\drivers\etc\hosts zu setzen.
|
||||
</li><br>
|
||||
|
||||
<a name="dnsServer"></a>
|
||||
<li>dnsServer<br>
|
||||
Enthält die IP Adresse des DNS Servers. Die von bestimmten Modulen
|
||||
|
@ -290,6 +290,7 @@ my @globalAttrList = qw(
|
||||
blockingCallMax
|
||||
commandref:modular,full
|
||||
configfile
|
||||
dnsHostsFile
|
||||
dnsServer
|
||||
dupTimeout
|
||||
exclude_from_update
|
||||
|
Loading…
x
Reference in New Issue
Block a user