CFC-Servers/cfc_cl_http_whitelist

Please change the error code on blocked sound.PlayURL() requests to a custom one

Closed this issue · 1 comments

Grocel commented

The Problem

Currently it is set to error 20 and BASS_ERROR_ILLPARAM, which is somewhat inaccurate. Error 20 is reserved for broken, malformed, impossible URL strings, but not for blocked URLs that are valid otherwise.

My request

Please change it to a custom error code, so it no longer conflicts with "official" error codes.

The Background

This causes confusing-to-user behaviors in some addons that use the sound.PlayURL() function. My 3D Stream Radio addon is also affected. I received strange reports about the radio always returning BASS_ERROR_ILLPARAM, even for known-good and stock URLs/playlists. I didn't knew where this came from, so I thought players had a broken install etc. Now the mystery is solved: The URLs had been blocked by this addon.

Solution

I would like to add a separate error handler for blocked URLs to my addon, so I can explain the issue in-game and redirect the user to a more user friendly resolution. For that I need that custom error case. I think other developers would like to have that option too.

I recommend the error code 200 with BASS_ERROR_URLBLOCKED or BASS_ERROR_CFC_URLBLOCKED as its name or something.

plally commented

I added the following error codes in that PR

-- the url was blocked
BASS_ERROR_BLOCKED_URI = 11001
-- the request was blocked after inspecting the content
BASS_ERROR_BLOCKED_CONTENT = 11002

the second code is not currently used but will be used in an upcoming feature.