示例#1
0
def get_domains(dom):
    print "Start with domain: " + dom

    # get all mutations of initial domain
    # id 0 is original
    domains = dnstwist.calcDomains(dom)

    mongoDomains = mongoDB.domains
    unresolvedDomains = {}

    # check if already exists in db
    for domain in domains:
        mongoDomain = mongoDomains.find_one({"domain": domain})

        if not mongoDomain is None:
            # get from db
            domains[domain] = mongoDomain
        else:
            # resolve by our self and insert into db
            domains[domain]['resolveDate'] = datetime.now()
            resolveDomain(domains[domain])
            domains[domain]['isFullyResolved'] = False;
            mongoDomains.insert(domains[domain])

            # mark for further processing
            unresolvedDomains[domain] = domains[domain]


    # start long lived resolver
    resolveDomainsLong(unresolvedDomains, mongoDomains)

    # convert domains to array and return to client
    return mongodoc_jsonify({'domains': domains.values()})
示例#2
0
        opts, args = getopt.getopt(sys.argv[1:], "d:h", ["help", "domain"])
    except getopt.error, msg:
        printHelp()
        sys.exit(0)

    if len(sys.argv) == 1:
        printHelp()
        sys.exit(0)

    # process options
    for o, a in opts:
        if o in ("-h", "--help"):
            printHelp()
            sys.exit(0)
        if o in ("-d", "--domain"):
            dom = a

    print "Domain: " + dom

    domains = dnstwist.calcDomains(dom)

    print json.dumps(domains, indent=4)

    for domain in domains:
        resolveDomain(domains[domain])

    resolveDomainsLongImpl(domains)


if __name__ == "__main__":
    main()