Slon/Modules/Api: Update whitelist_ip to specify multiple values
The whitelist_ip setting will now match on any value encapsulated by single quotes, regardless of delimiter.
This commit is contained in:
parent
329c7fabf7
commit
3468d97da9
1 changed files with 4 additions and 5 deletions
|
@ -19,12 +19,11 @@ class SlonCatboxUpload {
|
||||||
|
|
||||||
Bool @slon_api_authorized(SlonHttpSession* session)
|
Bool @slon_api_authorized(SlonHttpSession* session)
|
||||||
{
|
{
|
||||||
|
U8 scratch_buffer[256];
|
||||||
U8* whitelist_ip = db->o("settings")->@("whitelist_ip");
|
U8* whitelist_ip = db->o("settings")->@("whitelist_ip");
|
||||||
if (!whitelist_ip) {
|
if (whitelist_ip) {
|
||||||
return FALSE;
|
StrPrint(scratch_buffer, "'%s'", session->header("x-forwarded-for"));
|
||||||
}
|
return session->auth > 0 && StrFind(scratch_buffer, whitelist_ip);
|
||||||
if (StrICmp(session->header("x-forwarded-for"), whitelist_ip)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
return session->auth > 0;
|
return session->auth > 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue