twisted names exception with getHostByName()
Open
Nobody has claimed this yet.
bug
names
new
priority-high
- Dominant language
- Python
- Stars
- 6k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 10
Description
| jonojono reported | |
|---|---|
| Trac ID | trac#8041 |
| Type | defect |
| Created | 2015-10-05 03:45:55Z |
An exception is thrown when using twisted.names.client.getHostByName() on certain hostnames.
An example to reproduce:
# cat dns.py
...
@defer.inlineCallbacks
def test_dns(reactor, domain):
result = yield client.getHostByName(domain, timeout=(1, 2))
print result
if __name__ == '__main__':
task.react(test_dns, sys.argv[1:])
# python dns.py weblogin.umich.edu
main function encountered error
Traceback (most recent call last):
File "/twisted/names/client.py", line 398, in _lookup
d = self.queryUDP([dns.Query(name, type, cls)], timeout)
File "/twisted/names/client.py", line 299, in queryUDP
d = self._query(used, queries, timeout[0])
File "/twisted/names/client.py", line 264, in _query
d = protocol.query(*args)
File "/twisted/names/dns.py", line 2802, in query
return self._query(queries, timeout, id, writeMessage)
--- <exception caught here> ---
File "/twisted/names/dns.py", line 2680, in _query
writeMessage(m)
File "/twisted/names/dns.py", line 2800, in writeMessage
self.writeMessage(m, address)
File "/twisted/names/dns.py", line 2728, in writeMessage
self.transport.write(message.toStr(), address)
File "/twisted/internet/udp.py", line 286, in write
"write() only accepts IP addresses, not hostnames")
twisted.internet.error.InvalidAddressError:
I've observed this exception thrown on hostnames that have both CNAME and A records in the answer section. See the dig output for weblogin.umich.edu:
# dig weblogin.umich.edu
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> weblogin.umich.edu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40349
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;weblogin.umich.edu. IN A
;; ANSWER SECTION:
weblogin.umich.edu. 178 IN CNAME weblogin.dsc.umich.edu.
weblogin.dsc.umich.edu. 1800 IN A 141.211.21.150
weblogin.dsc.umich.edu. 1800 IN A 141.211.7.200
weblogin.dsc.umich.edu. 1800 IN A 141.211.7.210
weblogin.dsc.umich.edu. 1800 IN A 141.211.21.149
;; AUTHORITY SECTION:
dsc.umich.edu. 1800 IN NS dns2.itd.umich.edu.
dsc.umich.edu. 1800 IN NS dns1.itd.umich.edu.
;; Query time: 33 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Mon Oct 5 03:41:39 2015
;; MSG SIZE rcvd: 169
Searchable metadata
trac-id__8041 8041
type__defect defect
reporter__jonojono jonojono
priority__high high
milestone__None None
branch__
branch_author__
status__new new
resolution__None None
component__names names
keywords__None None
time__1444016755835561 1444016755835561
changetime__1460040926788527 1460040926788527
version__None None
owner__pawelmhm pawelmhm
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with twisted/names/client.py around getHostByName() and follow the query and write path through twisted/names/dns.py. Reproduce the failure with the supplied dns.py example and weblogin.umich.edu hostname, then verify that handling an answer containing CNAME and A records no longer raises InvalidAddressError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100