From: AJ ONeal Date: Mon, 13 Jul 2020 05:19:47 +0000 (+0000) Subject: add info for debug api X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=d24043dc1c18369dbd059ecdd083ff8af9fd2fac;p=webi-installers%2F.git add info for debug api --- diff --git a/_webi/ua-detect.js b/_webi/ua-detect.js index 89c18c8..c0483cb 100644 --- a/_webi/ua-detect.js +++ b/_webi/ua-detect.js @@ -1,5 +1,27 @@ 'use strict'; +function getRequest(req) { + var ua = req.headers['user-agent'] || ''; + var os = req.query.os; + var arch = req.query.arch; + var scheme = req.socket.encrypted ? 'https' : 'http'; + var host = req.headers.host || 'beta.webinstall.dev'; + var url = scheme + '://' + host + '/api/debug'; + if (os && arch) { + ua = os + ' ' + arch; + } else if (os || arch) { + ua = os || arch; + } + + return { + unix: 'curl -fsSA "$(uname -a)" ' + url, + windows: 'curl.exe -fsSA "MS $Env:PROCESSOR_ARCHITECTURE" ' + url, + ua: ua, + os: uaDetect.os(ua), + arch: uaDetect.arch(ua) + }; +} + function getOs(ua) { if ('-' === ua) { return '-'; @@ -56,5 +78,7 @@ function getArch(ua) { } } -module.exports.os = getOs; -module.exports.arch = getArch; +var uaDetect = module.exports; +uaDetect.os = getOs; +uaDetect.arch = getArch; +uaDetect.request = getRequest;