Skip to content

Commit

Permalink
Do not set SERVER_NAME on case of IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 23, 2019
1 parent 590a578 commit 5d981f4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/layman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@

app = Flask(__name__)
app.secret_key = os.environ['FLASK_SECRET_KEY']
if "." in settings.LAYMAN_PROXY_SERVER_NAME:


def _is_ip_address(maybe_ip):
import socket
try:
socket.inet_aton(maybe_ip)
return True
except socket.error:
return False


if "." in settings.LAYMAN_PROXY_SERVER_NAME and not _is_ip_address(settings.LAYMAN_PROXY_SERVER_NAME):
app.config['SERVER_NAME'] = settings.LAYMAN_PROXY_SERVER_NAME


Expand Down

0 comments on commit 5d981f4

Please sign in to comment.