def handler(store, default=True, internal=False, passive=False):
    """ Decorator for setting up a handler.

    This puts the handler into the handler store which can then be used
    to look up all handlers and information about them such as which are default,
    passive, etc.

    Currently there are two handler stores, one for connection handlers in
    nogotofail.mitm.connection.handlers.connection.store and one for data handlers
    in nogotofail.mitm.connection.handlers.data.store

    Arguments:
    store -- the HandlerStore to store information about the handler in
    default -- if the handler should be used by default
    internal -- if the handler is used internally. These are always added and not displayed
        in --help or sent to the client.
    passive -- if the handler is passive and does no modification.
    """
    def wrapper(cls):
        cls.passive = passive

        if internal:
            store.internal.append(cls)
        else:
            store.map[cls.name] = cls
            store.all.append(cls)
            if default:
                store.default.append(cls)
        return cls
    return wrapper