end
hook_setfold("sendtochannel", fold_sendtox)
hook_setfold("sendtoclient", fold_sendtox)
+hook_setfold("newuser", fold_sendtox)
function commands.echo(client, source, command, args)
client_notice(client, "client = "..tostring(client))
client_notice(client, "new spam protection level: "..tostring(spamlevel))
end
end
+
+dofile "lua/irccloud.lua"
--- /dev/null
+-- irccloud authentication support
+local function parseipv6(s)
+ if not s:match("^[0-9a-fA-F:]*") then
+ return nil
+ end
+ local part1 = {}
+ local part2 = {}
+ local part = part1
+ local i = 1
+ repeat
+ local j = s:find(":", i, true) or 0
+ local sub = s:sub(i, j-1)
+ if sub == "" then
+ part = part2
+ else
+ part[#part + 1] = sub
+ end
+ i = j + 1
+ until i == 1
+ local c = {}
+ for i = 1, 8 do
+ if i <= #part1 then
+ c[i] = tonumber(part1[i], 16)
+ elseif i + #part2 - 8 >= 1 then
+ c[i] = tonumber(part2[i + #part2 - 8], 16)
+ else
+ c[i] = 0
+ end
+ end
+ local netid = c[1]<<48 | c[2]<<32 | c[3]<<16 | c[4]
+ local ifaceid = c[5]<<48 | c[6]<<32 | c[7]<<16 | c[8]
+ return netid, ifaceid
+end
+
+local function isirccloudnetwork(netid)
+ -- https://www.irccloud.com/networks
+ -- 2a03:5180:f::/62, 2a03:5180:f:4::/63, 2a03:5180:f:6::/64
+ 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)
+ print(netid, ifaceid)
+ if netid and isirccloudnetwork(netid) and uidmap[ifaceid] then
+ client_chghost(cl1, uidmap[ifaceid], cl1.hostname)
+ end
+end)
sendLUSERS(client);
rpl_umodeis(client), sendbuf(client);
sendMOTD(client);
+#ifdef HAS_LUA
+ admin_hook("newuser", client, 0, 0, 0);
+#endif
// send CTCP VERSION and CTCP TIME
msg_privmsg_server("cia!cia@cia.gov", client->nick, "\1VERSION\1"), sendbuf(client);
msg_privmsg_server("cia!cia@cia.gov", client->nick, "\1TIME\1"), sendbuf(client);