mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-26 12:58:03 +00:00
MINOR: lua: Add support for userlist as fetches and converters arguments
It means now http_auth() and http_auth_group() sample fetches are now exported to the lua.
This commit is contained in:
parent
05e2d77441
commit
d25d926806
@ -39,6 +39,7 @@
|
|||||||
#include <haproxy/server-t.h>
|
#include <haproxy/server-t.h>
|
||||||
#include <haproxy/tcpcheck-t.h>
|
#include <haproxy/tcpcheck-t.h>
|
||||||
#include <haproxy/thread-t.h>
|
#include <haproxy/thread-t.h>
|
||||||
|
#include <haproxy/uri_auth-t.h>
|
||||||
|
|
||||||
/* values for proxy->state */
|
/* values for proxy->state */
|
||||||
enum pr_state {
|
enum pr_state {
|
||||||
|
26
src/hlua.c
26
src/hlua.c
@ -26,6 +26,7 @@
|
|||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
#include <haproxy/applet.h>
|
#include <haproxy/applet.h>
|
||||||
#include <haproxy/arg.h>
|
#include <haproxy/arg.h>
|
||||||
|
#include <haproxy/auth.h>
|
||||||
#include <haproxy/cfgparse.h>
|
#include <haproxy/cfgparse.h>
|
||||||
#include <haproxy/channel.h>
|
#include <haproxy/channel.h>
|
||||||
#include <haproxy/cli.h>
|
#include <haproxy/cli.h>
|
||||||
@ -593,6 +594,7 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
|||||||
int min_arg;
|
int min_arg;
|
||||||
int i, idx;
|
int i, idx;
|
||||||
struct proxy *px;
|
struct proxy *px;
|
||||||
|
struct userlist *ul;
|
||||||
const char *msg = NULL;
|
const char *msg = NULL;
|
||||||
char *sname, *pname;
|
char *sname, *pname;
|
||||||
|
|
||||||
@ -821,11 +823,23 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
|||||||
argp[idx].type = ARGT_MSK6;
|
argp[idx].type = ARGT_MSK6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARGT_MAP:
|
|
||||||
case ARGT_REG:
|
|
||||||
case ARGT_USR:
|
case ARGT_USR:
|
||||||
msg = "type not yet supported";
|
if (argp[idx].type != ARGT_STR) {
|
||||||
|
msg = "string expected";
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
if (p->uri_auth && p->uri_auth->userlist &&
|
||||||
|
!strcmp(p->uri_auth->userlist->name, argp[idx].data.str.area))
|
||||||
|
ul = p->uri_auth->userlist;
|
||||||
|
else
|
||||||
|
ul = auth_find_userlist(argp[idx].data.str.area);
|
||||||
|
|
||||||
|
if (!ul) {
|
||||||
|
msg = lua_pushfstring(L, "unable to find userlist '%s'", argp[idx].data.str.area);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
argp[idx].type = ARGT_USR;
|
||||||
|
argp[idx].data.usr = ul;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARGT_STR:
|
case ARGT_STR:
|
||||||
@ -836,6 +850,12 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
|||||||
argp[idx].data.str = tmp;
|
argp[idx].data.str = tmp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ARGT_MAP:
|
||||||
|
case ARGT_REG:
|
||||||
|
msg = "type not yet supported";
|
||||||
|
goto error;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for type of argument. */
|
/* Check for type of argument. */
|
||||||
|
Loading…
Reference in New Issue
Block a user