コード例 #1
0
ファイル: dns_scraper.py プロジェクト: ralphholz/dns-scraper
def getRrData(rr, section=ldns.LDNS_SECTION_ANSWER):
	"""Return RR bytes as pythonic string from ldns_rr."""
	l = rr.uncompressed_size()
	buf = ldns.ldns_buffer(l)
	rr.write_to_buffer_canonical(buf, section)
	
	return getLdnsBufferData(buf, l)
コード例 #2
0
ファイル: dns_scraper.py プロジェクト: ralphholz/dns-scraper
def getRdfData(rdf):
	"""Return RDF bytes as pythonic string from ldns_rdf.
	If rdf is None, returns None.
	"""
	if rdf is None:
		return None
	l = rdf.size()
	buf = ldns.ldns_buffer(l)
	rdf.write_to_buffer_canonical(buf)
	
	return getLdnsBufferData(buf, l)
コード例 #3
0
    method_name = class_name + ".reverse()"
    dn = ldns.ldns_dname("www.nic.cz.")
    try:
        ret = dn.reverse()
        if not isinstance(ret, ldns.ldns_dname):
            set_error()
        if ret.__str__() != "cz.nic.www.":
            set_error()
    except:
        set_error()

#if not error_detected:
if True:
    method_name = class_name + ".write_to_buffer()"
    dn = ldns.ldns_dname("www.nic.cz.")
    buf = ldns.ldns_buffer(1024)
    try:
        ret = dn.write_to_buffer(buf)
        if ret != ldns.LDNS_STATUS_OK:
            set_error()
        if buf.position() != 12:
            set_error()
    except:
        set_error()
    try:
        ret = dn.write_to_buffer("")
    except TypeError:
        pass
    except:
        set_error()
コード例 #4
0
#!/usr/bin/python

import ldns

buf = ldns.ldns_buffer(1024)
buf.printf("Test buffer")
print buf

コード例 #5
0
    global class_name
    global method_name
    global error_detected
    error_detected = True
    sys.stderr.write("(line %d): malfunctioning method %s.\n" % \
       (inspect.currentframe().f_back.f_lineno, method_name))


# Buffer creation.
capacity = 1024

#if not error_detected:
if True:
    method_name = "ldns_buffer.__init__()"
    try:
        buf = ldns.ldns_buffer(1024)
    except:
        set_error()

#if not error_detected:
if True:
    method_name = "ldns_buffer.__str__()"
    buf.printf("abcedf")
    try:
        string = buf.__str__()
    except:
        set_error()
    if not isinstance(string, str):
        # Should be string.
        set_error()
    buf.clear()
コード例 #6
0
ファイル: test_buffer.py プロジェクト: ericjpj/DNSquery
    """
    global class_name
    global method_name
    global error_detected
    error_detected = True
    sys.stderr.write("(line %d): malfunctioning method %s.\n" % (inspect.currentframe().f_back.f_lineno, method_name))


# Buffer creation.
capacity = 1024

# if not error_detected:
if True:
    method_name = "ldns_buffer.__init__()"
    try:
        buf = ldns.ldns_buffer(1024)
    except:
        set_error()


# if not error_detected:
if True:
    method_name = "ldns_buffer.__str__()"
    buf.printf("abcedf")
    try:
        string = buf.__str__()
    except:
        set_error()
    if not isinstance(string, str):
        # Should be string.
        set_error()
コード例 #7
0
ファイル: test_pkt.py プロジェクト: benlaurie/ldns
        set_error()
    pkt.update_set_zo(127)
    try:
        ret = pkt.update_zocount()
        if (not isinstance(ret, int)) and (not isinstance(ret, long)):
            set_error()
        if ret != 127:
            set_error()
    except:
        set_error()


#if not error_detected:
if True:
    method_name = class_name + ".write_to_buffer()"
    pkt = pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
    buf = buf = ldns.ldns_buffer(4096)
    try:
        ret = pkt.write_to_buffer(buf)
        if ret != ldns.LDNS_STATUS_OK:
            set_error()
    except:
        set_error()


if not error_detected:
    sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__)))
else:
    sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__)))
    sys.exit(1)