From: Bob Halley Date: Fri, 10 Jul 2020 17:31:41 +0000 (-0700) Subject: add ECS example X-Git-Tag: v2.0.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=858bd95b78429c1f8d3e1c6b902f7445da437c1e;p=thirdparty%2Fdnspython.git add ECS example --- diff --git a/examples/ecs.py b/examples/ecs.py new file mode 100755 index 00000000..f7b31d84 --- /dev/null +++ b/examples/ecs.py @@ -0,0 +1,15 @@ + +import dns.edns +import dns.message +import dns.query + +# This example demonstrates how to use the EDNS client subnet option + +ADDRESS = '0.0.0.0' # replace this with the address you want to check +PREFIX = 0 # replace this with a prefix length (typically 24 for IPv4) + +ecs = dns.edns.ECSOption(ADDRESS, PREFIX) +q = dns.message.make_query('www.google.com', 'A', use_edns=0, options=[ecs]) +r = dns.query.udp(q, '8.8.8.8') +print(r) +