You can now change HTTP and HTTPS ports, #4172

Ylian Saint-Hilaire committed Jun 30, 2022 at 19:55 UTC 70e158afbdc85614293599c95de864949fca390f
2 files changed +56 -4
meshuser.js
+16
@@ -3026,6 +3026,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3026 }
3027 }
3028
3029 + if ((typeof command.httpport == 'number') && (command.httpport > 0) && (command.httpport < 65536)) {
3030 + if ((command.httpport == 80) && (node.httpport != null)) {
3031 + delete node.httpport; change = 1; changes.push('httpport'); // Delete the HTTP port
3032 + } else {
3033 + node.httpport = command.httpport; change = 1; changes.push('httpport'); // Set the HTTP port
3034 + }
3035 + }
3036 +
3037 + if ((typeof command.httpsport == 'number') && (command.httpsport > 0) && (command.httpsport < 65536)) {
3038 + if ((command.httpsport == 443) && (node.httpsport != null)) {
3039 + delete node.httpsport; change = 1; changes.push('httpsport'); // Delete the HTTPS port
3040 + } else {
3041 + node.httpsport = command.httpsport; change = 1; changes.push('httpsport'); // Set the HTTPS port
3042 + }
3043 + }
3044 +
3045 if ((typeof command.ssh == 'number') && (command.ssh == 0)) {
3046 if ((node.ssh != null) && (node.ssh[user._id] != null)) { delete node.ssh[user._id]; change = 1; changes.push('ssh'); } // Delete the SSH cendentials
3047 }
views/default.handlebars
+40 -4
@@ -112,6 +112,12 @@
112 <div id="rfbPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
113 <div class="cmtext" onclick="cmrfbportaction(1,event)">Alternate Port</div>
114 </div>
115 + <div id="httpPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
116 + <div class="cmtext" onclick="cmhttpportaction(1,event)">Alternate Port</div>
117 + </div>
118 + <div id="httpsPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
119 + <div class="cmtext" onclick="cmhttpsportaction(1,event)">Alternate Port</div>
120 + </div>
121 <div id="filesContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
122 <div class="cmtext" onclick="cmfilesaction(1,event)">Rename</div>
123 <div class="cmtext" onclick="cmfilesaction(2,event)">Edit</div>
@@ -3240,6 +3246,8 @@
3246 node.rdpport = message.event.node.rdpport;
3247 node.rfbport = message.event.node.rfbport;
3248 node.sshport = message.event.node.sshport;
3249 + node.httpport = message.event.node.httpport;
3250 + node.httpsport = message.event.node.httpsport;
3251 node.consent = message.event.node.consent;
3252 node.pmt = message.event.node.pmt;
3253 if (message.event.node.links != null) { node.links = message.event.node.links; } else { delete node.links; }
@@ -4575,8 +4583,8 @@
4583 // RDP link, show this link only of the remote machine is Windows.
4584 if ((((node.conn & 1) != 0) || (node.mtype == 3)) && (node.agent) && ((meshrights & 8) != 0) && (node.agent.id != 14)) {
4585 if (webRelayPort != 0) {
4578 - x += '<a href=# onclick=p10WebRouter("' + node._id + '",1,80)>' + "HTTP" + '</a>&nbsp;';
4579 - x += '<a href=# onclick=p10WebRouter("' + node._id + '",2,443)>' + "HTTPS" + '</a>&nbsp;';
4586 + x += '<a href=# onclick=p10WebRouter("' + node._id + '",1,' + (node.httpport ? node.httpport : 80) + ')>' + "HTTP" + '</a>&nbsp;';
4587 + x += '<a href=# onclick=p10WebRouter("' + node._id + '",2,' + (node.httpsport ? node.httpsport : 443) + ')>' + "HTTPS" + '</a>&nbsp;';
4588 }
4589 if ((node.agent.id > 0) && (node.agent.id < 5)) {
4590 if (navigator.platform.toLowerCase() == 'win32') {
@@ -6066,6 +6074,32 @@
6074 if (currentNode.rfbport != null) { Q('d10rfbport').value = currentNode.rfbport; }
6075 }
6076
6077 + function cmhttpportaction(action) {
6078 + if (xxdialogMode) return;
6079 + var x = "HTTP remote connection port:" + '<br /><br /><input type=text placeholder="80" inputmode="numeric" pattern="[0-9]*" onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" maxlength=5 id=d10httpport type=text>';
6080 + setDialogMode(2, "HTTP Connection", 3, function() {
6081 + // Save the new HTTP port to the server
6082 + var httpport = ((Q('d10httpport').value.length > 0) ? parseInt(Q('d10httpport').value) : 80);
6083 + meshserver.send({ action: 'changedevice', nodeid: currentNode._id, httpport: httpport });
6084 + //if (currentNode != null) { p10rfb(currentNode._id, httpport); }
6085 + }, x, currentNode);
6086 + Q('d10httpport').focus();
6087 + if (currentNode.httpport != null) { Q('d10httpport').value = currentNode.httpport; }
6088 + }
6089 +
6090 + function cmhttpsportaction(action) {
6091 + if (xxdialogMode) return;
6092 + var x = "HTTPS remote connection port:" + '<br /><br /><input type=text placeholder="443" inputmode="numeric" pattern="[0-9]*" onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" maxlength=5 id=d10httpsport type=text>';
6093 + setDialogMode(2, "HTTPS Connection", 3, function() {
6094 + // Save the new HTTP port to the server
6095 + var httpsport = ((Q('d10httpsport').value.length > 0) ? parseInt(Q('d10httpsport').value) : 443);
6096 + meshserver.send({ action: 'changedevice', nodeid: currentNode._id, httpsport: httpsport });
6097 + //if (currentNode != null) { p10rfb(currentNode._id, httpsport); }
6098 + }, x, currentNode);
6099 + Q('d10httpsport').focus();
6100 + if (currentNode.httpsport != null) { Q('d10httpsport').value = currentNode.httpsport; }
6101 + }
6102 +
6103 function cmfilesaction(action) {
6104 if (xxdialogMode) return;
6105 var filetreexx = p13sort_files(p13filetree.dir);
@@ -6155,6 +6189,8 @@
6189 QV('altPortContextMenu', false);
6190 QV('rfbPortContextMenu', false);
6191 QV('sshPortContextMenu', false);
6192 + QV('httpPortContextMenu', false);
6193 + QV('httpsPortContextMenu', false);
6194 QV('filesContextMenu', false);
6195 QV('deskPlayerContextMenu', false);
6196 QV('deskKeyShortcutContextMenu', false);
@@ -7147,8 +7183,8 @@
7183 // RDP link, show this link only of the remote machine is Windows.
7184 if ((((connectivity & 1) != 0) || (node.mtype == 3)) && (node.agent) && ((meshrights & 8) != 0)) {
7185 if (webRelayPort != 0) {
7150 - x += '<a href=# onclick=p10WebRouter("' + node._id + '",1,80)>' + "HTTP" + '</a>&nbsp;';
7151 - x += '<a href=# onclick=p10WebRouter("' + node._id + '",2,443)>' + "HTTPS" + '</a>&nbsp;';
7186 + x += '<a href=# cmenu=httpPortContextMenu onclick=p10WebRouter("' + node._id + '",1,' + (node.httpport ? node.httpport : 80) + ')>' + "HTTP" + '</a>&nbsp;';
7187 + x += '<a href=# cmenu=httpsPortContextMenu onclick=p10WebRouter("' + node._id + '",2,' + (node.httpsport ? node.httpsport : 443) + ')>' + "HTTPS" + '</a>&nbsp;';
7188 }
7189 if ((node.agent.id > 0) && (node.agent.id < 5)) {
7190 if (navigator.platform.toLowerCase() == 'win32') {