mirror of
https://github.com/CFC-Servers/cfc_cl_http_whitelist.git
synced 2025-03-04 03:03:18 -05:00
dont proxy dropbox, google or translate
This commit is contained in:
parent
8f12ceb276
commit
d403350d01
@ -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
|
||||
|
@ -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 },
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user