tessl install tessl/pypi-dnslib@0.9.0Simple library to encode/decode DNS wire-format packets
Agent Success
Agent success rate when using this tile
97%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.76x
Baseline
Agent success rate without this tile
55%
Build a custom DNS resolver that returns different IP addresses based on the geographic region of the requester. The resolver should implement region-specific responses with failover support.
Your custom resolver should:
The resolver should accept configuration in this format:
config = {
"service.example.com.": {
"us-east": "192.168.1.10",
"us-west": "192.168.1.20",
"eu": "192.168.1.30",
"default": "192.168.1.1"
},
"api.example.com.": {
"us-east": "192.168.2.10",
"eu": "192.168.2.30",
"default": "192.168.2.1"
}
}For this implementation, simulate region detection by examining the client address from the handler:
@generates
class GeoResolver:
"""
Custom DNS resolver that returns region-specific IP addresses.
Args:
config (dict): Mapping of domains to region-specific IPs
ttl (int, optional): TTL for DNS responses (default: 300)
"""
def __init__(self, config, ttl=300):
"""Initialize the geo resolver with configuration."""
pass
def resolve(self, request, handler):
"""
Resolve DNS query with region-specific response.
Args:
request: DNS query request
handler: Request handler with client information
Returns:
DNS response with appropriate record or NXDOMAIN
"""
pass
def get_region(self, client_address):
"""
Determine region from client address.
Args:
client_address (str): Client IP address
Returns:
str: Region identifier
"""
passProvides DNS protocol support and server framework.