From d24043dc1c18369dbd059ecdd083ff8af9fd2fac Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 13 Jul 2020 05:19:47 +0000 Subject: [PATCH] add info for debug api --- _webi/ua-detect.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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; -- 2.25.1