]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add ECS example
authorBob Halley <halley@dnspython.org>
Fri, 10 Jul 2020 17:31:41 +0000 (10:31 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 10 Jul 2020 17:31:56 +0000 (10:31 -0700)
examples/ecs.py [new file with mode: 0755]

diff --git a/examples/ecs.py b/examples/ecs.py
new file mode 100755 (executable)
index 0000000..f7b31d8
--- /dev/null
@@ -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)
+