Esempio n. 1
0
 def __init__(self, cbServerHostName, cbServerCert, tracerMHops,
              tracerSPerHop, tracerPeriod):
     self.logger = logging.getLogger(__name__)
     self.cbServerHostName = cbServerHostName
     self.tracer = Tracer(tracerMHops, tracerSPerHop, tracerPeriod)
     self.hts = {"tasks": [], "pip": {4: {}, 6: {}}}
     self.cbServerCert = cbServerCert
     self.pipfetcher = PipFetcher(self.cbServerHostName, self.cbServerCert)
     self.htlfetcher = HTLFetcher(cbServerHostName, 443, self.cbServerCert)
Esempio n. 2
0
 def __init__(self, cbServerHostName, cbServerCert, tracerMHops, tracerSPerHop, tracerPeriod):
     self.logger = logging.getLogger(__name__)
     self.cbServerHostName    = cbServerHostName
     self.tracer              = Tracer(tracerMHops, tracerSPerHop, tracerPeriod)
     self.hts                 = {"tasks" : [], "pip": {4:{}, 6:{}}}
     self.cbServerCert        = cbServerCert
     self.pipfetcher          = PipFetcher(self.cbServerHostName, self.cbServerCert)
     self.htlfetcher          = HTLFetcher(cbServerHostName, 443, self.cbServerCert)
Esempio n. 3
0
class PyHunter(object):
    # TODO: Merge this with the CBTester class
    def __init__(self, cbServerHostName, cbServerCert, tracerMHops,
                 tracerSPerHop, tracerPeriod):
        self.logger = logging.getLogger(__name__)
        self.cbServerHostName = cbServerHostName
        self.tracer = Tracer(tracerMHops, tracerSPerHop, tracerPeriod)
        self.hts = {"tasks": [], "pip": {4: {}, 6: {}}}
        self.cbServerCert = cbServerCert
        self.pipfetcher = PipFetcher(self.cbServerHostName, self.cbServerCert)
        self.htlfetcher = HTLFetcher(cbServerHostName, 443, self.cbServerCert)

    def getHTL(self):
        """fetchs the hunting task list"""
        ml = self.htlfetcher.fetch()
        for msg in ml.allMessages():
            if msg.type == messageTypes["CURRENT_SERVER_TIME"]:
                self.hts["cs"] = msg
                continue
            elif msg.type == messageTypes["PUBLIC_IP_NOTIF4"]:
                self.hts["pip"][4]["not"] = msg
                self.hts["pip"][4]["ts"] = time()
                continue
            elif msg.type == messageTypes["PUBLIC_IP_NOTIF6"]:
                self.hts["pip"][6]["not"] = msg
                self.hts["pip"][6]["ts"] = time()
                continue
            elif msg.type == messageTypes[
                    "IPV4_SHA256_TASK"] or msg.type == messageTypes[
                        "IPV6_SHA256_TASK"]:
                self.hts["tasks"].append(msg)
                continue
        return {}

    def freshen_pip(self, ipv):
        """
        checks whether the current pip is fresh
        pulls a fresh one if that isn't the case
        """
        validity = 60000
        try:
            if (time() - self.hts["pip"][ipv]["ts"] < validity):
                return True
        except KeyError, e:
            print e
            return False
        try:
            print "Getting a new Public IP Notification!"
            pipn = self.pipfetcher.getPublicIPN(ipv)
            self.hts["pip"][ipv]["not"] = pipn
            return True
        except Exception, e:
            print e
            return False
Esempio n. 4
0
class PyHunter(object):
    # TODO: Merge this with the CBTester class
    def __init__(self, cbServerHostName, cbServerCert, tracerMHops, tracerSPerHop, tracerPeriod):
        self.logger = logging.getLogger(__name__)
        self.cbServerHostName    = cbServerHostName
        self.tracer              = Tracer(tracerMHops, tracerSPerHop, tracerPeriod)
        self.hts                 = {"tasks" : [], "pip": {4:{}, 6:{}}}
        self.cbServerCert        = cbServerCert
        self.pipfetcher          = PipFetcher(self.cbServerHostName, self.cbServerCert)
        self.htlfetcher          = HTLFetcher(cbServerHostName, 443, self.cbServerCert)

    def getHTL(self):
        """fetchs the hunting task list"""
        ml = self.htlfetcher.fetch()
        for msg in ml.allMessages():
            if msg.type == messageTypes["CURRENT_SERVER_TIME"]:
                self.hts["cs"] = msg
                continue
            elif msg.type == messageTypes["PUBLIC_IP_NOTIF4"]:
                self.hts["pip"][4]["not"] = msg
                self.hts["pip"][4]["ts"]  = time()
                continue
            elif msg.type == messageTypes["PUBLIC_IP_NOTIF6"]:
                self.hts["pip"][6]["not"] = msg
                self.hts["pip"][6]["ts"] = time()
                continue
            elif msg.type == messageTypes["IPV4_SHA256_TASK"] or msg.type == messageTypes["IPV6_SHA256_TASK"]:
                self.hts["tasks"].append(msg)
                continue
        return {}
        
    def freshen_pip(self,ipv):
        """
        checks whether the current pip is fresh
        pulls a fresh one if that isn't the case
        """
        validity = 60000
        try:
            if (time() - self.hts["pip"][ipv]["ts"] < validity):
                return True
        except KeyError, e:
	    print e
            return False
        try:
            print "Getting a new Public IP Notification!"
            pipn = self.pipfetcher.getPublicIPN(ipv)
            self.hts["pip"][ipv]["not"] = pipn
            return True
        except Exception, e:
	    print e
            return False