From dbbe864b35d545299eb5f691e1e6aa014e8746a8 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 8 Nov 2023 13:46:19 +0100 Subject: [PATCH] Make the config structure a little clearer & easier to use --- config.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/config.js b/config.js index 11d60bd..7e08568 100644 --- a/config.js +++ b/config.js @@ -10,25 +10,20 @@ * *************************************************************************************************/ -// Local testing certificate for now +// Put your CA certificate data here in PEM format: const CERT_PEM = `-----BEGIN CERTIFICATE----- [!! Put your CA certificate data here, in PEM format !!] -----END CERTIFICATE-----`; -if (CERT_PEM.includes("Put your CA certificate data here")) { - throw new Error('No certificate was provided' + - '\n\n' + - 'You need to set CERT_PEM in the Frica config script ' + - 'to the contents of your CA certificate.' - ); -} - -// Default emulator address for now: +// Put your intercepting proxy's address here: const PROXY_HOST = '127.0.0.1'; const PROXY_PORT = 8000; +// If you like, set to to true to enable extra logging: +const DEBUG_MODE = false; + // If you find issues with non-HTTP traffic being captured (due to the // native connect hook script) you can add ports here to exempt traffic // on that port from being redirected. Note that this will only affect @@ -37,8 +32,12 @@ const PROXY_PORT = 8000; // sent via the proxy and intercepted despite this setting. const IGNORED_NON_HTTP_PORTS = []; -// Set to enable extra logging: -const DEBUG_MODE = false; + +// ---------------------------------------------------------------------------- +// You don't need to modify any of the below, it just checks and applies some +// of the configuration that you've entered above. +// ---------------------------------------------------------------------------- + if (DEBUG_MODE) { // Add logging just for clean output & to separate reloads: @@ -50,4 +49,14 @@ if (DEBUG_MODE) { }); } else { console.log(''); // Add just a single newline, for minimal clarity +} + +// Check the certificate (without literally including the instruction phrasing +// here, as that can be confusing for some users): +if (CERT_PEM.match(/\[!!.* CA certificate data .* !!\]/)) { + throw new Error('No certificate was provided' + + '\n\n' + + 'You need to set CERT_PEM in the Frica config script ' + + 'to the contents of your CA certificate.' + ); } \ No newline at end of file