mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-27 09:10:21 +01:00
Use LuaSocket's base 64 encoding function
This commit is contained in:
parent
26ca287b09
commit
8e6a9a287f
@ -1,6 +1,8 @@
|
|||||||
-- This file is licensed under the terms of the BSD 2-clause license.
|
-- This file is licensed under the terms of the BSD 2-clause license.
|
||||||
-- See LICENSE.txt for details.
|
-- See LICENSE.txt for details.
|
||||||
|
|
||||||
|
-- MIME is part of LuaSocket
|
||||||
|
local b64e = require("mime").b64
|
||||||
|
|
||||||
irc.hooks = {}
|
irc.hooks = {}
|
||||||
irc.registered_hooks = {}
|
irc.registered_hooks = {}
|
||||||
@ -213,7 +215,7 @@ end
|
|||||||
|
|
||||||
function irc.hooks.preregister(conn)
|
function irc.hooks.preregister(conn)
|
||||||
if not (irc.config["sasl.user"] and irc.config["sasl.pass"]) then return end
|
if not (irc.config["sasl.user"] and irc.config["sasl.pass"]) then return end
|
||||||
local authString = irc.b64e(
|
local authString = b64e(
|
||||||
("%s\x00%s\x00%s"):format(
|
("%s\x00%s\x00%s"):format(
|
||||||
irc.config["sasl.user"],
|
irc.config["sasl.user"],
|
||||||
irc.config["sasl.user"],
|
irc.config["sasl.user"],
|
||||||
|
1
init.lua
1
init.lua
@ -30,7 +30,6 @@ dofile(modpath.."/hooks.lua")
|
|||||||
dofile(modpath.."/callback.lua")
|
dofile(modpath.."/callback.lua")
|
||||||
dofile(modpath.."/chatcmds.lua")
|
dofile(modpath.."/chatcmds.lua")
|
||||||
dofile(modpath.."/botcmds.lua")
|
dofile(modpath.."/botcmds.lua")
|
||||||
dofile(modpath.."/util.lua")
|
|
||||||
if irc.config.enable_player_part then
|
if irc.config.enable_player_part then
|
||||||
dofile(modpath.."/player_part.lua")
|
dofile(modpath.."/player_part.lua")
|
||||||
else
|
else
|
||||||
|
20
util.lua
20
util.lua
@ -1,20 +0,0 @@
|
|||||||
--Base 64 encode -- for SASL authentication
|
|
||||||
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
||||||
function irc.b64e(data)
|
|
||||||
return ((data:gsub('.', function(x)
|
|
||||||
local r,b='',x:byte()
|
|
||||||
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
|
|
||||||
return r;
|
|
||||||
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
|
|
||||||
if (#x < 6) then return '' end
|
|
||||||
local c=0
|
|
||||||
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
|
|
||||||
return b:sub(c+1,c+1)
|
|
||||||
end)..({ '', '==', '=' })[#data%3+1])
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Requested by Exio
|
|
||||||
string.expandvars = function(s, vars)
|
|
||||||
return s:gsub("%$%(([^)]+)%)", vars)
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user