-
Notifications
You must be signed in to change notification settings - Fork 852
Lua plugin support for connection exempt list #12849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4c1d0e9
1470339
1dab75e
4654fb7
ed81e30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,9 @@ static int ts_lua_get_config_dir(lua_State *L); | |
| static int ts_lua_get_runtime_dir(lua_State *L); | ||
| static int ts_lua_get_plugin_dir(lua_State *L); | ||
| static int ts_lua_get_traffic_server_version(lua_State *L); | ||
| static int ts_lua_connection_limit_exempt_list_add(lua_State *L); | ||
| static int ts_lua_connection_limit_exempt_list_remove(lua_State *L); | ||
| static int ts_lua_connection_limit_exempt_list_clear(lua_State *L); | ||
|
|
||
| static int ts_lua_sleep_cleanup(ts_lua_async_item *ai); | ||
| static int ts_lua_sleep_handler(TSCont contp, TSEvent event, void *edata); | ||
|
|
@@ -136,6 +139,18 @@ ts_lua_inject_misc_api(lua_State *L) | |
| lua_pushcfunction(L, ts_lua_get_traffic_server_version); | ||
| lua_setfield(L, -2, "get_traffic_server_version"); | ||
|
|
||
| /* ts.connection_limit_exempt_list_add(...) */ | ||
| lua_pushcfunction(L, ts_lua_connection_limit_exempt_list_add); | ||
| lua_setfield(L, -2, "connection_limit_exempt_list_add"); | ||
|
|
||
| /* ts.connection_limit_exempt_list_remove(...) */ | ||
| lua_pushcfunction(L, ts_lua_connection_limit_exempt_list_remove); | ||
| lua_setfield(L, -2, "connection_limit_exempt_list_remove"); | ||
|
|
||
| /* ts.connection_limit_exempt_list_clear(...) */ | ||
| lua_pushcfunction(L, ts_lua_connection_limit_exempt_list_clear); | ||
| lua_setfield(L, -2, "connection_limit_exempt_list_clear"); | ||
|
|
||
| ts_lua_inject_misc_variables(L); | ||
| } | ||
|
|
||
|
|
@@ -631,3 +646,54 @@ ts_lua_get_traffic_server_version(lua_State *L) | |
| lua_pushstring(L, s); | ||
| return 1; | ||
| } | ||
|
|
||
| static int | ||
| ts_lua_connection_limit_exempt_list_add(lua_State *L) | ||
| { | ||
| size_t len; | ||
| const char *ip_ranges; | ||
|
|
||
| ip_ranges = luaL_checklstring(L, 1, &len); | ||
|
Comment on lines
+651
to
+656
|
||
|
|
||
| if (ip_ranges && len > 0) { | ||
| TSReturnCode ret = TSConnectionLimitExemptListAdd(std::string_view(ip_ranges, len)); | ||
shukitchan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (ret == TS_SUCCESS) { | ||
| lua_pushboolean(L, 1); | ||
| } else { | ||
| lua_pushboolean(L, 0); | ||
| } | ||
| } else { | ||
| lua_pushboolean(L, 0); | ||
| } | ||
shukitchan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| static int | ||
| ts_lua_connection_limit_exempt_list_remove(lua_State *L) | ||
| { | ||
| size_t len; | ||
| const char *ip_ranges; | ||
|
|
||
| ip_ranges = luaL_checklstring(L, 1, &len); | ||
|
|
||
| if (ip_ranges && len > 0) { | ||
| TSReturnCode ret = TSConnectionLimitExemptListRemove(std::string_view(ip_ranges, len)); | ||
| if (ret == TS_SUCCESS) { | ||
| lua_pushboolean(L, 1); | ||
| } else { | ||
| lua_pushboolean(L, 0); | ||
| } | ||
| } else { | ||
| lua_pushboolean(L, 0); | ||
| } | ||
shukitchan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| static int | ||
| ts_lua_connection_limit_exempt_list_clear(lua_State * /* L ATS_UNUSED */) | ||
| { | ||
| TSConnectionLimitExemptListClear(); | ||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.