return netid >= 0x2a035180000f0000 and netid <= 0x2a035180000f0006
end
-local uidmap = {
- [635723] = "samson",
-}
-
hook_add("newuser", "irccloud_auth", function(hook, cl1, cl2, chan, txt)
local netid, ifaceid = parseipv6(cl1.peername)
- if netid and isirccloudnetwork(netid) and uidmap[ifaceid] then
- client_chghost(cl1, uidmap[ifaceid], cl1.hostname)
+ if netid and isirccloudnetwork(netid) then
+ client_chghost(cl1, db_read_rhs(tostring(ifaceid), "irccloud.txt"))
end
end)
#include "admin.h"
#include "irc.h"
#include "ircfmt.h"
+#include "passwd.h"
#include <lauxlib.h>
#include <lualib.h>
static lua_State *GL = 0;
static int fn_client_chghost(lua_State *L)
{
struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client");
- const char *newusername = luaL_checkstring(L, 2);
- const char *newhostname = luaL_checkstring(L, 3);
+ const char *newusername = luaL_optstring(L, 2, 0);
+ const char *newhostname = luaL_optstring(L, 3, 0);
client_chghost(cl, newusername, newhostname);
return 0;
}
rpl_whoisspecial(cl1, cl2, "", text), sendbuf(cl1);
return 0;
}
+static int fn_db_read_rhs(lua_State *L) {
+ const char *key = luaL_checkstring(L, 1);
+ const char *fn = luaL_checkstring(L, 2);
+ const char *res = db_read_rhs(key, getdatafile(fn));
+ lua_pushstring(L, res);
+ return 1;
+}
void admin_init(void)
{
lua_setglobal(L, "client_chghost");
lua_pushcfunction(L, fn_rpl_whoisspecial);
lua_setglobal(L, "rpl_whoisspecial");
+ lua_pushcfunction(L, fn_db_read_rhs);
+ lua_setglobal(L, "db_read_rhs");
}
void admin_fini(void)
{