Fix CNAME resolution

front-end-standardization
Eric Holscher 2015-06-23 17:50:03 -07:00
parent fa1279d7ed
commit b1a9f4c5f8
1 changed files with 1 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class SubdomainMiddleware(object):
redis_conn = redis.Redis(**settings.REDIS) redis_conn = redis.Redis(**settings.REDIS)
from dns import resolver from dns import resolver
answer = [ans for ans in resolver.query(host, 'CNAME')][0] answer = [ans for ans in resolver.query(host, 'CNAME')][0]
domain = answer.target.lower().to_unicode() domain = answer.target.to_unicode().lower()
slug = domain.split('.')[0] slug = domain.split('.')[0]
cache.set(host, slug, 60 * 60) cache.set(host, slug, 60 * 60)
# Cache the slug -> host mapping permanently. # Cache the slug -> host mapping permanently.