Initial commit for v2.4.3

This commit is contained in:
usmannasir
2025-08-01 14:56:30 +05:00
commit 6dd7114f6d
4521 changed files with 1795978 additions and 0 deletions

132
static/WebTerminal/main.js Normal file
View File

@@ -0,0 +1,132 @@
var charWidth = 6.2;
var charHeight = 15.2;
/**
* for full screen
* @returns {{w: number, h: number}}
*/
function getTerminalSize() {
var width = window.innerWidth;
var height = window.innerHeight;
return {
w: Math.floor(width / charWidth),
h: Math.floor(height / charHeight)
};
}
function openTerminal(options) {
if (!$.isEmptyObject($('.terminal')[0])) {
alert("Please refresh this page.");
return
}
var client = new WSSHClient();
var term = new Terminal({cols: 120, rows: 30, screenKeys: true, useStyle: true});
term.on('data', function (data) {
client.sendClientData(data);
});
term.open();
$('.terminal').detach().appendTo('#term');
$("#term").show();
term.write('Connecting...' + '\r\n');
client.connect({
onError: function (error) {
term.write('Error connecting to backend.\r\n');
//term.destroy();
},
onConnect: function () {
client.sendInitData(options);
term.write('connection established..\r\n');
},
onClose: function (e) {
term.write("\r\nconnection closed.")
//term.destroy();
},
onData: function (data) {
term.write(data);
}
})
}
function store(options) {
window.localStorage.host = options.host;
window.localStorage.port = options.port;
window.localStorage.username = options.username;
window.localStorage.ispwd = options.ispwd;
window.localStorage.secret = options.secret
}
function check() {
return validResult["host"] && validResult["port"] && validResult["username"];
}
function connect() {
var remember = $("#remember").is(":checked");
var options = {
verifyPath: $("#verifyPath").text(),
password: $("#password").text()
};
if (remember) {
store(options)
}
openTerminal(options)
}
app.controller('webTerminal', function ($scope, $http, $window) {
$scope.cyberpanelLoading = true;
connect();
$scope.restartSSH = function (name) {
$scope.cyberpanelLoading = false;
url = "/Terminal/restart";
var data = {
name: name
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Successfully restarted SSH server, refreshing the page now..',
type: 'success'
});
$window.location.href = '/Terminal/';
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
});

5977
static/WebTerminal/term.js Normal file

File diff suppressed because it is too large Load Diff

64
static/WebTerminal/ws.js Normal file
View File

@@ -0,0 +1,64 @@
function WSSHClient() {
};
WSSHClient.prototype._generateEndpoint = function () {
var protocol = 'wss://';
var host = window.location.host.split(':')[0];
var endpoint = protocol + host + ':5678';
return endpoint;
};
WSSHClient.prototype.connect = function (options) {
var endpoint = this._generateEndpoint();
if (window.WebSocket) {
this._connection = new WebSocket(endpoint);
}
else if (window.MozWebSocket) {
this._connection = MozWebSocket(endpoint);
}
else {
options.onError('WebSocket Not Supported');
return;
}
this._connection.onerror = function (evt) {
options.onError(evt);
};
this._connection.onopen = function () {
options.onConnect();
};
this._connection.onmessage = function (evt) {
var data = evt.data.toString()
options.onData(data);
};
this._connection.onclose = function (evt) {
options.onClose(evt);
};
};
WSSHClient.prototype.send = function (data) {
this._connection.send(JSON.stringify(data));
};
WSSHClient.prototype.sendInitData = function (options) {
var data = {
hostname: options.host,
port: options.port,
username: options.username,
ispwd: options.ispwd,
secret: options.secret
};
this._connection.send(JSON.stringify({"tp": "init", "data": options}))
}
WSSHClient.prototype.sendClientData = function (data) {
this._connection.send(JSON.stringify({"tp": "client", "data": data, 'verifyPath': $("#verifyPath").text(), 'password': $("#password").text()}))
}
var client = new WSSHClient();