2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

00_FBAHAHTTP.pm: implement HTTPS for connection (Forum #85286)

git-svn-id: https://svn.fhem.de/fhem/trunk@16344 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2018-03-06 21:06:34 +00:00
parent 64ea5a6abe
commit b4f252ceec
2 changed files with 18 additions and 5 deletions

View File

@ -128,9 +128,10 @@ FBAHAHTTP_Poll($)
return $ret if($ret);
}
my $sid = $hash->{".SID"};
my $host = ($hash->{DEF} =~ m/^http/i ? $hash->{DEF} : "http://$hash->{DEF}");
HttpUtils_NonblockingGet({
url=>"http://$hash->{DEF}/webservices/homeautoswitch.lua?sid=$sid".
url=>"$host/webservices/homeautoswitch.lua?sid=$sid".
"&switchcmd=getdevicelistinfos",
loglevel => AttrVal($name, "verbose", 4),
timeout => AttrVal($name, "fbTimeout", 4),
@ -221,8 +222,9 @@ FBAHAHTTP_ProcessStack($)
my ($hash) = @_;
my $name = $hash->{NAME};
my $msg = $hash->{CmdStack}->[0];
my $host = ($hash->{DEF} =~ m/^http/i ? $hash->{DEF} : "http://$hash->{DEF}");
HttpUtils_NonblockingGet({
url=>"http://$hash->{DEF}/webservices/homeautoswitch.lua?$msg",
url=>"$host/webservices/homeautoswitch.lua?$msg",
loglevel => AttrVal($name, "verbose", 4),
timeout => AttrVal($name, "fbTimeout", 4),
callback => sub {
@ -311,6 +313,9 @@ FBAHAHTTP_Write($$$)
<ul>
<code>define fb1 FBAHAHTTP fritz.box</code><br>
</ul>
Note: to specify HTTPS for the connection use https://fritz.box as
hostname. To explicitly specify the port, postfix the hostname with :port,
as in https://fritz.box:443
</ul>
<br>

View File

@ -11,11 +11,19 @@ my ($lastOkPw, $lastOkUser, $lastOkHost, $lastOkTime) =("", "", 0);
sub FB_checkPw(@);
sub
FB_host2URL($)
{
my ($h) = @_;
return "$h/" if($h =~ m/^http/i);
return "http://$h/";
}
sub
FB_doCheckPW($$$)
{
my ($host, $user, $pw) = @_;
my $data = GetFileFromURL("http://$host/login_sid.lua", undef, undef, 1);
my $data = GetFileFromURL(FB_host2URL($host)."login_sid.lua",undef,undef,1);
return undef if(!$data);
my $chl="";
@ -28,14 +36,14 @@ FB_doCheckPW($$$)
my @d = ( "login:command/response=$chlAnsw",
"getpage=../html/de/internet/connect_status.txt" );
$data = join("&", map {join("=", map {urlEncode($_)} split("=",$_,2))} @d);
$data = GetFileFromURL("http://$host/cgi-bin/webcm", undef, $data, 1);
$data = GetFileFromURL(FB_host2URL($host)."cgi-bin/webcm", undef, $data, 1);
my $isOk = ($data =~ m/checkStatus/);
return $isOk;
} else { # FritzOS >= 5.50
my @d = ( "response=$chlAnsw", "page=/login_sid.lua" );
$data = join("&", map {join("=", map {urlEncode($_)} split("=",$_,2))} @d);
my $url = "http://$host/login_sid.lua";
my $url = FB_host2URL($host)."login_sid.lua";
$url .= "?username=$user" if($user);
$data = GetFileFromURL($url, undef, $data, 1);