Make the config structure a little clearer & easier to use

This commit is contained in:
Tim Perry
2023-11-08 13:48:37 +01:00
parent 676627d01f
commit dbbe864b35
+21 -12
View File
@@ -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.'
);
}