Example #1
0
def run_mdp_broker():
    args = docopt("""Usage:
        mdp-broker [options] <config>

    Options:
        -h --help                 show this help message and exit
        -s --secure               generate (and print) client & broker keys for a secure server
    """)
    global log
    _setup_logging(args['<config>'])

    log = logging.getLogger(__name__)

    cp = ConfigParser()
    cp.read(args['<config>'])

    # Parse settings a bit
    raw = dict(
        (option, cp.get('mdp-broker', option))
        for option in cp.options('mdp-broker'))
    s = SettingsSchema().to_python(raw)

    if args['--secure']:
        broker_key = Key.generate()
        client_key = Key.generate()
        s['key'] = dict(
            broker=broker_key,
            client=client_key)
        log.info('Auto-generated keys: %s_%s_%s',
            broker_key.public, client_key.public, client_key.secret)
        log.info(' broker.public: %s', broker_key.public)
        log.info(' client.public: %s', client_key.public)
        log.info(' client.secret: %s', client_key.secret)

    if s['key']:
        log.info('Starting secure mdp-broker on %s', s['uri'])
        auth = ThreadAuthenticator()
        auth.start()
        auth.thread.authenticator.certs['*'] = {
            s['key']['client'].public: 'OK'}

        broker = SecureMajorDomoBroker(s['key']['broker'], s['uri'])
    else:
        log.info('Starting mdp-broker on %s', s['uri'])
        broker = MajorDomoBroker(s['uri'])
    try:
        broker.serve_forever()
    except:
        auth.stop()
        raise
def main():
    auth = ThreadAuthenticator(zmq.Context.instance())
    auth.start()
    auth.allow('127.0.0.1')
    # Tell the authenticator how to handle CURVE requests
    auth.configure_curve(domain='*', location=zmq.auth.CURVE_ALLOW_ANY)

    key = Key.load('example/broker.key_secret')
    broker = SecureMajorDomoBroker(key, sys.argv[1])
    try:
        broker.serve_forever()
    except KeyboardInterrupt:
        auth.stop()
        raise
def main():
    auth = ThreadAuthenticator(zmq.Context.instance())
    auth.start()
    auth.allow('127.0.0.1')
    # Tell the authenticator how to handle CURVE requests
    auth.configure_curve(domain='*', location=zmq.auth.CURVE_ALLOW_ANY)

    key = Key.load('example/broker.key_secret')
    broker = SecureMajorDomoBroker(key, sys.argv[1])
    try:
        broker.serve_forever()
    except KeyboardInterrupt:
        auth.stop()
        raise
Example #4
0
def run_mdp_broker():
    args = docopt("""Usage:
        mdp-broker [options] <config>

    Options:
        -h --help                 show this help message and exit
        -s --secure               generate (and print) client & broker keys for a secure server
    """)
    global log
    _setup_logging(args['<config>'])

    log = logging.getLogger(__name__)

    cp = ConfigParser()
    cp.read(args['<config>'])

    # Parse settings a bit
    raw = dict((option, cp.get('mdp-broker', option))
               for option in cp.options('mdp-broker'))
    s = SettingsSchema().to_python(raw)

    if args['--secure']:
        broker_key = Key.generate()
        client_key = Key.generate()
        s['key'] = dict(broker=broker_key, client=client_key)
        log.info('Auto-generated keys: %s_%s_%s', broker_key.public,
                 client_key.public, client_key.secret)
        log.info(' broker.public: %s', broker_key.public)
        log.info(' client.public: %s', client_key.public)
        log.info(' client.secret: %s', client_key.secret)

    if s['key']:
        log.info('Starting secure mdp-broker on %s', s['uri'])
        auth = ThreadAuthenticator()
        auth.start()
        auth.thread.authenticator.certs['*'] = {
            s['key']['client'].public: 'OK'
        }

        broker = SecureMajorDomoBroker(s['key']['broker'], s['uri'])
    else:
        log.info('Starting mdp-broker on %s', s['uri'])
        broker = MajorDomoBroker(s['uri'])
    try:
        broker.serve_forever()
    except:
        auth.stop()
        raise