<commit_before>/**
 * Setup subdomain
 *
 * Implements the subdomain registration
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

var config = require('config');
var fs = require('fs');
var path = require('path');

var TunnelSetup = {

    /*
    * Router middleware to check if we have a ssl tunnel set.
    *
    * @param {Object} request Express request object.
    * @param {Object} response Express response object.
    * @param {Object} next Next middleware.
    */
    isTunnelSet: function (request, response, next) {
        // If ssl tunnel is disabled, continue
        if (!config.get('ssltunnel.enabled')) {
            return next();
        } else {
            // then we check if we have certificates installed
            if ((fs.existsSync('./certificate.pem')
                && fs.existsSync('./privatekey.pem'))
                || (fs.existsSync('notunnel')))  {
                // if certs are installed,
                // then we don't need to do anything and return
                return next();
            } else {
                // if there are no certs installed,
                // we display the cert setup page to the user
                response.sendFile('tunnel_setup.html',
                    { root: path.join(__dirname, 'views') });
            }
        }
    }
}

module.exports = TunnelSetup;<commit_msg>Update tunnel_setup.html path - fixes #222.<commit_after>/**
 * Setup subdomain
 *
 * Implements the subdomain registration
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

var config = require('config');
var fs = require('fs');
var path = require('path');

var TunnelSetup = {

    /*
    * Router middleware to check if we have a ssl tunnel set.
    *
    * @param {Object} request Express request object.
    * @param {Object} response Express response object.
    * @param {Object} next Next middleware.
    */
    isTunnelSet: function (request, response, next) {
        // If ssl tunnel is disabled, continue
        if (!config.get('ssltunnel.enabled')) {
            return next();
        } else {
            // then we check if we have certificates installed
            if ((fs.existsSync('./certificate.pem')
                && fs.existsSync('./privatekey.pem'))
                || (fs.existsSync('notunnel')))  {
                // if certs are installed,
                // then we don't need to do anything and return
                return next();
            } else {
                // if there are no certs installed,
                // we display the cert setup page to the user
                response.sendFile('tunnel_setup.html',
                    { root: path.join(__dirname, '../src/views') });
            }
        }
    }
}

module.exports = TunnelSetup;
{'fraction_non_alphanumeric': 0.11310885910428245, 'fraction_numerical': 0.0035959463877084014, 'mean_word_length': 1.900473933649289, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1958811', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 293}