LiquidProxy Lua Edition
at master 53 lines 1.2 kB view raw
1_G.LuaRequire = _G.require 2_G.require = require 3 4require "string-extensions" 5require "util" 6 7local fs = require "fs" 8 9---@type config 10_G.Config = require "default_cfg" 11if fs.existsSync "cfg.lua" then 12 if not pcall(function() require "cfg" end) then 13 print "cfg.lua failed to load" 14 os.exit(1) 15 end 16 ---@type config 17 Config = table.patch(Config, require "cfg") 18end 19 20_G.l = require "logger" (Config.log_level) 21 22local stack = {} 23_G.LogStarted = function(name, type, port) 24 if not stack[name] then stack[name] = {} end 25 table.insert(stack[name], {port = port, type = type}) 26end 27 28require "app.cert" 29require "app.tls" 30require "app.fail2ban" 31 32if Config.mod.http.enabled then 33 require "app.http.main" 34end 35 36if Config.mod.directTCP.enabled then 37 require "app.directTCP.main" 38end 39 40if not next(stack) then 41 print "Nothing to do! Did you disable all plugins?" 42end 43 44for name, tbl in pairs(stack) do 45 local t = name.." proxy started (" 46 for i, tbl2 in pairs(tbl) do 47 if i ~= 1 then 48 t = t .. ", " 49 end 50 t = t .. tbl2.type .. ": " .. tostring(tbl2.port) 51 end 52 l:info(t..")") 53end