A python module that patches
socket to query a certain DNS
server for SRV records when creating connections.
pip install srv-hijacker
This module exposes exactly one function:
import srv_hijacker srv_hijacker.hijack( host_regex=r'service.consul$', srv_dns_host='127.0.0.1', srv_dns_port=8600 )
Note: Only connections that match the
host_regex are patched. All other
connections are the same as before.
srv_dns_port are optional, if not provided the default
nameservers and ports configured.
make run_consulto boot up a DNS server to test against
Only confirmed to work with Python 3.7. Tests use
requests, which uses
The use case this was designed for is to transparently patch
requests so that
calls to endpoints like
your_service.service.consul hit consul's DNS server
and use the host + port given in the SRV query.