diff --git a/inputstream.adaptive/addon.xml.in b/inputstream.adaptive/addon.xml.in index fa3906e9d..ca8e2b656 100644 --- a/inputstream.adaptive/addon.xml.in +++ b/inputstream.adaptive/addon.xml.in @@ -10,7 +10,7 @@ name="adaptive" extension="" tags="true" - listitemprops="license_type|license_key|license_url|license_url_append|license_data|license_flags|manifest_type|server_certificate|manifest_update_parameter|manifest_upd_params|manifest_params|manifest_headers|stream_params|stream_headers|original_audio_language|play_timeshift_buffer|pre_init_data|stream_selection_type|chooser_bandwidth_max|chooser_resolution_max|chooser_resolution_secure_max|live_delay|internal_cookies|manifest_config" + listitemprops="license_type|license_key|license_url|license_url_append|license_data|license_flags|manifest_type|server_certificate|manifest_update_parameter|manifest_upd_params|manifest_params|manifest_headers|stream_params|stream_headers|original_audio_language|play_timeshift_buffer|pre_init_data|stream_selection_type|chooser_bandwidth_max|chooser_resolution_max|chooser_resolution_secure_max|live_delay|internal_cookies|config|manifest_config" library_@PLATFORM@="@LIBRARY_FILENAME@"/> @PLATFORM@ diff --git a/src/CompKodiProps.cpp b/src/CompKodiProps.cpp index 24d759b83..f5c88bb6f 100644 --- a/src/CompKodiProps.cpp +++ b/src/CompKodiProps.cpp @@ -51,7 +51,8 @@ constexpr std::string_view PROP_PLAY_TIMESHIFT_BUFFER = "inputstream.adaptive.pl constexpr std::string_view PROP_LIVE_DELAY = "inputstream.adaptive.live_delay"; constexpr std::string_view PROP_PRE_INIT_DATA = "inputstream.adaptive.pre_init_data"; -constexpr std::string_view PROP_INTERNAL_COOKIES = "inputstream.adaptive.internal_cookies"; +constexpr std::string_view PROP_CONFIG = "inputstream.adaptive.config"; +constexpr std::string_view PROP_INTERNAL_COOKIES = "inputstream.adaptive.internal_cookies"; //! @todo: to remove on Kodi 22 // Chooser's properties constexpr std::string_view PROP_STREAM_SELECTION_TYPE = "inputstream.adaptive.stream_selection_type"; @@ -207,9 +208,17 @@ ADP::KODI_PROPS::CCompKodiProps::CCompKodiProps(const std::map m_resolutionSecureMax; // Res. limit for DRM protected videos (values 0 means auto) }; +// Generic add-on configuration +struct Config +{ + // Determines whether curl verifies the authenticity of the peer's certificate, + // if set to false CA certificates are not loaded and verification will be skipped. + bool curlSSLVerifyPeer{true}; + // Determines if cookies are internally handled by InputStream Adaptive add-on + bool internalCookies{false}; +}; + struct ManifestConfig { // Limit the timeshift buffer depth, in seconds @@ -102,16 +112,17 @@ class ATTR_DLL_LOCAL CCompKodiProps */ std::string_view GetDrmPreInitData() const { return m_drmPreInitData; } - // \brief Defines if cookies are internally handled by InputStream Adaptive add-on - bool IsInternalCookies() const { return m_isInternalCookies; } - // \brief Specifies the chooser properties that will override XML settings const ChooserProps& GetChooserProps() const { return m_chooserProps; } + // \brief Specifies generic add-on configuration + const Config& GetConfig() const { return m_config; } + // \brief Specifies the manifest configuration const ManifestConfig& GetManifestConfig() const { return m_manifestConfig; } private: + void ParseConfig(const std::string& data); void ParseManifestConfig(const std::string& data); std::string m_licenseType; @@ -131,8 +142,8 @@ class ATTR_DLL_LOCAL CCompKodiProps bool m_playTimeshiftBuffer{false}; uint64_t m_liveDelay{0}; std::string m_drmPreInitData; - bool m_isInternalCookies{false}; ChooserProps m_chooserProps; + Config m_config; ManifestConfig m_manifestConfig; }; diff --git a/src/utils/CurlUtils.cpp b/src/utils/CurlUtils.cpp index 4a9e9195a..2809db300 100644 --- a/src/utils/CurlUtils.cpp +++ b/src/utils/CurlUtils.cpp @@ -184,22 +184,26 @@ UTILS::CURL::CUrl::CUrl(std::string_view url) { if (m_file.CURLCreate(url.data())) { + auto& kodiProps = CSrvBroker::GetKodiProps(); + // Default curl options m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "seekable", "0"); m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "acceptencoding", "gzip, deflate"); m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "failonerror", "false"); + if (!kodiProps.GetConfig().curlSSLVerifyPeer) + m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "verifypeer", "false"); // Add session cookies // NOTE: if kodi property inputstream.adaptive.stream_headers is set with "cookie" header // the cookies set by the property will replace these - if (CSrvBroker::GetKodiProps().IsInternalCookies()) + if (kodiProps.GetConfig().internalCookies) m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "cookie", GetCookies(url)); } } UTILS::CURL::CUrl::~CUrl() { - if (CSrvBroker::GetKodiProps().IsInternalCookies()) + if (CSrvBroker::GetKodiProps().GetConfig().internalCookies) StoreCookies(GetEffectiveUrl(), GetResponseHeaders("set-cookie")); m_file.Close();