comparison net/server_epoll.lua @ 12481:2ee27587fec7

net: refactor sslconfig to not depend on LuaSec This now requires that the network backend exposes a tls_builder function, which essentially wraps the former util.sslconfig.new() function, passing a factory to create the eventual SSL context. That allows a net.server backend to pick whatever it likes as SSL context factory, as long as it understands the config table passed by the SSL config builder. Heck, a backend could even mock and replace the entire SSL config builder API.
author Jonas Schäfer <jonas@wielicki.name>
date Sat, 02 Apr 2022 11:15:33 +0200
parents 7e9ebdc75ce4
children b7f07585ec4c
comparison
equal deleted inserted replaced
12480:7e9ebdc75ce4 12481:2ee27587fec7
25 local inet = require "util.net"; 25 local inet = require "util.net";
26 local inet_pton = inet.pton; 26 local inet_pton = inet.pton;
27 local _SOCKETINVALID = socket._SOCKETINVALID or -1; 27 local _SOCKETINVALID = socket._SOCKETINVALID or -1;
28 local new_id = require "util.id".short; 28 local new_id = require "util.id".short;
29 local xpcall = require "util.xpcall".xpcall; 29 local xpcall = require "util.xpcall".xpcall;
30 local sslconfig = require "util.sslconfig";
31 local tls_impl = require "net.tls_luasec";
30 32
31 local poller = require "util.poll" 33 local poller = require "util.poll"
32 local EEXIST = poller.EEXIST; 34 local EEXIST = poller.EEXIST;
33 local ENOENT = poller.ENOENT; 35 local ENOENT = poller.ENOENT;
34 36
1102 link = link; 1104 link = link;
1103 set_config = function (newconfig) 1105 set_config = function (newconfig)
1104 cfg = setmetatable(newconfig, default_config); 1106 cfg = setmetatable(newconfig, default_config);
1105 end; 1107 end;
1106 1108
1109 tls_builder = function(basedir)
1110 return sslconfig._new(tls_impl.new_context, basedir)
1111 end,
1112
1107 -- libevent emulation 1113 -- libevent emulation
1108 event = { EV_READ = "r", EV_WRITE = "w", EV_READWRITE = "rw", EV_LEAVE = -1 }; 1114 event = { EV_READ = "r", EV_WRITE = "w", EV_READWRITE = "rw", EV_LEAVE = -1 };
1109 addevent = function (fd, mode, callback) 1115 addevent = function (fd, mode, callback)
1110 log("warn", "Using deprecated libevent emulation, please update code to use watchfd API instead"); 1116 log("warn", "Using deprecated libevent emulation, please update code to use watchfd API instead");
1111 local function onevent(self) 1117 local function onevent(self)