Skip to content

Commit

Permalink
add settings for tap / track_pos hash checking
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Jan 6, 2025
1 parent 39b2f89 commit d2d2967
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ typedef struct

bool tonies_json_auto_update;
bool full_taf_validation;
bool tap_taf_validation;
bool track_pos_taf_validation;
} settings_core_t;

typedef struct
Expand Down
7 changes: 5 additions & 2 deletions src/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,12 @@ void readTrackPositions(tonie_info_t *tonieInfo, FsFile *file)
osFreeMem(trackPos->pos);
trackPos->pos = NULL;

if (!isValidTaf(tonieInfo->contentPath, true))
if (get_settings()->core.track_pos_taf_validation)
{
TRACE_ERROR("SHA1 not valid or length different for TAF %s\r\n", tonieInfo->contentPath);
if (!isValidTaf(tonieInfo->contentPath, true))
{
TRACE_ERROR("SHA1 not valid or length different for TAF %s\r\n", tonieInfo->contentPath);
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ static void option_map_init(uint8_t settingsId)
OPTION_UNSIGNED("core.settings_level", &settings->core.settings_level, 1, 1, 3, "Settings level", "1: Basic, 2: Detail, 3: Expert", LEVEL_BASIC)
OPTION_BOOL("core.tonies_json_auto_update", &settings->core.tonies_json_auto_update, TRUE, "Auto-Update tonies.json", "Auto-Update tonies.json for Tonies information and images.", LEVEL_DETAIL)
OPTION_BOOL("core.full_taf_validation", &settings->core.full_taf_validation, FALSE, "Full TAF validation", "Validate TAFs by checking the audio length and the SHA1 hash. (may be slow, as file needs to be fully read!)", LEVEL_EXPERT)
OPTION_BOOL("core.tap_taf_validation", &settings->core.tap_taf_validation, FALSE, "TAP TAF validation", "Validate TAFs of TAPs by checking the audio length and the SHA1 hash. (may be slow, as file needs to be fully read!)", LEVEL_EXPERT)
OPTION_BOOL("core.track_pos_taf_validation", &settings->core.track_pos_taf_validation, TRUE, "Track position error TAF validation", "Validate TAFs when track position error occurs by checking the audio length and the SHA1 hash. (may be slow, as file needs to be fully read!)", LEVEL_DETAIL)

OPTION_TREE_DESC("security_mit", "Security mitigation", LEVEL_EXPERT)
OPTION_BOOL("security_mit.warnAccess", &settings->security_mit.warnAccess, TRUE, "Warning on unwanted access", "If teddyCloud detects unusal access, warn on frontend until restart. (See on*)", LEVEL_EXPERT)
Expand Down
2 changes: 1 addition & 1 deletion src/tonie_audio_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ error_t tap_load(char *filename, tonie_audio_playlist_t *tap)
cJSON_Delete(tapJson);
if (error == NO_ERROR)
{
if (isValidTaf(tap->_filepath_resolved, true))
if (isValidTaf(tap->_filepath_resolved, get_settings()->core.tap_taf_validation))
{
tap->_cached = true;
// TODO check audio id if different and check settings.
Expand Down

0 comments on commit d2d2967

Please sign in to comment.