99import time
1010
1111class SSHServer (multi .Thread ):
12+ OKGREEN = '\033 [92m'
13+ ENDC = '\033 [0m'
1214
1315 def loadPublicKey (self ):
1416 pubkey = '/root/.ssh/cyberpanel.pub'
@@ -44,17 +46,25 @@ def __init__(self, websocket):
4446 self .shell .settimeout (0 )
4547
4648 self .websocket = websocket
49+ self .color = 0
4750
4851 def recvData (self ):
4952 while True :
5053 try :
5154 if os .path .exists (self .websocket .verifyPath ):
52- if self .shell .recv_ready ():
53- self .websocket .sendMessage (self .shell .recv (9000 ).decode ("utf-8" ))
54- else :
55- time .sleep (0.1 )
55+ if self .websocket .filePassword == self .websocket .filePassword :
56+ if self .shell .recv_ready ():
57+ if self .color == 0 :
58+ text = '%sEnjoy your accelerated Internet by CyberPanel and LiteSpeed%s' % (SSHServer .OKGREEN , SSHServer .ENDC )
59+ nText = 'Enjoy your accelerated Internet by CyberPanel'
60+ self .websocket .sendMessage (self .shell .recv (9000 ).decode ("utf-8" ).replace (nText , text ))
61+ self .color = 1
62+ else :
63+ self .websocket .sendMessage (self .shell .recv (9000 ).decode ("utf-8" ))
64+ else :
65+ time .sleep (0.01 )
5666 except BaseException , msg :
57- time .sleep (2 )
67+ time .sleep (0.1 )
5868
5969 def run (self ):
6070 try :
@@ -70,9 +80,12 @@ def handleMessage(self):
7080 data = json .loads (self .data )
7181 if str (self .data ).find ('"tp":"init"' ) > - 1 :
7282 self .verifyPath = str (data ['data' ]['verifyPath' ])
83+ self .password = str (data ['data' ]['password' ])
84+ self .filePassword = open (self .verifyPath , 'r' ).read ()
7385 else :
7486 if os .path .exists (self .verifyPath ):
75- self .shell .send (str (data ['data' ]))
87+ if self .filePassword == self .filePassword :
88+ self .shell .send (str (data ['data' ]))
7689 except :
7790 pass
7891
0 commit comments