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)
|
logger.info("connected to %s", host)
|
||||||
break
|
break
|
||||||
else:
|
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]
|
wrapper = [local_manager.make_middleware]
|
||||||
|
|
||||||
@ -215,6 +217,10 @@ def main():
|
|||||||
migrate.disqus(db.SQLite3(dbpath, conf), args.dump)
|
migrate.disqus(db.SQLite3(dbpath, conf), args.dump)
|
||||||
sys.exit(0)
|
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://"):
|
if conf.get("server", "listen").startswith("http://"):
|
||||||
host, port, _ = parse.host(conf.get("server", "listen"))
|
host, port, _ = parse.host(conf.get("server", "listen"))
|
||||||
try:
|
try:
|
||||||
|
@ -114,7 +114,8 @@ class Config:
|
|||||||
"[general]",
|
"[general]",
|
||||||
"name = ",
|
"name = ",
|
||||||
"dbpath = /tmp/isso.db",
|
"dbpath = /tmp/isso.db",
|
||||||
"host = http://localhost:8080/", "max-age = 15m",
|
"host = ",
|
||||||
|
"max-age = 15m",
|
||||||
"notify = ",
|
"notify = ",
|
||||||
"[moderation]",
|
"[moderation]",
|
||||||
"enabled = false",
|
"enabled = false",
|
||||||
|
@ -125,10 +125,18 @@ class JSONResponse(Response):
|
|||||||
|
|
||||||
|
|
||||||
def origin(hosts):
|
def origin(hosts):
|
||||||
|
"""
|
||||||
|
Return a function that returns a valid HTTP Origin or localhost
|
||||||
|
if none found.
|
||||||
|
"""
|
||||||
|
|
||||||
hosts = [x.rstrip("/") for x in hosts]
|
hosts = [x.rstrip("/") for x in hosts]
|
||||||
|
|
||||||
def func(environ):
|
def func(environ):
|
||||||
|
|
||||||
|
if not hosts:
|
||||||
|
return "http://localhost/"
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
if environ.get("HTTP_ORIGIN", None) == host:
|
if environ.get("HTTP_ORIGIN", None) == host:
|
||||||
return host
|
return host
|
||||||
|
Loading…
Reference in New Issue
Block a user