Loading data/serverconfig.js +12 −3 Changes for data/serverconfig.js: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,9 @@ var ServerConfig = (function() { { key: "BIND", label: "Bind address", hint: "0.0.0.0 = all interfaces" }, { key: "PORT", label: "Port", type: "number", def: "9090" }, { key: "MAXCONN", label: "Max. connections", type: "number" }, { key: "SSL/CERT", label: "TLS certificate", hint: "optional, a file below the config directory" }, { key: "SSL/KEY", label: "TLS key", hint: "optional, a file below the config directory" } { key: "SSL/CERT", label: "TLS certificate", hint: "a file below the config directory, generated if missing; both empty = plain http" }, { key: "SSL/KEY", label: "TLS key", hint: "a file below the config directory, generated if missing" } ]}, { title: "Domain controller", fields: [ { key: "DNS/HOSTNAME", label: "DC host name", hint: "e.g. dc1.example.com" }, Loading Loading @@ -171,8 +172,16 @@ var ServerConfig = (function() { /* polls url until the restarted server answers, then opens it */ function waitFor(url, onStatus) { var tries = 0; /* a certificate the browser doesn't trust fails a fetch just like a * server that is still down, and http from an https page is blocked: * then the browser gets the address after the restart's time */ var blind = url.indexOf("https:") === 0 || url.indexOf(window.location.protocol) !== 0; function attempt() { if (++tries > 60) { if (blind && ++tries >= 4) { window.location.href = url; return; } if (!blind && ++tries > 60) { onStatus("The server did not come back. Check the log and open " + url + " by hand.", true); return; } Loading src/confhelper.cpp +20 −2 Changes for src/confhelper.cpp: 20 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <memory> #include <mutex> #include <map> #include <algorithm> #include <cstring> #include <cerrno> #include <cctype> Loading Loading @@ -175,9 +176,13 @@ namespace fenrirds::confhelper { return d == std::string::npos ? "yaml" : spec.substr(0, d); } /* yaml://etc/x is /etc/x: certificate paths are compared with it */ std::string specPath(const std::string &spec) { size_t d = spec.find(':'); return d == std::string::npos ? spec : spec.substr(d + 1); std::string path = d == std::string::npos ? spec : spec.substr(d + 1); path.erase(std::unique(path.begin(), path.end(), [](char a, char b) { return a == '/' && b == '/'; }), path.end()); return path; } std::string parentDir(const std::string &path) { Loading Loading @@ -243,8 +248,10 @@ namespace fenrirds::confhelper { /* certificates must live next to the config file; the server reads * them while still root */ bool isCertPath(const std::string &v, const std::string &confDir, std::string &err) { size_t skip = v.find_first_not_of('/'); // a config may say //etc/x std::string plain = skip == std::string::npos || skip == 0 ? v : v.substr(skip - 1); if (!printable(v, 1024) || v[0] != '/' || v.find("/..") != std::string::npos || v.compare(0, confDir.size() + 1, confDir + "/") != 0) { || plain.compare(0, confDir.size() + 1, confDir + "/") != 0) { err = "certificate paths must be below " + confDir + "/"; return false; } Loading Loading @@ -475,6 +482,13 @@ namespace fenrirds::confhelper { json_object_object_add(jvals, f.key, json_object_new_string(vals[0].c_str())); } } /* only what the wizard offers, not the template: a node that * joins through set() takes TLS from its master */ if (!cf.exists()) { std::string dir = parentDir(specPath(spec)); json_object_object_add(jvals, "SSL/CERT", json_object_new_string((dir + "/cert.pem").c_str())); json_object_object_add(jvals, "SSL/KEY", json_object_new_string((dir + "/key.pem").c_str())); } json_object_object_add(jres, "ok", json_object_new_boolean(true)); json_object_object_add(jres, "exists", json_object_new_boolean(cf.exists())); json_object_object_add(jres, "path", json_object_new_string(specPath(spec).c_str())); Loading Loading @@ -966,6 +980,10 @@ namespace fenrirds::confhelper { #endif } std::string primaryAddress() { return firstAddress(); } bool available() { return g_fd >= 0; } Loading src/confhelper.h +3 −0 Changes for src/confhelper.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -59,6 +59,9 @@ namespace fenrirds::confhelper { /* true in the server once start() forked the helper */ bool available(); /* the first address other machines reach this one on, 0.0.0.0 if none */ std::string primaryAddress(); /* true if the config file named by the spec ("yaml:/etc/...") exists */ bool configExists(const std::string &configSpec); Loading src/fenrirds.cpp +8 −1 Changes for src/fenrirds.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -908,7 +908,7 @@ namespace fenrirds { static int runSetup(const std::string &bind, int port){ std::cerr << "[FENRIRDS] no config file: setup wizard on http://" << bind << ":" << port << "/" << std::endl; << (bind == "0.0.0.0" ? confhelper::primaryAddress() : bind) << ":" << port << "/" << std::endl; if (!confhelper::available()) std::cerr << "[FENRIRDS] config helper not running, the setup can't save" << std::endl; libhttppp::HttpD httpd(bind, port, 64, "", "", ""); Loading Loading @@ -1223,6 +1223,13 @@ int main(int argc,char *argv[]){ ); } { std::string addr = config.getValue(cfgKey("/BIND"), 0); std::cerr << "[FENRIRDS] web interface on " << (!cert.empty() && !key.empty() ? "https://" : "http://") << (addr == "0.0.0.0" ? fenrirds::confhelper::primaryAddress() : addr) << ":" << config.getIntValue(cfgKey("/PORT"), 0) << "/" << std::endl; } /* Start cluster while still root so QUIC can bind privileged ports */ if (clusterEnabled) { cluster.init(ccfg); Loading Loading
data/serverconfig.js +12 −3 Changes for data/serverconfig.js: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,9 @@ var ServerConfig = (function() { { key: "BIND", label: "Bind address", hint: "0.0.0.0 = all interfaces" }, { key: "PORT", label: "Port", type: "number", def: "9090" }, { key: "MAXCONN", label: "Max. connections", type: "number" }, { key: "SSL/CERT", label: "TLS certificate", hint: "optional, a file below the config directory" }, { key: "SSL/KEY", label: "TLS key", hint: "optional, a file below the config directory" } { key: "SSL/CERT", label: "TLS certificate", hint: "a file below the config directory, generated if missing; both empty = plain http" }, { key: "SSL/KEY", label: "TLS key", hint: "a file below the config directory, generated if missing" } ]}, { title: "Domain controller", fields: [ { key: "DNS/HOSTNAME", label: "DC host name", hint: "e.g. dc1.example.com" }, Loading Loading @@ -171,8 +172,16 @@ var ServerConfig = (function() { /* polls url until the restarted server answers, then opens it */ function waitFor(url, onStatus) { var tries = 0; /* a certificate the browser doesn't trust fails a fetch just like a * server that is still down, and http from an https page is blocked: * then the browser gets the address after the restart's time */ var blind = url.indexOf("https:") === 0 || url.indexOf(window.location.protocol) !== 0; function attempt() { if (++tries > 60) { if (blind && ++tries >= 4) { window.location.href = url; return; } if (!blind && ++tries > 60) { onStatus("The server did not come back. Check the log and open " + url + " by hand.", true); return; } Loading
src/confhelper.cpp +20 −2 Changes for src/confhelper.cpp: 20 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <memory> #include <mutex> #include <map> #include <algorithm> #include <cstring> #include <cerrno> #include <cctype> Loading Loading @@ -175,9 +176,13 @@ namespace fenrirds::confhelper { return d == std::string::npos ? "yaml" : spec.substr(0, d); } /* yaml://etc/x is /etc/x: certificate paths are compared with it */ std::string specPath(const std::string &spec) { size_t d = spec.find(':'); return d == std::string::npos ? spec : spec.substr(d + 1); std::string path = d == std::string::npos ? spec : spec.substr(d + 1); path.erase(std::unique(path.begin(), path.end(), [](char a, char b) { return a == '/' && b == '/'; }), path.end()); return path; } std::string parentDir(const std::string &path) { Loading Loading @@ -243,8 +248,10 @@ namespace fenrirds::confhelper { /* certificates must live next to the config file; the server reads * them while still root */ bool isCertPath(const std::string &v, const std::string &confDir, std::string &err) { size_t skip = v.find_first_not_of('/'); // a config may say //etc/x std::string plain = skip == std::string::npos || skip == 0 ? v : v.substr(skip - 1); if (!printable(v, 1024) || v[0] != '/' || v.find("/..") != std::string::npos || v.compare(0, confDir.size() + 1, confDir + "/") != 0) { || plain.compare(0, confDir.size() + 1, confDir + "/") != 0) { err = "certificate paths must be below " + confDir + "/"; return false; } Loading Loading @@ -475,6 +482,13 @@ namespace fenrirds::confhelper { json_object_object_add(jvals, f.key, json_object_new_string(vals[0].c_str())); } } /* only what the wizard offers, not the template: a node that * joins through set() takes TLS from its master */ if (!cf.exists()) { std::string dir = parentDir(specPath(spec)); json_object_object_add(jvals, "SSL/CERT", json_object_new_string((dir + "/cert.pem").c_str())); json_object_object_add(jvals, "SSL/KEY", json_object_new_string((dir + "/key.pem").c_str())); } json_object_object_add(jres, "ok", json_object_new_boolean(true)); json_object_object_add(jres, "exists", json_object_new_boolean(cf.exists())); json_object_object_add(jres, "path", json_object_new_string(specPath(spec).c_str())); Loading Loading @@ -966,6 +980,10 @@ namespace fenrirds::confhelper { #endif } std::string primaryAddress() { return firstAddress(); } bool available() { return g_fd >= 0; } Loading
src/confhelper.h +3 −0 Changes for src/confhelper.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -59,6 +59,9 @@ namespace fenrirds::confhelper { /* true in the server once start() forked the helper */ bool available(); /* the first address other machines reach this one on, 0.0.0.0 if none */ std::string primaryAddress(); /* true if the config file named by the spec ("yaml:/etc/...") exists */ bool configExists(const std::string &configSpec); Loading
src/fenrirds.cpp +8 −1 Changes for src/fenrirds.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -908,7 +908,7 @@ namespace fenrirds { static int runSetup(const std::string &bind, int port){ std::cerr << "[FENRIRDS] no config file: setup wizard on http://" << bind << ":" << port << "/" << std::endl; << (bind == "0.0.0.0" ? confhelper::primaryAddress() : bind) << ":" << port << "/" << std::endl; if (!confhelper::available()) std::cerr << "[FENRIRDS] config helper not running, the setup can't save" << std::endl; libhttppp::HttpD httpd(bind, port, 64, "", "", ""); Loading Loading @@ -1223,6 +1223,13 @@ int main(int argc,char *argv[]){ ); } { std::string addr = config.getValue(cfgKey("/BIND"), 0); std::cerr << "[FENRIRDS] web interface on " << (!cert.empty() && !key.empty() ? "https://" : "http://") << (addr == "0.0.0.0" ? fenrirds::confhelper::primaryAddress() : addr) << ":" << config.getIntValue(cfgKey("/PORT"), 0) << "/" << std::endl; } /* Start cluster while still root so QUIC can bind privileged ports */ if (clusterEnabled) { cluster.init(ccfg); Loading