Beispiel #1
0
#!/usr/bin/python

import shared
import socket
import time

blah = shared.SecondBucketCounter(5)

def processData(data):
  if data['type'] == "connect":
    host = data['host']
    blah.addItem(host)
    if blah.checkItem(host, 75):
      agg.write("BLOCK %s|10000" % host)

agg = shared.AggregatorConnector()

while True:
  for d in agg.json_read():
    processData(d)
Beispiel #2
0
    self.time = int(time.time() * 1000)
    #self.method = 'GET'
  def request(self):
    #this enables random ip
    self.method = "GET"
    self.type = 'request'
    self.uuid = str(uuid.uuid4())
    self.url = fake_paths[int(random.random() * len(fake_paths))]
    self.host = fake_hosts[int(random.random() * len(fake_hosts))]
    self.time = int(time.time() * 1000)
    return(json.dumps(self.__dict__))
  def connect(self):
    return(json.dumps({"host":self.host,"uuid":self.uuid,"type": "connect"}))
  def end(self):
    self.time = int(time.time() * 1000)
    return(json.dumps({"host":self.host,"uuid":self.uuid,"type": "end","time":int(self.time + (random.random() * 20000))}))

agg = shared.AggregatorConnector(mode="S")

m = MockHttp()
for i in range(0,int(total_requests)):
  request = str(m.request())
  agg.write(request)
  end = str(m.end())
  agg.write(end)
  #time.sleep(.0001)
#  agg.write(str(m.request()))
  #time.sleep(.1)
#  agg.write(str(m.end()))
#  del(m)