Return the server address dynamically

master
kaiyou 7 years ago
parent 9e3e86f0d0
commit 5786bb3e1b

@ -1,5 +1,7 @@
from mailu import db, models
import socket
SUPPORTED_AUTH_METHODS = ["none", "plain"]
@ -12,6 +14,12 @@ STATUSES = {
}
SERVER_MAP = {
"imap": ("imap", 143),
"smtp": ("smtp", 25)
}
def handle_authentication(headers):
""" Handle an HTTP nginx authentication request
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):
servers = {
"imap": ("172.18.0.12", 143),
"smtp": ("172.18.0.9", 25)
}
return servers[protocol]
hostname, port = SERVER_MAP[protocol]
address = socket.gethostbyname(hostname)
return address, port

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

Loading…
Cancel
Save