Commit b6548908 authored by Mio Iwakura's avatar Mio Iwakura

Nightly

parent 67968ac4
......@@ -55,9 +55,6 @@ immutable struct Vars
int PROJECT_NAME_LEN = 128;
int PROJECT_DESCRIPTION_LEN = 4096;
}
HTTPListener httpsListener;
URLRouter httpsRouter;
HTTPServerSettings httpsSettings;
Vars vars;
void main()
{
......@@ -66,35 +63,33 @@ void main()
import etc.linux.memoryerror;
static if (is (typeof (registerMemoryErrorHandler)))
registerMemoryErrorHandler();
import core.sys.posix.signal : SIGUSR1;
import eventcore.core;
eventDriver.signals.listen(SIGUSR1,
(id, status, sig){
logInfo("SIGUSR1 - reloading certs...");
reloadCerts();
});
}
/* version (OSX) */
/* { */
/* //@NOTE: vibe.d doesn't support signals on OSX because it sucks */
/* //@NOTE: ...but why are you running an OSX server in the first place??? */
/* setTimer(0.5.days, toDelegate(&reloadCerts), true); */
/* } */
auto httpSettings = new HTTPServerSettings;
httpSettings.port = http_port;
debug httpSettings.bindAddresses = ["::1", "127.0.0.1"];
httpsSettings = httpSettings.dup;
auto httpsSettings = httpSettings.dup;
httpsSettings.port = https_port;
httpsSettings.tlsContext = createTLSContext(TLSContextKind.server, TLSVersion.tls1_2);
httpsSettings.tlsContext.setCipherList(ciphers);
httpsSettings.tlsContext.setDHParams(dhparam_path);
httpsRouter = new URLRouter;
auto httpsRouter = new URLRouter;
httpsRouter.registerWebInterface(new WebInterface);
httpsRouter.get("*", serveStaticFiles("public/"));
reloadCerts();
HTTPListener httpsListener;
try
{
httpsSettings.tlsContext.useCertificateChainFile(
certificate_chain_path.findCert);
httpsSettings.tlsContext.usePrivateKeyFile(
private_key_path.findCert);
httpsListener = listenHTTP(httpsSettings, httpsRouter);
}
catch (Exception e)
{
logInfo(e.msg);
}
scope (exit) httpsListener.stopListening();
auto httpRouter = new URLRouter;
httpRouter.any("/.well_known/acme-challenge/*", serveStaticFiles("public/"));
httpRouter.any("*", staticRedirect(https_domain, HTTPStatus.movedPermanently));
auto httpListener = listenHTTP(httpSettings, httpRouter);
scope (exit) httpListener.stopListening();
......@@ -416,22 +411,6 @@ class WebInterface
}
}
}
void reloadCerts() nothrow @safe
{
auto certificate_chain = certificate_chain_path.findCert;
auto private_key = private_key_path.findCert;
try
{
httpsSettings.tlsContext.useCertificateChainFile(certificate_chain);
httpsSettings.tlsContext.usePrivateKeyFile(private_key);
httpsListener.stopListening();
httpsListener = listenHTTP(httpsSettings, httpsRouter);
}
catch (Exception e)
{
logInfo(e.msg);
}
}
string findCert(string cert) nothrow @safe
{
try
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment