server_host = "billing.local" server_port = 80 function send_session_info(content) http_request({ host = server_host, port = server_port, method = "POST", path = "/stat/", headers = { "User-Agent: Astra", "Host: " .. server_host, "Content-Type: application/json", "Content-Length: " .. #content, "Connection: close", }, content = content, callback = function(self, response) if response.code ~= 200 then log.error("[xProxy] failed to send stat") end end, }) end function auth_request(client_id, request, auth_callback) if not request then send_session_info(json.encode({ session = client_id, status = "stop", })) return end local client_address = request.headers['x-real-ip'] if not client_address then client_address = request.addr end send_session_info(json.encode({ session = client_id, status = "start", channel = request.path, client = client_address, })) http_request({ host = server_host, port = server_port, path = "/auth" .. request.path, headers = { "User-Agent: Astra", "Host: " .. server_host, "X-Real-IP: " .. client_address, "Connection: close", }, callback = function(self, response) if response.code == 200 then auth_callback(true) else auth_callback("http://streamer.local:8000/404") end end, }) end