show rdp port on button and set rdpport in console (#5708)

* add rdpport to console

Signed-off-by: si458 <simonsmith5521@gmail.com>

* add port number to rdp connect button

Signed-off-by: si458 <simonsmith5521@gmail.com>

---------

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-01-19 02:56:54 +00:00 committed by GitHub
parent aaff8232b0
commit a2aed9e772
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 1 deletions

View File

@ -3767,7 +3767,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
if (require('os').dns != null) { availcommands += ',dnsinfo'; }
try { require('linux-dhcp'); availcommands += ',dhcp'; } catch (ex) { }
if (process.platform == 'win32') {
availcommands += ',cs,wpfhwacceleration,uac,volumes';
availcommands += ',cs,wpfhwacceleration,uac,volumes,rdpport';
if (bcdOK()) { availcommands += ',safemode'; }
if (require('notifybar-desktop').DefaultPinned != null) { availcommands += ',privacybar'; }
try { require('win-utils'); availcommands += ',taskbar'; } catch (ex) { }
@ -4051,6 +4051,44 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
case 'timerinfo':
response = require('ChainViewer').getTimerInfo();
break;
case 'rdpport':
if (process.platform != 'win32') {
response = 'Unknown command "rdpport", type "help" for list of available commands.';
return;
}
if (args['_'].length == 0) {
response = 'Proper usage: rdpport [get|default|PORTNUMBER]';
} else {
switch (args['_'][0].toLocaleLowerCase()) {
case 'get':
var rdpport = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp', 'PortNumber');
response = "Current RDP Port Set To: " + rdpport + '\r\n';
break;
case 'default':
try {
require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp', 'PortNumber', 3389);
response = 'RDP Port Set To 3389, Please Dont Forget To Restart Your Computer To Fully Apply';
} catch (ex) {
response = 'Unable to Set RDP Port To: 3389';
}
break;
default:
if (isNaN(parseFloat(args['_'][0]))){
response = 'Proper usage: rdpport [get|default|PORTNUMBER]';
} else if(parseFloat(args['_'][0]) < 0 || args['_'][0] > 65535) {
response = 'RDP Port Must Be More Than 0 And Less Than 65535';
} else {
try {
require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp', 'PortNumber', parseFloat(args['_'][0]));
response = 'RDP Port Set To ' + args['_'][0] + ', Please Dont Forget To Restart Your Computer To Fully Apply';
} catch (ex) {
response = 'Unable to Set RDP Port To: '+args['_'][0];
}
}
break;
}
}
break;
case 'find':
if (args['_'].length <= 1) {
response = "Proper usage:\r\n find root criteria [criteria2] [criteria n...]";

View File

@ -8984,6 +8984,7 @@
var online = ((currentNode.conn & 1) != 0); // If Agent (1) connected, enable remote desktop
QE('connectbutton1', online);
QE('connectbutton1r', online || (currentNode.mtype == 3));
Q('connectbutton1r').value = 'RDP Connect' + ((currentNode.rdpport && currentNode.rdpport != 3389) ? ' ('+currentNode.rdpport + ')' : '');
var hwonline = ((currentNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal
QE('connectbutton1h', hwonline);
QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus));