Skip to content

Commit

Permalink
[Settings] Add verbose debugging setting
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Oct 16, 2024
1 parent 0b8bdbb commit ca58497
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,13 @@ msgstr ""
msgctxt "#30241"
msgid "Saves the license data for example: initial data, challenge data and response data, in the \"cdm\" folder of the Kodi data folder."
msgstr ""

#. Setting to enable verbose debug
msgctxt "#30242"
msgid "Enable verbose debug"
msgstr ""

#. Description of setting with label #30242
msgctxt "#30243"
msgid "Verbose debugging can be useful for debugging components, but in some cases it may expose sensitive information in the log."
msgstr ""
5 changes: 5 additions & 0 deletions inputstream.adaptive/resources/settings.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@
<default>false</default>
<control type="toggle" />
</setting>
<setting id="debug.verbose" type="boolean" label="30242" help="30243">
<level>0</level>
<default>false</default>
<control type="toggle" />
</setting>
</group>
</category>
</section>
Expand Down
20 changes: 11 additions & 9 deletions src/CompKodiProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "CompKodiProps.h"

#include "CompSettings.h"
#include "SrvBroker.h"
#include "decrypters/Helpers.h"
#include "utils/StringUtils.h"
#include "utils/UrlUtils.h"
Expand Down Expand Up @@ -122,11 +123,11 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri

for (const auto& prop : props)
{
bool logPropValRedacted{false};
const bool isRedacted = !CSrvBroker::GetSettings().IsDebugVerbose();

if (prop.first == PROP_LICENSE_URL) //! @todo: deprecated to be removed on Kodi 23
{
LogProp(prop.first, prop.second, true);
LogProp(prop.first, prop.second, isRedacted);
LOG::Log(
LOGWARNING,
"Warning \"inputstream.adaptive.license_url\" property for PVR API bug is deprecated and "
Expand All @@ -137,7 +138,7 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
}
else if (prop.first == PROP_LICENSE_URL_APPEND) //! @todo: deprecated to be removed on Kodi 23
{
LogProp(prop.first, prop.second, true);
LogProp(prop.first, prop.second, isRedacted);
LOG::Log(
LOGWARNING,
"Warning \"inputstream.adaptive.license_url_append\" property for PVR API bug is deprecated and "
Expand Down Expand Up @@ -240,14 +241,14 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
}
else if (prop.first == PROP_DRM && !prop.second.empty())
{
LogProp(prop.first, prop.second, true);
LogProp(prop.first, prop.second, isRedacted);
if (!ParseDrmConfig(prop.second))
LOG::LogF(LOGERROR, "Cannot parse \"%s\" property, wrong or malformed data.",
prop.first.c_str());
}
else if (prop.first == PROP_DRM_LEGACY && !prop.second.empty())
{
LogProp(prop.first, prop.second, true);
LogProp(prop.first, prop.second, isRedacted);
if (!ParseDrmLegacyConfig(prop.second))
LOG::LogF(LOGERROR, "Cannot parse \"%s\" property, wrong or malformed data.",
prop.first.c_str());
Expand Down Expand Up @@ -427,6 +428,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
drmCfg.priority = 1;

// Parse DRM properties
const bool isRedacted = !CSrvBroker::GetSettings().IsDebugVerbose();
std::string propValue;

if (STRING::GetMapValue(props, PROP_LICENSE_FLAGS, propValue))
Expand All @@ -441,27 +443,27 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(

if (STRING::GetMapValue(props, PROP_LICENSE_DATA, propValue))
{
LogProp(PROP_LICENSE_DATA, propValue, true);
LogProp(PROP_LICENSE_DATA, propValue, isRedacted);
drmCfg.initData = propValue;
}

if (STRING::GetMapValue(props, PROP_PRE_INIT_DATA, propValue))
{
LogProp(PROP_PRE_INIT_DATA, propValue, true);
LogProp(PROP_PRE_INIT_DATA, propValue, isRedacted);
drmCfg.preInitData = propValue;
}

// Parse DRM license properties

if (STRING::GetMapValue(props, PROP_SERVER_CERT, propValue))
{
LogProp(PROP_SERVER_CERT, propValue, true);
LogProp(PROP_SERVER_CERT, propValue, isRedacted);
drmCfg.license.serverCert = propValue;
}

if (STRING::GetMapValue(props, PROP_LICENSE_KEY, propValue))
{
LogProp(PROP_LICENSE_KEY, propValue, true);
LogProp(PROP_LICENSE_KEY, propValue, isRedacted);

std::vector<std::string> fields = STRING::SplitToVec(propValue, '|');
size_t fieldCount = fields.size();
Expand Down
5 changes: 5 additions & 0 deletions src/CompSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ bool ADP::SETTINGS::CCompSettings::IsDebugManifest() const
{
return kodi::addon::GetSettingBoolean("debug.save.manifest");
}

bool ADP::SETTINGS::CCompSettings::IsDebugVerbose() const
{
return kodi::addon::GetSettingBoolean("debug.verbose");
}
1 change: 1 addition & 0 deletions src/CompSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ATTR_DLL_LOCAL CCompSettings

bool IsDebugLicense() const;
bool IsDebugManifest() const;
bool IsDebugVerbose() const;
};

} // namespace SETTINGS
Expand Down

0 comments on commit ca58497

Please sign in to comment.