<commit_before>/*
 * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
 */

/**
  * @proxy.api.js
  *     - Very basic forward proxy implementation for Contrail WebUI
  */
var url         = require('url');
var http        = require('http');
var https       = require('https');
var config      = process.mainModule.exports.config;
var logutils    = require('../utils/log.utils');
var appErrors   = require('../errors/app.errors');
var util        = require('util');
var messages    = require('./messages');
var async       = require('async');
var commonUtils = require('../utils/common.utils');
var opApiServer = require('./opServer.api');
var discoveryClientApi = require('./discoveryclient.api');
var jsonPath    = require('JSONPath').eval;
var _           = require('underscore');
var redisUtils  = require('../utils/redis.utils');
var configServerApi = require('./configServer.api');

var nodeList     = {'hosts': {}, 'ips': {}};
var timeOutId    = null;
var proxyURLStr  = 'proxyURL';
var protocolList = ['http:', 'https:'];
/* Default allowed proxy ports per node */
var defVirtualRouterPorts   = [
    '8085', /* HttpPortAgent */
    '8102', /* HttpPortVRouterNodemgr */
];
var defControlNodePorts     = [
    '8083', /* HttpPortControl */
    '8092', /* HttpPortDns */
    '8101', /* HttpPortControlNodemgr */
]
var defAnalyticsNodePorts   = [
    '8081', /* OpServerPort */
    '8089', /* HttpPortCollector */
    '8090', /* HttpPortOpserver */
    '8091', /* HttpPortQueryEngine */
    '8104', /* HttpPortAnalyticsNodemgr */
];
var defConfigNodePorts      = [
    '5998', /* DiscoveryServerPort */
    '8082', /* ApiServerPort */
    '8084', /* HttpPortApiServer */
    '8087', /* HttpPortSchemaTransformer */
    '8088', /* HttpPortSvcMonitor */
    '8096', /* HttpPortDeviceManager */
    '8100', /* HttpPortConfigNodemgr */
];

function getAllowedProxyPortListByNodeType (nodeType)
{
    if (global.label.VROUTER == nodeType) {
        nodePortsLabel = 'vrouter_node_ports';
        defPorts = defVirtualRouterPorts;
    } else if (global.label.CONTROL_NODE == nodeType) {
        nodePortsLabel = 'control_node_ports';
        defPorts = defControlNodePorts;
    } else if (global.label.OPS_API_SERVER == nodeType) {
        nodePortsLabel = 'analytics_node_ports';
        defPorts = defAnalyticsNodePorts;
    } else if (global.label.API_SERVER == nodeType) {
        nodePortsLabel = 'config_node_ports';
        defPorts = defConfigNodePorts;
    }
    return ((null != config.proxy) &&
            (null != config.proxy[nodePortsLabel]) &&
            (config.proxy[nodePortsLabel].length > 0)) ?<commit_msg>Related-Bug: #1587368 - Changes related to ConfigNode Detail Introspect link.<commit_after>/*
 * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
 */

/**
  * @proxy.api.js
  *     - Very basic forward proxy implementation for Contrail WebUI
  */
var url         = require('url');
var http        = require('http');
var https       = require('https');
var config      = process.mainModule.exports.config;
var logutils    = require('../utils/log.utils');
var appErrors   = require('../errors/app.errors');
var util        = require('util');
var messages    = require('./messages');
var async       = require('async');
var commonUtils = require('../utils/common.utils');
var opApiServer = require('./opServer.api');
var discoveryClientApi = require('./discoveryclient.api');
var jsonPath    = require('JSONPath').eval;
var _           = require('underscore');
var redisUtils  = require('../utils/redis.utils');
var configServerApi = require('./configServer.api');

var nodeList     = {'hosts': {}, 'ips': {}};
var timeOutId    = null;
var proxyURLStr  = 'proxyURL';
var protocolList = ['http:', 'https:'];
/* Default allowed proxy ports per node */
var defVirtualRouterPorts   = [
    '8085', /* HttpPortAgent */
    '8102', /* HttpPortVRouterNodemgr */
];
var defControlNodePorts     = [
    '8083', /* HttpPortControl */
    '8092', /* HttpPortDns */
    '8101', /* HttpPortControlNodemgr */
]
var defAnalyticsNodePorts   = [
    '8081', /* OpServerPort */
    '8089', /* HttpPortCollector */
    '8090', /* HttpPortOpserver */
    '8091', /* HttpPortQueryEngine */
    '8104', /* HttpPortAnalyticsNodemgr */
];
var defConfigNodePorts      = [
    '5998', /* DiscoveryServerPort */
    '8082', /* ApiServerPort */
    '8084', /* HttpPortApiServer */
    '8087', /* HttpPortSchemaTransformer */
    '8088', /* HttpPortSvcMonitor */
    '8096', /* HttpPortDeviceManager */
    '8100', /* HttpPortConfigNodemgr */
];

function getAllowedProxyPortListByNodeType (nodeType)
{
    switch (nodeType) {
    case global.label.VROUTER:
        nodePortsLabel = 'vrouter_node_ports';
        defPorts = defVirtualRouterPorts;
        break;
    case global.label.CONTROL_NODE:
        nodePortsLabel = 'control_node_ports';
        defPorts = defControlNodePorts;
        break;
    case global.label.OPS_API_SERVER:
    case global.label.OPSERVER:
        nodePortsLabel = 'analytics_node_ports';
        defPorts = defAnalyticsNodePorts;
        break;
    case global.label.API_SERVER:
    case global.label.VNCONFIG_API_SERVER:
        nodePortsLabel = 'config_node_ports';
        defPorts = defConfigNodePorts;
        break;
    }
    return ((null != config.proxy) &&
            (null != config.proxy[nodePortsLabel]) &&
            (config.proxy[nodePortsLabel].length > 0)) ?
{'fraction_non_alphanumeric': 0.14941046425939572, 'fraction_numerical': 0.028187177597641857, 'mean_word_length': 3.0575485799701045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2345242', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1666, 'n_words': 349}