bug fix: web terminal

This commit is contained in:
Usman Nasir
2019-11-03 19:31:21 +05:00
parent 1d4e588a73
commit a80d7456f6
11 changed files with 586 additions and 391 deletions

View File

@@ -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()