Example #1
0
    def test_lookupServerViaSRV(self):
        """
        Test L{lookupServerViaSRV} with a local Bind find
        """

        # Patch config
        for zonefile, checks in (
            ("db.example.com", (("example.com", "example.com", 8443,),),),
            ("db.two.zones", (
                ("example.com", "example.com", 8443,),
                ("example.org", "example.org", 8543,),
            ),),
            ("db.empty.zone", (("example.com", "", 0,),),),
        ):
            module = getModule(__name__)
            dataPath = module.filePath.sibling("data")
            bindPath = dataPath.child(zonefile)
            self.patch(config.Scheduling.iSchedule, "DNSDebug", bindPath.path)
            utils.DebugResolver = None

            for domain, result_host, result_port in checks:
                result = (yield utils.lookupServerViaSRV(domain))
                if result is None:
                    host = ""
                    port = 0
                else:
                    host, port = result
                self.assertEqual(host, result_host)
                self.assertEqual(port, result_port)
Example #2
0
    def _getURI(self):
        """
        Determine the well-known URI for the public key service.
        """

        # First we do an SRV lookup for _domainkey to get the public key server host/port
        result = (yield lookupServerViaSRV(self.dkim_tags["d"],
                                           service="_domainkey_lookup"))
        if result is None:
            log.debug(
                "DKIM: SRV _domainkey failed on: {tag} trying domain directly",
                tag=self.dkim_tags["d"])
            host = self.dkim_tags["d"]
            port = ""
            scheme = "https"
        else:
            host, port = result
            scheme = "http" if port in (
                80,
                8008,
                8080,
            ) else "https"
            if port == 80 and scheme == "http" or port == 443 and scheme == "https":
                port = ""
            else:
                port = ":%s" % (port, )

        returnValue("%s://%s%s/.well-known/domainkey/%s/%s" % (
            scheme,
            host,
            port,
            self.dkim_tags["d"],
            self.dkim_tags["s"],
        ))
Example #3
0
    def test_lookupServerViaSRV(self):
        """
        Test L{lookupServerViaSRV} with a local Bind find
        """

        # Patch config
        for zonefile, checks in (
            (
                "db.example.com",
                ((
                    "example.com",
                    "example.com",
                    8443,
                ), ),
            ),
            (
                "db.two.zones",
                (
                    (
                        "example.com",
                        "example.com",
                        8443,
                    ),
                    (
                        "example.org",
                        "example.org",
                        8543,
                    ),
                ),
            ),
            (
                "db.empty.zone",
                ((
                    "example.com",
                    "",
                    0,
                ), ),
            ),
        ):
            module = getModule(__name__)
            dataPath = module.filePath.sibling("data")
            bindPath = dataPath.child(zonefile)
            self.patch(config.Scheduling.iSchedule, "DNSDebug", bindPath.path)
            utils.DebugResolver = None

            for domain, result_host, result_port in checks:
                result = (yield utils.lookupServerViaSRV(domain))
                if result is None:
                    host = ""
                    port = 0
                else:
                    host, port = result
                self.assertEqual(host, result_host)
                self.assertEqual(port, result_port)
Example #4
0
    def _getURI(self):
        """
        Determine the well-known URI for the public key service.
        """

        # First we do an SRV lookup for _domainkey to get the public key server host/port
        result = (yield lookupServerViaSRV(self.dkim_tags["d"], service="_domainkey_lookup"))
        if result is None:
            log.debug("DKIM: SRV _domainkey failed on: %s trying domain directly" % (self.dkim_tags["d"],))
            host = self.dkim_tags["d"]
            port = ""
            scheme = "https"
        else:
            host, port = result
            scheme = "http" if port in (80, 8008, 8080,) else "https"
            if port == 80 and scheme == "http" or port == 443 and scheme == "https":
                port = ""
            else:
                port = ":%s" % (port,)

        returnValue("%s://%s%s/.well-known/domainkey/%s/%s" % (scheme, host, port, self.dkim_tags["d"], self.dkim_tags["s"],))