Added HTTP header tracing.

Ylian Saint-Hilaire committed Jan 9, 2021 at 15:58 UTC 3249d727b8abd8902f038f5d9961b3b25ddeddf9
5 files changed +73 -39
meshcentral.js
+1 -1
@@ -2331,7 +2331,7 @@ function CreateMeshCentralServer(config, args) {
2331 20: { id: 20, localname: 'meshagent_x86-64_nokvm', rname: 'meshagent', desc: 'Linux x86-64 NoKVM', update: true, amt: true, platform: 'linux', core: 'linux-amt', rcore: 'linux-recovery', arcore: 'linux-agentrecovery' },
2332 21: { id: 21, localname: 'MeshAgent-WinMinCore-Console-x86-32.exe', rname: 'meshagent.exe', desc: 'Windows MinCore Console x86-32', update: true, amt: false, platform: 'win32', core: 'windows-amt', rcore: 'windows-recovery', arcore: 'windows-agentrecovery' },
2333 22: { id: 22, localname: 'MeshAgent-WinMinCore-Service-x86-64.exe', rname: 'meshagent.exe', desc: 'Windows MinCore Service x86-32', update: true, amt: false, platform: 'win32', core: 'windows-amt', rcore: 'windows-recovery', arcore: 'windows-agentrecovery' },
2334 - 23: { id: 23, localname: 'MeshAgent-NodeJS', rname: 'meshagent', desc: 'NodeJS', update: false, amt: false, platform: 'node', core: 'linux-noamt', rcore: 'linux-recovery', arcore: 'linux-agentrecovery' }, // Get this one from NPM
2334 + 23: { id: 23, localname: 'MeshAgent-NodeJS', rname: 'meshagent', desc: 'NodeJS', update: false, amt: false, platform: 'node', core: 'nodejs', rcore: 'nodejs', arcore: 'nodejs' }, // NodeJS based agent
2335 24: { id: 24, localname: 'meshagent_arm-linaro', rname: 'meshagent', desc: 'Linux ARM Linaro', update: true, amt: false, platform: 'linux', core: 'linux-noamt', rcore: 'linux-recovery', arcore: 'linux-agentrecovery' },
2336 25: { id: 25, localname: 'meshagent_armhf', rname: 'meshagent', desc: 'Linux ARM - HardFloat', update: true, amt: false, platform: 'linux', core: 'linux-noamt', rcore: 'linux-recovery', arcore: 'linux-agentrecovery' }, // "armv6l" and "armv7l"
2337 26: { id: 26, localname: 'meshagent_arm64', rname: 'meshagent', desc: 'Linux ARMv8-64', update: true, amt: false, platform: 'linux', core: 'linux-noamt', rcore: 'linux-recovery', arcore: 'linux-agentrecovery' }, // "aarch64"
public/styles/style.css
+5
@@ -2990,8 +2990,13 @@ a {
2990 padding: 3px;
2991 border-radius: 3px;
2992 background-color: #DDD;
2993 + cursor: pointer;
2994 }
2995
2996 + .traceEvent:hover {
2997 + background-color:#BBB;
2998 + }
2999 +
3000 .night .traceEvent {
3001 background-color: #222;
3002 }
translate/translate.json
+47 -35
@@ -2786,7 +2786,7 @@
2786 "default-mobile.handlebars->container->page_content->column_l->p3->p3info->1->p3AccountActions->p2AccountSecurity->1->0",
2787 "default.handlebars->31->1336",
2788 "default.handlebars->31->1338",
2789 - "default.handlebars->31->2226",
2789 + "default.handlebars->31->2228",
2790 "default.handlebars->31->550",
2791 "default.handlebars->31->552"
2792 ]
@@ -5705,7 +5705,7 @@
5705 "zh-chs": "您确定要{0}插件吗:{1}",
5706 "zh-cht": "你確定要{0}外掛嗎:{1}",
5707 "xloc": [
5708 - "default.handlebars->31->2235"
5708 + "default.handlebars->31->2237"
5709 ]
5710 },
5711 {
@@ -6676,7 +6676,7 @@
6676 "zh-chs": "CIRA服务器",
6677 "zh-cht": "CIRA伺服器",
6678 "xloc": [
6679 - "default.handlebars->31->2221"
6679 + "default.handlebars->31->2223"
6680 ]
6681 },
6682 {
@@ -6696,7 +6696,7 @@
6696 "zh-chs": "CIRA服务器命令",
6697 "zh-cht": "CIRA伺服器指令",
6698 "xloc": [
6699 - "default.handlebars->31->2222"
6699 + "default.handlebars->31->2224"
6700 ]
6701 },
6702 {
@@ -6921,7 +6921,7 @@
6921 "zh-chs": "呼叫错误",
6922 "zh-cht": "呼叫錯誤",
6923 "xloc": [
6924 - "default.handlebars->31->2236"
6924 + "default.handlebars->31->2238"
6925 ]
6926 },
6927 {
@@ -7624,7 +7624,7 @@
7624 "zh-cht": "檢查...",
7625 "xloc": [
7626 "default.handlebars->31->1105",
7627 - "default.handlebars->31->2230"
7627 + "default.handlebars->31->2232"
7628 ]
7629 },
7630 {
@@ -9434,7 +9434,7 @@
9434 "zh-chs": "连接转发器",
9435 "zh-cht": "連接轉發器",
9436 "xloc": [
9437 - "default.handlebars->31->2220"
9437 + "default.handlebars->31->2222"
9438 ]
9439 },
9440 {
@@ -9584,7 +9584,7 @@
9584 "zh-chs": "Cookie编码器",
9585 "zh-cht": "Cookie編碼器",
9586 "xloc": [
9587 - "default.handlebars->31->2205"
9587 + "default.handlebars->31->2206"
9588 ]
9589 },
9590 {
@@ -9991,7 +9991,7 @@
9991 "zh-chs": "核心服务器",
9992 "zh-cht": "核心伺服器",
9993 "xloc": [
9994 - "default.handlebars->31->2204"
9994 + "default.handlebars->31->2205"
9995 ]
9996 },
9997 {
@@ -14806,7 +14806,7 @@
14806 "zh-chs": "电邮/短信流量",
14807 "zh-cht": "電郵/短信流量",
14808 "xloc": [
14809 - "default.handlebars->31->2213"
14809 + "default.handlebars->31->2214"
14810 ]
14811 },
14812 {
@@ -19276,7 +19276,7 @@
19276 "fr": "Gestionnaire Intel AMT",
19277 "nl": "Intel AMT beheerder",
19278 "xloc": [
19279 - "default.handlebars->31->2219"
19279 + "default.handlebars->31->2221"
19280 ]
19281 },
19282 {
@@ -19324,7 +19324,7 @@
19324 "default.handlebars->31->1418",
19325 "default.handlebars->31->1589",
19326 "default.handlebars->31->1597",
19327 - "default.handlebars->31->2218",
19327 + "default.handlebars->31->2220",
19328 "default.handlebars->31->536",
19329 "default.handlebars->31->594",
19330 "default.handlebars->31->621"
@@ -21872,7 +21872,7 @@
21872 "zh-chs": "减",
21873 "zh-cht": "減",
21874 "xloc": [
21875 - "default.handlebars->31->2238"
21875 + "default.handlebars->31->2240"
21876 ]
21877 },
21878 {
@@ -23406,7 +23406,7 @@
23406 "zh-chs": "主服务器信息",
23407 "zh-cht": "主伺服器訊息",
23408 "xloc": [
23409 - "default.handlebars->31->2207"
23409 + "default.handlebars->31->2208"
23410 ]
23411 },
23412 {
@@ -24202,7 +24202,7 @@
24202 "zh-chs": "MeshAgent流量",
24203 "zh-cht": "MeshAgent流量",
24204 "xloc": [
24205 - "default.handlebars->31->2209"
24205 + "default.handlebars->31->2210"
24206 ]
24207 },
24208 {
@@ -24222,7 +24222,7 @@
24222 "zh-chs": "MeshAgent更新",
24223 "zh-cht": "MeshAgent更新",
24224 "xloc": [
24225 - "default.handlebars->31->2210"
24225 + "default.handlebars->31->2211"
24226 ]
24227 },
24228 {
@@ -24343,7 +24343,7 @@
24343 "zh-chs": "MeshCentral服务器同级化",
24344 "zh-cht": "MeshCentral伺服器同級化",
24345 "xloc": [
24346 - "default.handlebars->31->2208"
24346 + "default.handlebars->31->2209"
24347 ]
24348 },
24349 {
@@ -24722,7 +24722,7 @@
24722 "zh-chs": "消息调度器",
24723 "zh-cht": "電郵調度器",
24724 "xloc": [
24725 - "default.handlebars->31->2206"
24725 + "default.handlebars->31->2207"
24726 ]
24727 },
24728 {
@@ -24905,7 +24905,7 @@
24905 "zh-chs": "更多",
24906 "zh-cht": "更多",
24907 "xloc": [
24908 - "default.handlebars->31->2237"
24908 + "default.handlebars->31->2239"
24909 ]
24910 },
24911 {
@@ -29129,7 +29129,7 @@
29129 "zh-cht": "外掛指令",
29130 "xloc": [
29131 "default.handlebars->31->211",
29132 - "default.handlebars->31->2234"
29132 + "default.handlebars->31->2236"
29133 ]
29134 },
29135 {
@@ -34138,7 +34138,7 @@
34138 "zh-chs": "服务器证书",
34139 "zh-cht": "伺服器憑證",
34140 "xloc": [
34141 - "default.handlebars->31->2211"
34141 + "default.handlebars->31->2212"
34142 ]
34143 },
34144 {
@@ -34158,7 +34158,7 @@
34158 "zh-chs": "服务器数据库",
34159 "zh-cht": "伺服器數據庫",
34160 "xloc": [
34161 - "default.handlebars->31->2212"
34161 + "default.handlebars->31->2213"
34162 ]
34163 },
34164 {
@@ -34354,7 +34354,13 @@
34354 "zh-chs": "服务器跟踪",
34355 "zh-cht": "伺服器追蹤",
34356 "xloc": [
34357 - "default.handlebars->31->2223"
34357 + "default.handlebars->31->2225"
34358 + ]
34359 + },
34360 + {
34361 + "en": "Server Tracing Event",
34362 + "xloc": [
34363 + "default.handlebars->31->2204"
34364 ]
34365 },
34366 {
@@ -39741,7 +39747,7 @@
39747 "zh-cht": "在啟用兩因素身份驗證之前,無法訪問此功能。這是額外的安全性所必需的。轉到“我的帳戶”標籤,然後查看“帳戶安全性”部分。",
39748 "xloc": [
39749 "default.handlebars->31->1339",
39744 - "default.handlebars->31->2227",
39750 + "default.handlebars->31->2229",
39751 "default.handlebars->31->553"
39752 ]
39753 },
@@ -40292,7 +40298,7 @@
40298 "zh-chs": "最新",
40299 "zh-cht": "最新",
40300 "xloc": [
40295 - "default.handlebars->31->2232"
40301 + "default.handlebars->31->2234"
40302 ]
40303 },
40304 {
@@ -41752,7 +41758,7 @@
41758 "zh-chs": "版本不兼容,请先升级您的MeshCentral",
41759 "zh-cht": "版本不兼容,請先升級你的MeshCentral",
41760 "xloc": [
41755 - "default.handlebars->31->2228"
41761 + "default.handlebars->31->2230"
41762 ]
41763 },
41764 {
@@ -41854,8 +41860,8 @@
41860 "zh-chs": "查看变更日志",
41861 "zh-cht": "查看變更日誌",
41862 "xloc": [
41857 - "default.handlebars->31->2231",
41858 - "default.handlebars->31->2233"
41863 + "default.handlebars->31->2233",
41864 + "default.handlebars->31->2235"
41865 ]
41866 },
41867 {
@@ -42253,8 +42259,14 @@
42259 "zh-chs": "网络服务器",
42260 "zh-cht": "網絡伺服器",
42261 "xloc": [
42256 - "default.handlebars->31->2214",
42257 - "default.handlebars->31->2215"
42262 + "default.handlebars->31->2215",
42263 + "default.handlebars->31->2216"
42264 + ]
42265 + },
42266 + {
42267 + "en": "Web Server HTTP Headers",
42268 + "xloc": [
42269 + "default.handlebars->31->2219"
42270 ]
42271 },
42272 {
@@ -42274,7 +42286,7 @@
42286 "zh-chs": "Web服务器请求",
42287 "zh-cht": "Web伺服器請求",
42288 "xloc": [
42277 - "default.handlebars->31->2216"
42289 + "default.handlebars->31->2217"
42290 ]
42291 },
42292 {
@@ -42294,7 +42306,7 @@
42306 "zh-chs": "Web套接字中继",
42307 "zh-cht": "Web插座中繼",
42308 "xloc": [
42297 - "default.handlebars->31->2217"
42309 + "default.handlebars->31->2218"
42310 ]
42311 },
42312 {
@@ -43780,7 +43792,7 @@
43792 "zh-chs": "\\\\'",
43793 "zh-cht": "\\\\'",
43794 "xloc": [
43783 - "default.handlebars->31->2229"
43795 + "default.handlebars->31->2231"
43796 ]
43797 },
43798 {
@@ -44879,7 +44891,7 @@
44891 "zh-chs": "servertrace.csv",
44892 "zh-cht": "servertrace.csv",
44893 "xloc": [
44882 - "default.handlebars->31->2225"
44894 + "default.handlebars->31->2227"
44895 ]
44896 },
44897 {
@@ -44965,7 +44977,7 @@
44977 "zh-chs": "时间,来源,信息",
44978 "zh-cht": "時間,來源,訊息",
44979 "xloc": [
44968 - "default.handlebars->31->2224"
44980 + "default.handlebars->31->2226"
44981 ]
44982 },
44983 {
views/default.handlebars
+17 -3
@@ -13637,10 +13637,23 @@
13637 function displayServerTrace() {
13638 var x = '', max = parseInt(Q('p41limitdropdown').value);
13639 if (serverTrace.length > max) { serverTrace.splice(max); }
13640 - for (var i in serverTrace) { x += '<div class=traceEvent>' + EscapeHtml(new Date(serverTrace[i].time).toLocaleTimeString()) + ' - <b>' + EscapeHtml(serverTrace[i].source.toUpperCase()) + '</b>: ' + EscapeHtml(serverTrace[i].args.join(', ')) + '</div>' }
13640 + for (var i in serverTrace) {
13641 + var args = [];
13642 + for (var j in serverTrace[i].args) { if (typeof serverTrace[i].args[j] == 'object') { args.push(JSON.stringify(serverTrace[i].args[j])); } else { args.push(serverTrace[i].args[j]); } }
13643 + x += '<div class=traceEvent onclick=showTraceEvent(' + j + ')>' + EscapeHtml(new Date(serverTrace[i].time).toLocaleTimeString()) + ' - <b>' + EscapeHtml(serverTrace[i].source.toUpperCase()) + '</b>: ' + EscapeHtml(args.join(', ')) + '</div>';
13644 + }
13645 QH('p41events', x);
13646 }
13647
13648 + function showTraceEvent(i) {
13649 + var e = serverTrace[i], x = '';
13650 + if (xxdialogMode || (e == null)) return;
13651 + for (var i in e.args) {
13652 + if (typeof e.args[i] == 'object') { x += EscapeHtml(JSON.stringify(e.args[i])) + '<br /><br />'; } else { x += EscapeHtml(e.args[i]) + '<br /><br />'; }
13653 + }
13654 + setDialogMode(2, "Server Tracing Event", 1, null, '<div class=selecttext style=max-height:300px;overflow-y:auto>' + x + '</div>');
13655 + }
13656 +
13657 function clearServerTracing() { serverTrace = []; displayServerTrace(); }
13658
13659 function setServerTracing() {
@@ -13659,6 +13672,7 @@
13672 x += '<div><label><input type=checkbox id=p41c5 ' + ((serverTraceSources.indexOf('web') >= 0) ? 'checked' : '') + '>' + "Web Server" + '</label></div>';
13673 x += '<div><label><input type=checkbox id=p41c6 ' + ((serverTraceSources.indexOf('webrequest') >= 0) ? 'checked' : '') + '>' + "Web Server Requests" + '</label></div>';
13674 x += '<div><label><input type=checkbox id=p41c7 ' + ((serverTraceSources.indexOf('relay') >= 0) ? 'checked' : '') + '>' + "Web Socket Relay" + '</label></div>';
13675 + x += '<div><label><input type=checkbox id=p41c20 ' + ((serverTraceSources.indexOf('httpheaders') >= 0) ? 'checked' : '') + '>' + "Web Server HTTP Headers" + '</label></div>';
13676 //x += '<div><label><input type=checkbox id=p41c8 ' + ((serverTraceSources.indexOf('webrelaydata') >= 0) ? 'checked' : '') + '>' + "Traffic Relay 2 Data" + '</label></div>';
13677 x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>' + "Intel&reg; AMT" + '</b></div>';
13678 x += '<div><label><input type=checkbox id=p41c19 ' + ((serverTraceSources.indexOf('amt') >= 0) ? 'checked' : '') + '>' + "Intel AMT manager" + '</label></div>';
@@ -13673,8 +13687,8 @@
13687 }
13688
13689 function setServerTracingEx(b) {
13676 - var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert', 'db', 'email', 'amt'];
13677 - if (b == 1) { for (var i = 1; i < 20; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
13690 + var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert', 'db', 'email', 'amt', 'httpheaders'];
13691 + if (b == 1) { for (var i = 1; i < 21; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
13692 meshserver.send({ action: 'traceinfo', traceSources: sources });
13693 }
13694
webserver.js
+3
@@ -4971,6 +4971,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4971
4972 // Add HTTP security headers to all responses
4973 obj.app.use(function (req, res, next) {
4974 + // Useful for debugging reverse proxy issues
4975 + parent.debug('httpheaders', req.headers);
4976 +
4977 // Set the real IP address of the request
4978 // If a trusted reverse-proxy is sending us the remote IP address, use it.
4979 var ipex = '0.0.0.0', xforwardedhost = req.headers.host;