@@ -203,6 +203,7 @@ def socket_create(self) -> None:
203203
204204 def socket_bind (self ) -> None :
205205 """ Bind socket to port and wait for connection from client """
206+ # returns None
206207 try :
207208 self .socket .bind ((self .host , self .port ))
208209 self .socket .listen (5 )
@@ -213,11 +214,8 @@ def socket_bind(self) -> None:
213214 return
214215
215216 def recvall (self , conn , n ) -> bytes :
216- """ Helper function to recv n bytes or return None if EOF is hit
217- :param n:
218- :param conn:
219- """
220- # TODO: this can be a static method
217+ """ Function to receive n amount of bytes"""
218+ # returns bytes/None
221219 data = b''
222220 while len (data ) < n :
223221 packet = conn .recv (n - len (data ))
@@ -226,15 +224,16 @@ def recvall(self, conn, n) -> bytes:
226224 data += packet
227225 return data
228226
229- def get_key (self , conn ):
227+ def get_key (self , conn ) -> Fernet :
230228 """ Get Encryption Key from conn """
229+ # returns Fernet Key
231230 target = self .all_connections .index (conn )
232231 return self .all_keys [target ]
233232
234233 def receive (self , conn , _print = False ) -> bytes :
235234 """ Receive Buffer Size and Data from Client Encrypted with Connection Specific AES Key """
235+ # returns bytes
236236 KEY = self .get_key (conn )
237-
238237 length = int (KEY .decrypt (conn .recv (2048 )).decode ())
239238 conn .send (b'RECEIVED' )
240239 received = KEY .decrypt (self .recvall (conn , length ))
@@ -244,8 +243,8 @@ def receive(self, conn, _print=False) -> bytes:
244243
245244 def send (self , conn , data ) -> None :
246245 """ Send Buffer Size and Data to Client Encrypted with Connection Specific AES Key """
246+ # returns None
247247 KEY = self .get_key (conn )
248-
249248 encrypted = KEY .encrypt (data )
250249 conn .send (KEY .encrypt (str (len (encrypted )).encode ()))
251250 conn .recv (1024 )
@@ -412,6 +411,7 @@ def client_exec(self, conn, command) -> (str, str):
412411
413412 def python_interpreter (self , conn ) -> None :
414413 """ Remote Python Interpreter CLI"""
414+ # returns None
415415 print ('CAUTION! Using this feature wrong can break the client until restarted.' )
416416 print ('Tip: help("modules") lists available modules' )
417417 while 1 :
@@ -626,6 +626,7 @@ def shell(self, conn) -> None:
626626 self .client_shell (conn , command )
627627
628628 def selector (self , conn , command ) -> bool :
629+ """ Command selector interface """
629630 # returns True/None
630631 if '--h' in command :
631632 print (interface_help )
0 commit comments