diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index 9a578ee299..f3e5cb786b 100644 --- a/doc/lua-api/index.rst +++ b/doc/lua-api/index.rst @@ -976,7 +976,7 @@ Server class server. :returns: an integer. -.. js:function:: Server.set_addr(sv, addr) +.. js:function:: Server.set_addr(sv, addr[, port]) Dynamically change the address of the server. See the management socket documentation for more information about the format of the string. diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index a9c7fe507f..e6f4d7379c 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -1034,13 +1034,18 @@ int hlua_server_set_addr(lua_State *L) { struct server *srv; const char *addr; + const char *port; const char *err; srv = hlua_check_server(L, 1); addr = luaL_checkstring(L, 2); + if (lua_gettop(L) >= 3) + port = luaL_checkstring(L, 3); + else + port = NULL; HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); - err = server_parse_addr_change_request(srv, addr, "Lua script"); + err = update_server_addr_port(srv, addr, port, "Lua script"); HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); if (!err) lua_pushnil(L);