当前位置: 首页>>代码示例>>Python>>正文


Python dns.name方法代码示例

本文整理汇总了Python中dns.name方法的典型用法代码示例。如果您正苦于以下问题:Python dns.name方法的具体用法?Python dns.name怎么用?Python dns.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dns的用法示例。


在下文中一共展示了dns.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: before_request

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def before_request():
    # Check if user is anonymous
    g.user = current_user
    login_manager.anonymous_user = Anonymous

    # Check site is in maintenance mode
    maintenance = Setting().get('maintenance')
    if maintenance and current_user.is_authenticated and current_user.role.name not in [
            'Administrator', 'Operator'
    ]:
        return render_template('maintenance.html')

    # Manage session timeout
    session.permanent = True
    current_app.permanent_session_lifetime = datetime.timedelta(
        minutes=int(Setting().get('session_timeout')))
    session.modified = True 
开发者ID:ngoduykhanh,项目名称:PowerDNS-Admin,代码行数:19,代码来源:domain.py

示例2: _hostname_matches_additional

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def _hostname_matches_additional(self, ip, name, additional):
		"""
		Search for *name* in *additional* and if it is found, check that it
		includes *ip*.

		:param ip: The IP address to search for.
		:type ip: :py:class:`ipaddress.IPv4Address`, :py:class:`ipaddress.IPv6Address`
		:param str name: The name to search for.
		:param tuple additional: The additional data returned from a dns query to search in.
		:return: The first value is whether or not *name* was found in *additional*, the second is if *ip* was also found.
		:rtype: tuple
		"""
		rdtype = (1 if isinstance(ip, ipaddress.IPv4Address) else 28)
		ip = str(ip)
		additional = (entry for entry in additional if entry.rdtype == rdtype)
		entry = next((entry for entry in additional if str(entry.name)[:-1] == name), None)
		if entry is None:
			return False, None
		item = next((item for item in entry.items if item.address == ip), None)
		return True, item is not None 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:22,代码来源:spf.py

示例3: get_iana_protocols

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def get_iana_protocols():
    """Parse the local file of IANA IP protocols and return a dictionary of protocol number to name.

    :rtype:dict[int,str]
    """
    os_dist = platform.system()
    if os_dist == "Linux":
        protocols_file_path = "/etc/protocols"
    elif os_dist == "Windows":
        protocols_file_path = "C:\\windows\\system32\\etc\\protocols"
    else:
        raise TypeError("Unsupported OS '{}'".format(os_dist))
    protocols = {}
    with open(protocols_file_path) as services_file:
        for line in services_file.readlines():
            if not line.startswith("#") and not line.isspace():
                _, protocol_number, protocol_name, *_ = line.split()
                protocols[int(protocol_number)] = protocol_name
    return protocols 
开发者ID:Tufin,项目名称:pytos,代码行数:21,代码来源:network.py

示例4: get_zone_name

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def get_zone_name(domain):
    zones = get_all_zones()

    zone_name = ""

    for z in zones:
        if domain.endswith(z.name):
            # Find the most specific zone possible for the domain
            # Ex: If fqdn is a.b.c.com, there is a zone for c.com,
            # and a zone for b.c.com, we want to use b.c.com.
            if z.name.count(".") > zone_name.count("."):
                zone_name = z.name
    if not zone_name:
        metrics.send("dyn_no_zone_name", "counter", 1)
        raise Exception("No Dyn zone found for domain: {}".format(domain))
    return zone_name 
开发者ID:Netflix,项目名称:lemur,代码行数:18,代码来源:dyn.py

示例5: absent

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def absent(self, name, rdtype=None):
        """Require that an owner name (and optionally an rdata type) does
        not exist as a prerequisite to the execution of the update."""

        if isinstance(name, string_types):
            name = dns.name.from_text(name, None)
        if rdtype is None:
            self.find_rrset(self.answer, name,
                            dns.rdataclass.NONE, dns.rdatatype.ANY,
                            dns.rdatatype.NONE, None,
                            True, True)
        else:
            if isinstance(rdtype, string_types):
                rdtype = dns.rdatatype.from_text(rdtype)
            self.find_rrset(self.answer, name,
                            dns.rdataclass.NONE, rdtype,
                            dns.rdatatype.NONE, None,
                            True, True) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:20,代码来源:update.py

示例6: from_wire

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
        (mname, cused) = dns.name.from_wire(wire[: current + rdlen], current)
        current += cused
        rdlen -= cused
        (rname, cused) = dns.name.from_wire(wire[: current + rdlen], current)
        current += cused
        rdlen -= cused
        if rdlen != 20:
            raise dns.exception.FormError
        five_ints = struct.unpack('!IIIII',
                                  wire[current: current + rdlen])
        if origin is not None:
            mname = mname.relativize(origin)
            rname = rname.relativize(origin)
        return cls(rdclass, rdtype, mname, rname,
                   five_ints[0], five_ints[1], five_ints[2], five_ints[3],
                   five_ints[4]) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:19,代码来源:SOA.py

示例7: get_deepest_match

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def get_deepest_match(self, name):
        """Find the deepest match to I{name} in the dictionary.

        The deepest match is the longest name in the dictionary which is
        a superdomain of I{name}.

        @param name: the name
        @type name: dns.name.Name object
        @rtype: (key, value) tuple
        """

        depth = len(name)
        if depth > self.max_depth:
            depth = self.max_depth
        for i in xrange(-depth, 0):
            n = dns.name.Name(name[i:])
            if n in self:
                return (n, self[n])
        v = self[dns.name.empty]
        return (dns.name.empty, v) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:22,代码来源:namedict.py

