.loki support improvement

pull/988/head
Ryan Tharp 5 years ago
parent a00aa73715
commit 2d76b1eda9

@ -27,16 +27,18 @@ class LokiPublicChatFactoryAPI extends EventEmitter {
static async validServer(serverUrl) { static async validServer(serverUrl) {
// test to make sure it's online (and maybe has a valid SSL cert) // test to make sure it's online (and maybe has a valid SSL cert)
try { try {
const url = new URL(serverUrl);
// allow .loki (may only need an agent but not sure // allow .loki (may only need an agent but not sure
// until we have a .loki to test with) // until we have a .loki to test with)
if (serverUrl.match(/\.loki$/)) { process.env.NODE_TLS_REJECT_UNAUTHORIZED = url.host.match(/\.loki$/i)
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; ? '0'
} : '1';
// FIXME: use proxy when we have open groups that work with proxy
await nodeFetch(serverUrl); await nodeFetch(serverUrl);
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1'; process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1';
// const txt = await res.text(); // const txt = await res.text();
} catch (e) { } catch (e) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 1; process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1';
log.warn(`failing to created ${serverUrl}`, e.code, e.message); log.warn(`failing to created ${serverUrl}`, e.code, e.message);
// bail out if not valid enough // bail out if not valid enough
return false; return false;

Loading…
Cancel
Save