forked from narayana1208/4thYearProject
/
Main.py
52 lines (34 loc) · 1.01 KB
/
Main.py
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
import re
import threading
import Queue
import os
import time
from Schema import Schema, SchemaStore
from Openflow import Openflow
from Sflow import Sflow
from Monitor import Monitor
from DDoSPrevention import DDoSPrevention
def getFiles():
allFiles = os.listdir(os.getcwd())
print "current working directory is "+os.getcwd()
xmlFiles = []
xmlPattern= re.compile('^.*\.(xml)$')
for fileName in allFiles:
m = re.match(xmlPattern,fileName)
if m and fileName != "FlowSchema.xml":
xmlFiles += [m.group(0)]
print "\033[1m\033[37mLoaded schemas: "+str(xmlFiles)+"\033[0m"
return xmlFiles
schemas = SchemaStore(getFiles())
"""get lowest threshold"""
lowestThreshold = 9999999
for schema in schemas.schemas:
if schema.ddos:
if schema.ddos<lowestThreshold:
lowestThreshold=schema.ddos
openflow = Openflow(schemas)
openflow.start()
sflow = Sflow(schemas)
sflow.start()
monitor = Monitor(sflow,openflow,lowestThreshold,schemas.schemas)
monitor.start()