示例8: to_text

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def to_text(self, origin=None, relativize=True, **kw):
        """Convert the RRset into DNS master file format.

        @see: L{dns.name.Name.choose_relativity} for more information
        on how I{origin} and I{relativize} determine the way names
        are emitted.

        Any additional keyword arguments are passed on to the rdata
        to_text() method.

        @param origin: The origin for relative names, or None.
        @type origin: dns.name.Name object
        @param relativize: True if names should names be relativized
        @type relativize: bool"""

        return super(RRset, self).to_text(self.name, origin, relativize,
                                          self.deleting, **kw) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:19,代码来源:rrset.py

示例9: from_text_list

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_text_list(name, ttl, rdclass, rdtype, text_rdatas,
                   idna_codec=None):
    """Create an RRset with the specified name, TTL, class, and type, and with
    the specified list of rdatas in text format.

    @rtype: dns.rrset.RRset object
    """

    if isinstance(name, string_types):
        name = dns.name.from_text(name, None, idna_codec=idna_codec)
    if isinstance(rdclass, string_types):
        rdclass = dns.rdataclass.from_text(rdclass)
    if isinstance(rdtype, string_types):
        rdtype = dns.rdatatype.from_text(rdtype)
    r = RRset(name, rdclass, rdtype)
    r.update_ttl(ttl)
    for t in text_rdatas:
        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t)
        r.add(rd)
    return r 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:22,代码来源:rrset.py

示例10: from_rdata_list

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_rdata_list(name, ttl, rdatas, idna_codec=None):
    """Create an RRset with the specified name and TTL, and with
    the specified list of rdata objects.

    @rtype: dns.rrset.RRset object
    """

    if isinstance(name, string_types):
        name = dns.name.from_text(name, None, idna_codec=idna_codec)

    if len(rdatas) == 0:
        raise ValueError("rdata list must not be empty")
    r = None
    for rd in rdatas:
        if r is None:
            r = RRset(name, rd.rdclass, rd.rdtype)
            r.update_ttl(ttl)
        r.add(rd)
    return r 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:21,代码来源:rrset.py

示例11: absent

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def absent(self, name, rdtype=None):
        """Require that an owner name (and optionally an rdata type) does
        not exist as a prerequisite to the execution of the update."""

        if isinstance(name, (str, unicode)):
            name = dns.name.from_text(name, None)
        if rdtype is None:
            rrset = self.find_rrset(self.answer, name,
                                    dns.rdataclass.NONE, dns.rdatatype.ANY,
                                    dns.rdatatype.NONE, None,
                                    True, True)
        else:
            if isinstance(rdtype, (str, unicode)):
                rdtype = dns.rdatatype.from_text(rdtype)
            rrset = self.find_rrset(self.answer, name,
                                    dns.rdataclass.NONE, rdtype,
                                    dns.rdatatype.NONE, None,
                                    True, True) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:20,代码来源:update.py

示例12: from_wire

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
        (mname, cused) = dns.name.from_wire(wire[: current + rdlen], current)
        current += cused
        rdlen -= cused
        (rname, cused) = dns.name.from_wire(wire[: current + rdlen], current)
        current += cused
        rdlen -= cused
        if rdlen != 20:
            raise dns.exception.FormError
        five_ints = struct.unpack('!IIIII',
                                  wire[current : current + rdlen])
        if not origin is None:
            mname = mname.relativize(origin)
            rname = rname.relativize(origin)
        return cls(rdclass, rdtype, mname, rname,
                   five_ints[0], five_ints[1], five_ints[2], five_ints[3],
                   five_ints[4]) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:19,代码来源:SOA.py

示例13: get_deepest_match

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def get_deepest_match(self, name):
        """Find the deepest match to I{name} in the dictionary.

        The deepest match is the longest name in the dictionary which is
        a superdomain of I{name}.

        @param name: the name
        @type name: dns.name.Name object
        @rtype: (key, value) tuple
        """

        depth = len(name)
        if depth > self.max_depth:
            depth = self.max_depth
        for i in xrange(-depth, 0):
            n = dns.name.Name(name[i:])
            if self.has_key(n):
                return (n, self[n])
        v = self[dns.name.empty]
        return (dns.name.empty, v) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:22,代码来源:namedict.py

示例14: from_text_list

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_text_list(name, ttl, rdclass, rdtype, text_rdatas):
    """Create an RRset with the specified name, TTL, class, and type, and with
    the specified list of rdatas in text format.

    @rtype: dns.rrset.RRset object
    """

    if isinstance(name, (str, unicode)):
        name = dns.name.from_text(name, None)
    if isinstance(rdclass, (str, unicode)):
        rdclass = dns.rdataclass.from_text(rdclass)
    if isinstance(rdtype, (str, unicode)):
        rdtype = dns.rdatatype.from_text(rdtype)
    r = RRset(name, rdclass, rdtype)
    r.update_ttl(ttl)
    for t in text_rdatas:
        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t)
        r.add(rd)
    return r 
开发者ID:blackye,项目名称:luscan-devel,代码行数:21,代码来源:rrset.py

示例15: from_rdata_list

# 需要导入模块: import dns [as 别名]
# 或者: from dns import name [as 别名]
def from_rdata_list(name, ttl, rdatas):
    """Create an RRset with the specified name and TTL, and with
    the specified list of rdata objects.

    @rtype: dns.rrset.RRset object
    """

    if isinstance(name, (str, unicode)):
        name = dns.name.from_text(name, None)

    if len(rdatas) == 0:
        raise ValueError("rdata list must not be empty")
    r = None
    for rd in rdatas:
        if r is None:
            r = RRset(name, rd.rdclass, rd.rdtype)
            r.update_ttl(ttl)
            first_time = False
        r.add(rd)
    return r 
开发者ID:blackye,项目名称:luscan-devel,代码行数:22,代码来源:rrset.py


注:本文中的dns.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。