-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJobList.py
More file actions
171 lines (129 loc) · 5.71 KB
/
JobList.py
File metadata and controls
171 lines (129 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from Job import *
class JobList(object):
"""
Final Project
-Code Logic: nearestSeekerLocationtoTarget()
-Code Logic: returnJobSeekerLanHosts()
-Code GUI or convert unto .exe
-(BONUS 5%) Resume From Crash Point
"""
'''
Needed Variables
listofjobs: This list holds jobs that are created from the Client and will store all the information of the Jobs
jobsToRequest: This is a static list which is used to hold the names of the types of jobs offered
'''
listofjobs = []
jobsToRequest = ['IP Online Detection', 'Subnet IP Online Detection', 'Specific Port Status Detection',
'All Port Status Detection', 'ICMP Flood Attack', 'TCP Flood Attack', 'UDP Flood Attack']
'''
One-To-One Jobs
'''
def createIPOnlineDetectionJob(self, creatorName):
#Creating IP Online Detection Job
job = Job(creatorName, "IP Online Detection", '1')
#Adding IP Online Detection Job to Job List
self.listofjobs.append(job)
def createSubnetIPOnlineDetection(self, creatorName):
#Creating Subnet IP Online Detection Job
job = Job(creatorName, "Subnet IP Online Detection", '1')
#Adding Subnet IP Online Detection Job to Job List
self.listofjobs.append(job)
def specificPortStatusDetection(self, creatorName):
#Creating Specific Port Status Detection Job
job = Job(creatorName, "Specific Port Status Detection", '1')
#Adding Specific Port Status Detection Job to Job List
self.listofjobs.append(job)
def allPortStatusDetection(self, creatorName):
# Creating All Port Status Detection Job
job = Job(creatorName, "All Port Status Detection", '1')
# Adding All Port Status Detection Job to Job List
self.listofjobs.append(job)
'''
One-To-Many Jobs
'''
def createICMPFloodAttackJob(self, creatorName, numOfSeekers):
#Creating ICMP Flood Attack Job
job = Job(creatorName, "ICMP Flood Attack", numOfSeekers)
#Adding ICMP Flood Attack Job to Job List
self.listofjobs.append(job)
def createTCPFloodAttackJob(self, creatorName, numOfSeekers):
#Creating TCP Flood Attack Job
job = Job(creatorName, "TCP Flood Attack", numOfSeekers)
#Adding TCP Flood Attack Job to Job List
self.listofjobs.append(job)
def createUDPFloodAttackJob(self, creatorName, numOfSeekers):
#Creating UDP Flood Attack Job
job = Job(creatorName, "UDP Flood Attack", numOfSeekers)
#Adding UDP Flood Attack Job to Job List
self.listofjobs.append(job)
'''
Final Project Jobs
'''
def nearestSeekerLocationtoTarget(self):
print()
def returnJobSeekerLanHosts(self):
print()
'''
HELPER Functions
'''
def updateJobList(self, creatorName, jobName, numofSeekers):
"""
description: This Function takes in three strings and creates a
Job object and adds that object to a List of Jobs
:param creatorName: Given From Client as a string
:param jobName: Given From Client as a string
:param numofSeekers: Given From Client as a string
:return: VOID
"""
#Creating Job Object
job = Job(creatorName, jobName, numofSeekers)
#Adding Job Object to List of Jobs
self.listofjobs.append(job)
def printJobList(self):
"""
Description: This Function is used to print all jobs that are
currently inside the List of Jobs
:return: VOID
"""
#Loop For Every Job Object in The List of Jobs
for jobs in self.listofjobs:
#Loop For Every Element in The Job Object
for elements in jobs:
print(elements, end=", ")
print()
def updateNumOfSeekers(self, jobNumber, creatorStart):
"""
Description: This Function takes in parameter jobNumber which is used to determine which job
will be updating the amount of Job Seekers needed, Loops through the three main
Job object parameters and stores all three in temp variables, updates the NumofSeekers
by subtracting one then removing the old Job object and adding in the new updated Job object
:param jobNumber:This is given from the Client which is an integer
that determines which Job they will be updating the
number of seekers. This function is used during the
accept job phase. [TO BE REFACTORED]
:return:VOID
"""
#Counter Variable
count = 1
#Loop For Every Element in Specific Job
for elements in self.listofjobs[jobNumber]:
#JobCreatorName Condition
if count == 1:
jobCreatorName = elements
#JobName Condition
elif count == 2:
jobName = elements
#NumofSeekers Condition
elif count == 3:
if int(elements) == 0 and creatorStart is True:
NumofSeekers = "Job Started"
else:
NumofSeekers = int(elements) - 1
#Update Counter Variable
count+=1
#Removing the Old Job
self.listofjobs.remove(self.listofjobs[jobNumber])
#Adding the New Job
self.updateJobList(jobCreatorName, jobName, str(NumofSeekers))
def updateJobSeekerList(self, jobSelection, SeekerName):
self.listofjobs[jobSelection].addSeekerList(SeekerName)