|
Revision 11102, 0.7 kB
(checked in by dave, 3 months ago)
|
|
python sample implementation of BEP-25.
|
| Line | |
|---|
| 1 | # Uses PyDNS. |
|---|
| 2 | |
|---|
| 3 | import DNS |
|---|
| 4 | |
|---|
| 5 | #req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="10.211.55.3" ) |
|---|
| 6 | #req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="127.0.0.1" ) |
|---|
| 7 | #req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="localhost" ) |
|---|
| 8 | #print "www.google.com: ", req.req().show() |
|---|
| 9 | |
|---|
| 10 | tlds = ["com", "net", "org"] # add more here. |
|---|
| 11 | |
|---|
| 12 | name = DNS.revlookup( "77.46.197.147" ) |
|---|
| 13 | names = name.split('.') |
|---|
| 14 | while names and names[0] not in tlds: |
|---|
| 15 | name = "_bittorrent._tcp." + ".".join(names) |
|---|
| 16 | req = DNS.Request( name=name, qtype="SRV", protocol="udp", server="localhost") |
|---|
| 17 | response = req.req() |
|---|
| 18 | if response.answers: |
|---|
| 19 | break |
|---|
| 20 | del names[0] |
|---|
| 21 | |
|---|
| 22 | print "response=", response.show() |
|---|
| 23 | |
|---|