2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 03:44:52 +00:00

82_LGTV_WebOS: fix connection problem / add SSL Support

git-svn-id: https://svn.fhem.de/fhem/trunk@28182 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2023-11-17 20:26:24 +00:00
parent bba9640ec3
commit 284849f576
2 changed files with 19 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#
# Special thanks goes to comitters:
# - Vitolinker / Commandref
# - ska- / SSL_startHandshake - SSL Port 3001 Support
#
#
# This script is free software; you can redistribute it and/or modify

View File

@ -61,6 +61,7 @@ my $missingModul = "";
eval { require MIME::Base64; 1 } or $missingModul .= 'MIME::Base64 ';
eval { require IO::Socket::INET; 1 } or $missingModul .= 'IO::Socket::INET ';
eval { use IO::Socket::SSL; 1 } or $missingModul .= 'IO::Socket::SSL ';
## no critic (Conditional "use" statement. Use "require" to conditionally include a module (Modules::ProhibitConditionalUseStatements))
eval { use Digest::SHA qw /sha1_hex/; 1 } or $missingModul .= 'Digest::SHA ';
@ -648,7 +649,21 @@ sub Open {
::Log3( $name, 4, "LGTV_WebOS ($name) - Baue Socket Verbindung auf" );
my $socket = IO::Socket::INET->new(
# create a connecting socket
# SSL_startHandshake is dependent on the protocol: this lets us use one socket
# to work with either SSL or non-SSL sockets.
my $socket = IO::Socket::SSL->new(
PeerHost => $host,
PeerPort => 3001,
Proto => 'tcp',
SSL_startHandshake => 1, #( $proto eq 'wss' ? 1 : 0 ),
SSL_verify_mode => SSL_VERIFY_NONE,
# Blocking => 1
KeepAlive => 1,
Timeout => $timeout
)
|| IO::Socket::INET->new(
PeerHost => $host,
PeerPort => $port,
Proto => 'tcp',
@ -656,7 +671,8 @@ sub Open {
Timeout => $timeout
)
or return ::Log3( $name, 4,
"LGTV_WebOS ($name) Couldn't connect to $host:$port" ); # open Socket
"LGTV_WebOS ($name) Couldn't connect to $host:$port/3001" )
; # open Socket
$hash->{FD} = $socket->fileno();
$hash->{CD} = $socket; # sysread / close won't work on fileno