def hostname(self, request: IRequest, name: str) -> KleinRenderable:
"""
Hostname lookup resource.
Performs a lookup on the given name and responds with the resulting
address.
:param request: The request to respond to.
:param name: A host name.
"""
try:
address = await getHostByName(name)
except DNSNameError:
request.setResponseCode(http.NOT_FOUND)
return "no such host"
except DNSLookupError:
request.setResponseCode(http.NOT_FOUND)
return "lookup error"
return address
评论列表
文章目录