mirror of
https://github.com/CFC-Servers/cfc_cl_http_whitelist.git
synced 2025-03-04 03:03:18 -05:00
fix config loading with directorys (#52)
This commit is contained in:
parent
fad5576e8f
commit
33b31a0742
@ -4,12 +4,14 @@ local function requestNetworkedConfig()
|
||||
end
|
||||
|
||||
local function loadConfigsClient()
|
||||
CFCHTTP.LoadConfig( {
|
||||
CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.sharedConfigsDir ),
|
||||
CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.clientConfigsDir ),
|
||||
CFCHTTP.LuaTableSources( CFCHTTP.networkedConfig ),
|
||||
CFCHTTP.FileSource( CFCHTTP.filenames.defaultJsonConfig ),
|
||||
} )
|
||||
---@type (fun(): WhitelistConfig)[]
|
||||
local configSources = {}
|
||||
table.Add(configSources, CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.sharedConfigsDir ))
|
||||
table.Add(configSources, CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.clientConfigsDir ))
|
||||
table.insert(configSources, CFCHTTP.LuaTableSources( CFCHTTP.networkedConfig ) )
|
||||
table.insert(configSources, CFCHTTP.FileSource( CFCHTTP.filenames.defaultJsonConfig ))
|
||||
|
||||
CFCHTTP.LoadConfig( configSources )
|
||||
end
|
||||
|
||||
net.Receive( "CFCHTTP_ConfigUpdate", function()
|
||||
|
@ -21,11 +21,11 @@ CFCHTTP.Net.receiveWithMiddleware( "CFCHTTP_RequestConfig", function( _, ply )
|
||||
end, CFCHTTP.Net.rateLimit( "CFCHTTP_RequestConfig", 2, 10 ) )
|
||||
|
||||
local function loadConfigsServer()
|
||||
CFCHTTP.LoadConfig( {
|
||||
CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.sharedConfigsDir ),
|
||||
CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.serverConfigsDir ),
|
||||
CFCHTTP.FileSource( CFCHTTP.filenames.defaultJsonConfig ),
|
||||
} )
|
||||
local configSources = {}
|
||||
table.Add(configSources, CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.sharedConfigsDir ))
|
||||
table.Add(configSources, CFCHTTP.LuaDirectorySources( CFCHTTP.filenames.serverConfigsDir ))
|
||||
table.insert(configSources, CFCHTTP.FileSource( CFCHTTP.filenames.defaultJsonConfig ))
|
||||
CFCHTTP.LoadConfig( configSources )
|
||||
|
||||
local data = file.Read( CFCHTTP.filenames.serverClientJsonConfig, "DATA" )
|
||||
CFCHTTP.networkedClientConfig = data and util.JSONToTable( data )
|
||||
|
@ -35,8 +35,9 @@ function CFCHTTP.LuaFileSource( filename )
|
||||
end
|
||||
|
||||
---@param dir string
|
||||
---@return fun(): WhitelistConfig ...
|
||||
---@return fun(): WhitelistConfig[]
|
||||
function CFCHTTP.LuaDirectorySources( dir )
|
||||
---@type (fun(): WhitelistConfig)[]
|
||||
local funcs = {}
|
||||
local files = file.Find( dir .. "*.lua", "LUA" )
|
||||
|
||||
@ -44,7 +45,7 @@ function CFCHTTP.LuaDirectorySources( dir )
|
||||
table.insert( funcs, CFCHTTP.LuaFileSource( dir .. fil ) )
|
||||
end
|
||||
|
||||
return unpack( funcs )
|
||||
return funcs
|
||||
end
|
||||
|
||||
---@param tbl WhitelistConfig
|
||||
|
Loading…
Reference in New Issue
Block a user