Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
-Modified Server 002 to start moving identical components for User,Monitor and Drone Connections into a parent class ClientConnection
  • Loading branch information
Scratchcat1 authored Oct 19, 2017
1 parent a0d2791 commit 910d11b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 223 deletions.
27 changes: 15 additions & 12 deletions AATC_Client_Text_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,14 @@ def GetMonitorPermissionUser(self):
#################################################

def Call_Exit(self):
Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True
else:
print("Exit cancelled")
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True




Expand All @@ -386,7 +383,13 @@ def Call_Exit(self):

TextUI = UserTextUI(U,MenuOptions)
TextUI.Main_Loop()
Exit = True #When user selects exit

Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting")
Exit = True #When user selects exit
else:
print("Exit cancelled")

except Exception as e:
print("Error occured creating user interface",e)
Expand Down
8 changes: 4 additions & 4 deletions AATC_Crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ def ServerGenerateKey(self):

if Command == "ExchangeKey":
publicKey,AES_KeySize = Arguments[0],Arguments[1]

if AES_KeySize not in AATC_Config.ALLOWED_AES_KEYSIZES:
AES_KeySize = AATC_Config.DEFAULT_AES_KEYSIZE #If key size is not valid set size to default of AATC_Config.DEFAULT_AES_KEYSIZE

self.AESKey = binascii.b2a_hex(os.urandom(AES_KeySize//2)) # Here to allow regeneration of AES key while still in loop if required.
self.IV = binascii.b2a_hex(os.urandom(AES_KeySize//2))
self.IV = binascii.b2a_hex(os.urandom(AES_KeySize//2))

RSAPrivateKey = RSA.import_key(publicKey)
PublicKeyObject = PKCS1_OAEP.new(RSAPrivateKey)
RSAPublicKey = RSA.import_key(publicKey)
PublicKeyObject = PKCS1_OAEP.new(RSAPublicKey)

EncryptedAESKey = PublicKeyObject.encrypt(self.AESKey)
EncryptedIV = PublicKeyObject.encrypt(self.IV)
Expand Down Expand Up @@ -136,6 +137,5 @@ def Send(self,data):
def Recv(self):
data = recvall.recvall(self.con)
data = ast.literal_eval(codecs.decode(data))
# (Command,Arguments)
return data

4 changes: 2 additions & 2 deletions AATC_DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def RemoveFlight(self,UserID,FlightID):

def CheckForFlight(self,DroneID,MaxLookAheadTime):
InvalidateDelay = 1800
self.cur.execute("SELECT FlightID FROM Flight WHERE DroneID = %s AND StartTime < (%s+%s) AND StartTime > (%s-%s) ORDER BY StartTime ASC LIMIT 1",(DroneID,GetTime(),MaxLookAheadTime, GetTime(),InvalidateDelay))
self.cur.execute("SELECT FlightID FROM Flight WHERE DroneID = %s AND StartTime < (%s+%s) AND StartTime > (%s-%s) AND Completed = 0 ORDER BY StartTime ASC LIMIT 1",(DroneID,GetTime(),MaxLookAheadTime, GetTime(),InvalidateDelay))
FlightIDFetch = self.cur.fetchall()
self.db_con.commit()
if FlightIDFetch != ():
Expand All @@ -227,7 +227,7 @@ def MarkFlightComplete(self,DroneID,FlightID,Code):
return False,"You do not have permission to mark this flight complete"

def GetCompletedFlightIDs(self,EndTimeThreshold):
self.cur.execute("SELECT FlightID FROM Flight WHERE Completed > 0 AND (EndTime + %s) > %s",(EndTimeThreshold,GetTime()))
self.cur.execute("SELECT FlightID FROM Flight WHERE (Completed > 0 AND (EndTime + %s) > %s) OR (EndTime+ %s) > %s",(EndTimeThreshold,GetTime(),EndTimeThreshold*3,GetTime()))
return True,"['FlightID']",self.cur.fetchall()

def CleanCompletedFlights(self,EndTimeThreshold):
Expand Down
Loading

0 comments on commit 910d11b

Please sign in to comment.