From d403350d017e138c4d983a885354046259ce1f93 Mon Sep 17 00:00:00 2001 From: pierce Date: Fri, 14 Feb 2025 22:58:35 -0500 Subject: [PATCH] dont proxy dropbox, google or translate --- .../configs/starfallex.lua | 23 +++---------------- lua/cfc_http_restrictions/default_config.lua | 20 ++++++++-------- lua/cfc_http_restrictions/wraps/http.lua | 3 --- lua/cfc_http_restrictions/wraps/playURL.lua | 12 +++++++--- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/lua/cfc_http_restrictions/configs/starfallex.lua b/lua/cfc_http_restrictions/configs/starfallex.lua index 88279c5..feafbb1 100644 --- a/lua/cfc_http_restrictions/configs/starfallex.lua +++ b/lua/cfc_http_restrictions/configs/starfallex.lua @@ -10,27 +10,10 @@ local config = { } } + if CLIENT then - local P = {} - P.id = "urlwhitelist" - P.name = "URL Whitelist" - P.settingsoptions = { "Enabled", "Disabled" } - P.defaultsetting = 1 - P.checks = { - function() return true end, - "allow", - } - - P.settingsoptions[3] = "Disabled for owner" - P.checks[3] = function() return true end - - hook.Add( "PostGamemodeLoaded", "CFCHTTP_Wrap_SF", function() - local original = SF.Permissions.includePermissions - SF.Permissions.includePermissions = function() - original() - SF.Permissions.registerProvider( P ) - end + hook.Add( "CanAccessUrl", "StarfallEx", function( url ) + return true end ) end - return config diff --git a/lua/cfc_http_restrictions/default_config.lua b/lua/cfc_http_restrictions/default_config.lua index e0f8e55..a87bf3d 100644 --- a/lua/cfc_http_restrictions/default_config.lua +++ b/lua/cfc_http_restrictions/default_config.lua @@ -1,6 +1,8 @@ AddCSLuaFile() ----@alias WhitelistAddressOption { allowed: boolean|nil, noisy: boolean|nil, permanent: boolean|nil, pattern: boolean|nil, _edited: boolean|nil } + + +---@alias WhitelistAddressOption { allowed: boolean|nil, noisy: boolean|nil, permanent: boolean|nil, pattern: boolean|nil, _edited: boolean|nil, proxy: boolean|nil } ---@class WhitelistConfig ---@field version string @@ -16,9 +18,7 @@ local config = { defaultAssetURIOptions = { allowed = true, }, - defaultOptions = { - allowed = false, - }, + defaultOptions = {}, addresses = { -- this is used internally by this addon, removing it could cause issues @@ -43,17 +43,17 @@ local config = { ["github.com"] = { allowed = true }, -- dropbox - ["dl.dropboxusercontent.com"] = { allowed = true }, - ["dl.dropbox.com"] = { allowed = true }, - ["www.dropbox.com"] = { allowed = true }, + ["dl.dropboxusercontent.com"] = { allowed = true, proxy = false }, + ["dl.dropbox.com"] = { allowed = true, proxy = false }, + ["www.dropbox.com"] = { allowed = true, proxy = false }, -- onedrive ["onedrive.live.com"] = { allowed = true }, ["api.onedrive.com"] = { allowed = true }, -- google drive - ["docs.google.com"] = { allowed = true }, - ["drive.google.com"] = { allowed = true }, + ["docs.google.com"] = { allowed = true, proxy = false }, + ["drive.google.com"] = { allowed = true, proxy = false }, ["*.googleusercontent.com"] = { allowed = true }, -- youtube @@ -86,7 +86,7 @@ local config = { ["i.redd.it"] = { allowed = true }, ["api.wolframalpha.com"] = { allowed = true }, ["text-to-speech-demo.ng.bluemix.net"] = { allowed = true }, - ["translate.google.com"] = { allowed = true }, + ["translate.google.com"] = { allowed = true, proxy = false }, ["cdn[%w-_]*.discordapp%.com"] = { allowed = true, pattern = true }, ["images-([%w%-]+)%.discordapp%.net"] = { allowed = true, pattern = true }, diff --git a/lua/cfc_http_restrictions/wraps/http.lua b/lua/cfc_http_restrictions/wraps/http.lua index 522177e..c7ca284 100644 --- a/lua/cfc_http_restrictions/wraps/http.lua +++ b/lua/cfc_http_restrictions/wraps/http.lua @@ -17,15 +17,12 @@ local function wrapHTTP() HTTP = function( req ) local options = CFCHTTP.GetOptionsForURL( req.url ) local isAllowed = options and options.allowed - local allowedThroughProxy = options and options.allowedProxy local noisy = options and options.noisy local stack = string.Split( debug.traceback(), "\n" ) local status = isAllowed and "allowed" or "blocked" - -- TODO should we allow proxied http requests - CFCHTTP.LogRequest( { noisy = noisy, method = req.method, diff --git a/lua/cfc_http_restrictions/wraps/playURL.lua b/lua/cfc_http_restrictions/wraps/playURL.lua index b186388..d5a916f 100644 --- a/lua/cfc_http_restrictions/wraps/playURL.lua +++ b/lua/cfc_http_restrictions/wraps/playURL.lua @@ -15,7 +15,13 @@ local function wrapPlayURL() local stack = string.Split( debug.traceback(), "\n" ) local options = CFCHTTP.GetOptionsForURL( url ) - local isAllowed = options and options.allowed + + local isAllowed = options and options.allowed == true + local isBlocked = options and options.allowed == false + + -- if proxy is nil always default to proxying + local shouldProxy = options and options.proxy ~= false + local noisy = options and options.noisy local status = isAllowed and "allowed" or "blocked" @@ -26,9 +32,9 @@ local function wrapPlayURL() urls = { { url = url, status = status } } } - local canProxy = CFCHTTP.Proxy:IsHealthy() + local canProxy = CFCHTTP.Proxy:IsHealthy() and shouldProxy - if not isAllowed and not canProxy then + if isBlocked or (not isAllowed and not canProxy) then CFCHTTP.LogRequest( logData ) if callback then callback( nil, CFCHTTP.BASS_ERROR_BLOCKED_URI, "BASS_ERROR_BLOCKED_URI" ) end return