exit if no website(s) are configured and remove default host
This commit is contained in:
parent
d69bfc2511
commit
e4ad81cde0
@ -167,7 +167,9 @@ def make_app(conf=None, threading=True, multiprocessing=False, uwsgi=False):
|
||||
logger.info("connected to %s", host)
|
||||
break
|
||||
else:
|
||||
logger.warn("unable to connect to %s", ", ".join(conf.getiter("general", "host")))
|
||||
logger.warn("unable to connect to your website, Isso will probably not "
|
||||
"work correctly. Please make sure, Isso can reach your "
|
||||
"website via HTTP(S).")
|
||||
|
||||
wrapper = [local_manager.make_middleware]
|
||||
|
||||
@ -215,6 +217,10 @@ def main():
|
||||
migrate.disqus(db.SQLite3(dbpath, conf), args.dump)
|
||||
sys.exit(0)
|
||||
|
||||
if not any(conf.getiter("general", "host")):
|
||||
logger.error("No website(s) configured, Isso won't work.")
|
||||
sys.exit(1)
|
||||
|
||||
if conf.get("server", "listen").startswith("http://"):
|
||||
host, port, _ = parse.host(conf.get("server", "listen"))
|
||||
try:
|
||||
|
@ -114,7 +114,8 @@ class Config:
|
||||
"[general]",
|
||||
"name = ",
|
||||
"dbpath = /tmp/isso.db",
|
||||
"host = http://localhost:8080/", "max-age = 15m",
|
||||
"host = ",
|
||||
"max-age = 15m",
|
||||
"notify = ",
|
||||
"[moderation]",
|
||||
"enabled = false",
|
||||
|
@ -125,10 +125,18 @@ class JSONResponse(Response):
|
||||
|
||||
|
||||
def origin(hosts):
|
||||
"""
|
||||
Return a function that returns a valid HTTP Origin or localhost
|
||||
if none found.
|
||||
"""
|
||||
|
||||
hosts = [x.rstrip("/") for x in hosts]
|
||||
|
||||
def func(environ):
|
||||
|
||||
if not hosts:
|
||||
return "http://localhost/"
|
||||
|
||||
for host in hosts:
|
||||
if environ.get("HTTP_ORIGIN", None) == host:
|
||||
return host
|
||||
|
Loading…
Reference in New Issue
Block a user