mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 09:50:28 +00:00
Add redbean Lua IsLoopbackClient function
This commit is contained in:
parent
d60e855870
commit
8c535a0198
2 changed files with 11 additions and 0 deletions
|
@ -761,6 +761,10 @@ FUNCTIONS
|
|||
Returns true if IP address is part of a private network
|
||||
(10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).
|
||||
|
||||
IsLoopbackClient() → bool
|
||||
Returns true if the client IP address (returned by GetRemoteAddr)
|
||||
is part of the localhost network (127.0.0.0/8).
|
||||
|
||||
IsLoopbackIp(uint32) → bool
|
||||
Returns true if IP address is part of the localhost network
|
||||
(127.0.0.0/8).
|
||||
|
|
|
@ -3980,6 +3980,12 @@ static int LuaIsLoopbackIp(lua_State *L) {
|
|||
return LuaIsIp(L, IsLoopbackIp);
|
||||
}
|
||||
|
||||
static int LuaIsLoopbackClient(lua_State *L) {
|
||||
OnlyCallDuringRequest(L, "IsLoopbackClient");
|
||||
lua_pushboolean(L, IsLoopbackClient());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LuaCategorizeIp(lua_State *L) {
|
||||
lua_pushstring(L, GetIpCategoryName(CategorizeIp(luaL_checkinteger(L, 1))));
|
||||
return 1;
|
||||
|
@ -5369,6 +5375,7 @@ static const luaL_Reg kLuaFuncs[] = {
|
|||
{"IsCompressed", LuaIsCompressed}, //
|
||||
{"IsDaemon", LuaIsDaemon}, //
|
||||
{"IsHiddenPath", LuaIsHiddenPath}, //
|
||||
{"IsLoopbackClient", LuaIsLoopbackClient}, //
|
||||
{"IsLoopbackIp", LuaIsLoopbackIp}, //
|
||||
{"IsPrivateIp", LuaIsPrivateIp}, //
|
||||
{"IsPublicIp", LuaIsPublicIp}, //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue