[go: up one dir, main page]

File: dns_lookups.py

package info (click to toggle)
txtorcon 18.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,672 kB
  • sloc: python: 17,521; makefile: 227
file content (20 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from __future__ import print_function

from twisted.internet.task import react
from twisted.internet.defer import inlineCallbacks
from twisted.internet.endpoints import clientFromString
import txtorcon


@react
@inlineCallbacks
def main(reactor):
    control_ep = clientFromString(reactor, "tcp:localhost:9051")
    tor = yield txtorcon.connect(reactor, control_ep)
    for domain in ['torproject.org', 'meejah.ca']:
        print("Looking up '{}' via Tor".format(domain))
        ans = yield tor.dns_resolve(domain)
        print("...got answer: {}".format(ans))
        print("Doing PTR on {}".format(ans))
        ans = yield tor.dns_resolve_ptr(ans)
        print("...got answer: {}".format(ans))