Example #1
0
def run():
    """
    The run method is what actually spawns and manages blackhole.
    """
    signal.signal(signal.SIGTERM, terminate)
    action = set_action()
    set_options()
    # Grab the sockets early for multiprocessing
    if action in ('start',):
        socks = sockets()
        setgid()
        setuid()
    d = daemon(action)
    # Change group and user
    io_loop = fork()
    # Iterate over the dictionary of socket connections
    # and add them to the IOLoop
    for _, sock in socks.iteritems():
        callback = functools.partial(connection_ready, sock)
        io_loop.add_handler(sock.fileno(), callback, io_loop.READ)
    try:
        io_loop.start()
    except (KeyboardInterrupt, SystemExit):
        io_loop.stop()
        d.stop()
        sys.exit(0)
Example #2
0
def run():
    """
    The run method is what actually spawns and manages blackhole.
    """
    signal.signal(signal.SIGTERM, terminate)
    action = set_action()
    set_options()
    # Grab the sockets early for multiprocessing
    if action in ('start', ):
        socks = sockets()
        setgid()
        setuid()
    d = daemon(action)
    # Change group and user
    io_loop = fork()
    # Iterate over the dictionary of socket connections
    # and add them to the IOLoop
    for _, sock in socks.iteritems():
        callback = functools.partial(connection_ready, sock)
        io_loop.add_handler(sock.fileno(), callback, io_loop.READ)
    try:
        io_loop.start()
    except (KeyboardInterrupt, SystemExit):
        io_loop.stop()
        d.stop()
        sys.exit(0)
Example #3
0
 def setUp(self):
     super(TestSSLSocketIsNotSet, self).setUp()
     options.ssl = False
     self.sockets = sockets()
Example #4
0
 def setUp(self):
     super(TestSSLSocketIsSet, self).setUp()
     options.ssl = True
     self.sockets = sockets()
Example #5
0
 def setUp(self):
     super(TestSocketIsSet, self).setUp()
     self.ssl = False
     self.sockets = sockets()
Example #6
0
 def setUp(self):
     super(TestSSLSocketIsNotSet, self).setUp()
     options.ssl = False
     self.sockets = sockets()
Example #7
0
 def setUp(self):
     super(TestSSLSocketIsSet, self).setUp()
     options.ssl = True
     self.sockets = sockets()
Example #8
0
 def setUp(self):
     super(TestSocketIsSet, self).setUp()
     self.ssl = False
     self.sockets = sockets()