Return the server address dynamically

master
kaiyou 7 years ago
parent 9e3e86f0d0
commit 5786bb3e1b

@ -1,5 +1,7 @@
from mailu import db, models from mailu import db, models
import socket
SUPPORTED_AUTH_METHODS = ["none", "plain"] SUPPORTED_AUTH_METHODS = ["none", "plain"]
@ -12,6 +14,12 @@ STATUSES = {
} }
SERVER_MAP = {
"imap": ("imap", 143),
"smtp": ("smtp", 25)
}
def handle_authentication(headers): def handle_authentication(headers):
""" Handle an HTTP nginx authentication request """ Handle an HTTP nginx authentication request
See: http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html#protocol See: http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html#protocol
@ -57,8 +65,6 @@ def get_status(protocol, status):
def get_server(protocol): def get_server(protocol):
servers = { hostname, port = SERVER_MAP[protocol]
"imap": ("172.18.0.12", 143), address = socket.gethostbyname(hostname)
"smtp": ("172.18.0.9", 25) return address, port
}
return servers[protocol]

@ -11,4 +11,3 @@ def nginx_authentication():
for key, value in headers.items(): for key, value in headers.items():
response.headers[key] = str(value) response.headers[key] = str(value)
return response return response

Loading…
Cancel
Save