Пример #1
0
 def destroy(self):
     cls = self.__class__
     for conn, _ in self.proxy_pool:
         conn.close()
     if self == cls._tunnels[self.name]:
         cls._tunnels.pop(self.name, None)
     metrics.counter('total_tunnel').dec()
Пример #2
0
 def destroy(self):
     cls = self.__class__ 
     for conn, _ in self.proxy_pool:
         conn.close()
     if self == cls._tunnels[self.name]:
         cls._tunnels.pop(self.name, None)
     metrics.counter('total_tunnel').dec()
Пример #3
0
 def _scan_idle():
     counter = metrics.counter("idle_tunnel")
     counter.clear()
     for name, tunnel in cls._tunnels.iteritems():
         if time.time() - tunnel.updated > cls.active_timeout:
             tunnel.idle = True
             counter.inc()
     if counter.get_count():
         logging.debug("scan: {0} of {1} tunnels are idle".format(counter.get_value(), len(cls._tunnels)))
     cls.schedule_idle_scan()
Пример #4
0
    def __init__(self, name, client, protect=None, domain=None):
        self.name = name
        self.client = client
        if protect:
            user, passwd = protect.split(':')
            self.protect_user = user
            self.protect_passwd = passwd
            self.protect = True
        else:
            self.protect = False
        self.domain = domain
        self.created = time.time()
        self.updated = time.time()
        self.idle = False
        self.proxy_pool = []
        self.pool_semaphore = eventlet.semaphore.Semaphore(0)

        metrics.counter('total_tunnel').inc()
        platform = self.client.split(';', 1)[-1].lower()
        metrics.counter('collect:{0}'.format(platform)).inc()
Пример #5
0
 def _scan_idle():
     counter = metrics.counter('idle_tunnel')
     counter.clear()
     for name, tunnel in cls._tunnels.iteritems():
         if time.time() - tunnel.updated > cls.active_timeout:
             tunnel.idle = True
             counter.inc()
     if counter.get_count():
         logging.debug("scan: {0} of {1} tunnels are idle".format(
             counter.get_value(), len(cls._tunnels)))
     cls.schedule_idle_scan()
Пример #6
0
    def __init__(self, name, client, protect=None, domain=None):
        self.name = name
        self.client = client
        if protect:
            user, passwd = protect.split(':')
            self.protect_user = user
            self.protect_passwd = passwd
            self.protect = True
        else:
            self.protect = False
        self.domain = domain
        self.created = time.time()
        self.updated = time.time()
        self.idle = False
        self.proxy_pool = []
        self.pool_semaphore = eventlet.semaphore.Semaphore(0)

        metrics.counter('total_tunnel').inc()
        platform = self.client.split(';', 1)[-1].lower()
        metrics.counter('collect:{0}'.format(platform)).inc()