diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 46ea8a993..b8fc3bbfc 100755
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,5 +1,8 @@
+
+
+
@@ -27,11 +30,80 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -48,15 +120,6 @@
- restoreRemoteBackupsInc
- status
- liteSpeedStatus
- saveRewrite
- Dashboard
- onerror
- sendCommand
- trans_forward
- invoke_shell
self.ssh
webssh
_shell
@@ -78,6 +141,15 @@
emailMig
apt install build-essential libssl-dev libffi-dev python3-dev
python4
+ submitForward
+ IncBackup
+ pip install --ignore-installed
+ -r
+ websockets
+ addRule
+ websocket
+ conf/key
+ addRUle
admin.api == 1
@@ -95,6 +167,7 @@
cyberpanelLoading
cyberpanel.sh
https
+ self.websocket
$PROJECT_DIR$/backup
@@ -108,9 +181,6 @@
-
-
-
-
+
+
+
+
@@ -183,7 +256,7 @@
-
+
@@ -194,21 +267,21 @@
-
+
-
-
-
+
-
+
+
+
@@ -223,7 +296,29 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -246,6 +341,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -293,6 +432,9 @@
+
+
+
@@ -399,24 +541,25 @@
-
+
+
-
+
-
+
-
+
-
-
+
+
@@ -477,6 +620,11 @@
489
+
+ file://$PROJECT_DIR$/WebTerminal/CPWebSocket.py
+ 100
+
+
file://$PROJECT_DIR$/CLManager/templates/CLManager/createPackage.html
46
@@ -491,133 +639,13 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebTerminal/CPWebSocket.py b/WebTerminal/CPWebSocket.py
index 7dd379fe1..24357f206 100644
--- a/WebTerminal/CPWebSocket.py
+++ b/WebTerminal/CPWebSocket.py
@@ -6,21 +6,22 @@ import json
import ssl
-class WebSocketServer():
+class WebSocketServer:
def loadPublicKey(self):
pubkey = '/root/.ssh/cyberpanel.pub'
-
data = open(pubkey, 'r').read()
-
authFile = '/root/.ssh/authorized_keys'
- authData = open(authFile, 'r').read()
-
checker = 1
- if authData.find(data) > -1:
- checker = 0
+ try:
+ authData = open(authFile, 'r').read()
+ if authData.find(data) > -1:
+ checker = 0
+ except:
+ pass
+
if checker:
writeToFile = open(authFile, 'a')
@@ -119,17 +120,17 @@ class WebSocketServer():
def main():
pidfile = '/usr/local/CyberCP/WebTerminal/pid'
- machineIP = open('/etc/cyberpanel/machineIP', 'r').read()
- context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
- context.load_cert_chain('/usr/local/lscp/conf/cert.pem', '/usr/local/lscp/conf/key.pem')
- start_server = websockets.serve(WebSocketServer.initialize, machineIP, 5678, ssl=context)
- asyncio.get_event_loop().run_until_complete(start_server)
- asyncio.get_event_loop().run_forever()
- writeToFile = open(pidfile, 'r')
+ writeToFile = open(pidfile, 'w')
writeToFile.write(str(os.getpid()))
writeToFile.close()
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
+ context.load_cert_chain('/usr/local/lscp/conf/cert.pem', '/usr/local/lscp/conf/key.pem')
+ start_server = websockets.serve(WebSocketServer.initialize, '', 5678, ssl=context)
+ asyncio.get_event_loop().run_until_complete(start_server)
+ asyncio.get_event_loop().run_forever()
+
diff --git a/WebTerminal/static/WebTerminal/main.js b/WebTerminal/static/WebTerminal/main.js
index 6b6ea8a2b..87742f9d3 100755
--- a/WebTerminal/static/WebTerminal/main.js
+++ b/WebTerminal/static/WebTerminal/main.js
@@ -91,4 +91,57 @@ function connect() {
openTerminal(options)
}
-connect();
\ No newline at end of file
+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'
+ });
+ }
+
+ };
+
+});
\ No newline at end of file
diff --git a/WebTerminal/templates/WebTerminal/WebTerminal.html b/WebTerminal/templates/WebTerminal/WebTerminal.html
index 2eb15e092..46650deeb 100755
--- a/WebTerminal/templates/WebTerminal/WebTerminal.html
+++ b/WebTerminal/templates/WebTerminal/WebTerminal.html
@@ -13,16 +13,23 @@
-
{% trans "Terminal" %}
+
{% trans "Execute your terminal commands." %}
-
+
diff --git a/WebTerminal/urls.py b/WebTerminal/urls.py
index b2c552685..a959df39a 100755
--- a/WebTerminal/urls.py
+++ b/WebTerminal/urls.py
@@ -3,4 +3,5 @@ import views
urlpatterns = [
url(r'^$', views.terminal, name='terminal'),
+ url(r'^restart$', views.restart, name='restart'),
]
\ No newline at end of file
diff --git a/WebTerminal/views.py b/WebTerminal/views.py
index 822d0cb1c..e604b496d 100644
--- a/WebTerminal/views.py
+++ b/WebTerminal/views.py
@@ -1,13 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.shortcuts import render, redirect
+from django.shortcuts import render, redirect, HttpResponse
from plogical.acl import ACLManager
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from loginSystem.views import loadLoginPage
from random import randint
import os
from plogical.processUtilities import ProcessUtilities
+from plogical.firewallUtilities import FirewallUtilities
+from firewall.models import FirewallRules
+import json
+
# Create your views here.
def terminal(request):
@@ -25,6 +29,7 @@ def terminal(request):
writeToFile.writelines('code')
writeToFile.close()
+
## setting up ssh server
path = '/etc/systemd/system/cpssh.service'
curPath = '/usr/local/CyberCP/WebTerminal/cpssh.service'
@@ -36,7 +41,37 @@ def terminal(request):
command = 'systemctl start cpssh'
ProcessUtilities.executioner(command)
+ FirewallUtilities.addRule('tcp', '5678', '0.0.0.0/0')
+
+ newFWRule = FirewallRules(name='terminal', proto='tcp', port='5678', ipAddress='0.0.0.0/0')
+ newFWRule.save()
+
return render(request, 'WebTerminal/WebTerminal.html', {'verifyPath': verifyPath})
except BaseException, msg:
logging.writeToFile(str(msg))
- return redirect(loadLoginPage)
\ No newline at end of file
+ return redirect(loadLoginPage)
+
+
+
+def restart(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ command = 'systemctl restart cpssh'
+ ProcessUtilities.executioner(command)
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException, msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
\ No newline at end of file
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index a383dc483..f87a70cbe 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -640,14 +640,14 @@
- {% trans "Web Based Terminal" %}
+ {% trans "Web Terminal" %}
{% trans "NEW" %}
diff --git a/install/install.py b/install/install.py
index 5c7bc76c6..a94e7646f 100755
--- a/install/install.py
+++ b/install/install.py
@@ -3630,7 +3630,7 @@ milter_default_action = accept
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
- command = "pip install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
+ command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
diff --git a/loginSystem/urls.py b/loginSystem/urls.py
index 5236c6d00..93585445a 100755
--- a/loginSystem/urls.py
+++ b/loginSystem/urls.py
@@ -1,6 +1,5 @@
from django.conf.urls import url
import views
-from xterm_django.views import ssh_with_websocket
urlpatterns = [
url(r'^$', views.loadLoginPage, name='adminLogin'),
diff --git a/plogical/test1.py b/plogical/test1.py
new file mode 100755
index 000000000..e69de29bb
diff --git a/static/WebTerminal/main.js b/static/WebTerminal/main.js
index 6b6ea8a2b..87742f9d3 100644
--- a/static/WebTerminal/main.js
+++ b/static/WebTerminal/main.js
@@ -91,4 +91,57 @@ function connect() {
openTerminal(options)
}
-connect();
\ No newline at end of file
+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'
+ });
+ }
+
+ };
+
+});
\ No newline at end of file