Example #1
0
def new_secret_main(argv):
    """
    prints a new storage secret to stdout
    """
    from cli import build_base_options, parse_config
    optparser = build_base_options()
    opts, args, config = parse_config(argv, optparser, require_config=False)

    print new_secret()
Example #2
0
def relay_main(argv):
    from cli import build_base_options, parse_config
    optparser = build_base_options()
    opts, args, config = parse_config(argv, optparser)

    storage = build_storage(config, opts)
    xmpp = build_relay(config, opts, storage)

    # Connect to the XMPP server and start processing XMPP stanzas.
    if xmpp.connect():
        xmpp.process(block=True)
        print("Done")
    else:
        print("Unable to connect.")
Example #3
0
def hash_main(argv):
    """
    utility mainline for hashing and looking up jids.
    """

    from cli import build_base_options, parse_config
    from jidstorage import build_storage, no_storage

    optparser = build_base_options()

    optparser.add_option('-S', '--store', help='store results',
                         dest='build_storage', action="store_true", default=False)

    optparser.add_option(
        "-l", "--lookup", help='lookup real jid for hashed jid',
        dest="lookup", action="store_true", default=False)

    opts, args, config = parse_config(argv, optparser)

    if opts.build_storage == True or opts.lookup:
        storage = build_storage(config, opts)
    else:
        storage = no_storage()

    if opts.lookup == True:
        for hjid in args:
            real_jid = lookup_jid(JID(hjid), storage)
            print "%s => %s" % (hjid, real_jid)

    else:
        section = "hash"
        if not config.has_section(section):
            sys.exit("Configuration file %s is missing the [%s] section" % (
                opts.config_file, section))

        cfg = {}
        for key in ["secret", "domain"]:
            if not config.has_option(section, key):
                sys.exit('Missing option "%s" in [%s] section of %s' %
                         (key, section, opts.config_file))
            cfg[key] = config.get(section, key)

        for real_jid in args:
            hashed_jid = hash_jid(
                JID(real_jid), cfg['secret'], cfg['domain'], storage)
            print "%s => %s" % (real_jid, hashed_jid)