diff --git a/OpenFlow/src/Audit.ts b/OpenFlow/src/Audit.ts index 7244e431..0aee7243 100644 --- a/OpenFlow/src/Audit.ts +++ b/OpenFlow/src/Audit.ts @@ -173,6 +173,35 @@ export class Audit { Logger.otel.endSpan(span); } } + public static async IssueLicense(username: string,userid: string, customerid: string, remoteip: string, domain: string, months: number, success: boolean, error: string, parent: Span): Promise { + const span: Span = Logger.otel.startSubSpan("Audit.IssueLicense", parent); + try { + const log: LicenseKey = new LicenseKey(); + log.type = "issue"; + log.remoteip = remoteip; + log.ip = Audit.dot2num(log.remoteip); + log.success = success; + log.months = months; + log.customerid = customerid; + if(success) { + log.name = domain + " " + months + " months"; + } else { + if(error != null && error != "") { + log.name = error; + } else { + log.name = domain + " failed"; + } + } + log.username = username; + log.userid = userid; + Config.db.InsertOne(log, "audit", 0, false, Crypt.rootToken(), span); + } catch (error) { + Logger.instanse.error(error, span); + } + finally { + Logger.otel.endSpan(span); + } + } static dot2num(dot: string): number { if (NoderedUtil.IsNullEmpty(dot)) return 0; if (dot.indexOf(".") == -1) return 0; @@ -223,6 +252,21 @@ export class Nodered extends Base { this._type = "nodered"; } } +export class LicenseKey extends Base { + public success: boolean; + public type: string; + public userid: string; + public username: string; + public remoteip: string; + public ip: number; + public domain: string; + public months: number; + public customerid: string; + constructor() { + super(); + this._type = "license"; + } +} export class auditWorkitem extends Base { public success: boolean; public type: string; diff --git a/OpenFlow/src/Config.ts b/OpenFlow/src/Config.ts index 0484174d..cc521bbe 100644 --- a/OpenFlow/src/Config.ts +++ b/OpenFlow/src/Config.ts @@ -3,6 +3,7 @@ import * as https from "https"; import * as http from "http"; // import { fetch, toPassportConfig } from "passport-saml-metadata"; import * as fs from "fs"; +import * as os from "os"; import * as path from "path"; import { DatabaseConnection } from "./DatabaseConnection"; import { Logger } from "./Logger"; @@ -20,107 +21,6 @@ export class dbConfig extends Base { public version: string; public needsupdate: boolean; public updatedat: Date; - public skip_history_collections: string; - public history_delta_count: number; - public allow_skiphistory: boolean; - public max_memory_restart_mb: number; - - public allow_personal_nodered: boolean; - public amqp_enabled_exchange: boolean; - public log_with_trace: boolean; - public log_with_colors: boolean; - public enable_openai: boolean; - public enable_openapi: boolean; - public enable_openaiauth: boolean; - public openai_token: string; - - public cache_store_type: string; - public cache_store_max: number; - public cache_store_ttl_seconds; - public cache_store_redis_host; - public cache_store_redis_port; - public cache_store_redis_password; - public cache_workitem_queues; - - public log_cache: boolean; - public log_amqp: boolean; - public log_openapi: boolean; - public log_login_provider: boolean; - public log_websocket: boolean; - public log_oauth: boolean; - public log_webserver: boolean; - public log_database: boolean; - public log_database_queries: boolean; - public log_database_queries_ms: number; - public log_grafana: boolean; - public log_housekeeping: boolean; - public log_otel: boolean; - public log_blocked_ips: boolean; - public otel_debug_log: boolean; - public otel_warn_log: boolean; - public otel_err_log: boolean; - public otel_measure_queued_messages: boolean; - public otel_measure__mongodb_watch: boolean; - public otel_measure_onlineuser: boolean; - public otel_measure_nodeid: boolean; - public log_information: boolean; - public log_debug: boolean; - public log_verbose: boolean; - public log_silly: boolean; - public log_to_exchange: boolean; - public heapdump_onstop: boolean; - public api_bypass_perm_check: boolean; - public ignore_expiration: boolean; - - public workitem_queue_monitoring_interval: number; - public workitem_queue_monitoring_enabled: boolean; - public client_heartbeat_timeout: number; - public client_signin_timeout: number; - public client_disconnect_signin_error: boolean; - - public amqp_allow_replyto_empty_queuename: boolean; - public enable_web_tours: boolean; - public enable_nodered_tours: boolean; - public grafana_url:string; - public housekeeping_skip_collections: string; - - public ensure_indexes: boolean; - public text_index_name_fields: string[]; - public metadata_collections: string[]; - - public auto_create_users: boolean; - public auto_create_user_from_jwt: boolean; - public auto_create_domains: string[]; - public persist_user_impersonation: boolean; - public ping_clients_interval: number; - public websocket_message_callback_timeout: number; - - public otel_trace_pingclients: boolean; - public otel_trace_dashboardauth: boolean; - public otel_trace_include_query: boolean; - public otel_trace_connection_ips: boolean; - public otel_trace_mongodb_per_users: boolean; - public otel_trace_mongodb_query_per_users: boolean; - public otel_trace_mongodb_count_per_users: boolean; - public otel_trace_mongodb_aggregate_per_users: boolean; - public otel_trace_mongodb_insert_per_users: boolean; - public otel_trace_mongodb_update_per_users: boolean; - public otel_trace_mongodb_delete_per_users: boolean; - - public grpc_keepalive_time_ms: number; - public grpc_keepalive_timeout_ms: number; - public grpc_http2_min_ping_interval_without_data_ms: number; - public grpc_max_connection_idle_ms: number; - public grpc_max_connection_age_ms: number; - public grpc_max_connection_age_grace_ms: number; - public grpc_http2_max_pings_without_data: number; - public grpc_keepalive_permit_without_calls: number; - public grpc_max_receive_message_length: number; - public grpc_max_send_message_length: number; - - - public agent_images: NoderedImage[] - public agent_node_selector: string; public async Save(jwt: string, parent: Span): Promise { @@ -144,137 +44,54 @@ export class dbConfig extends Base { if (conf.compare(Config.version) == -1) { conf.needsupdate = true; } - Config.log_with_trace = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_with_trace) ? conf.log_with_trace : Config.getEnv("log_with_trace", "false")); - if (!NoderedUtil.IsNullEmpty(conf.auto_create_users)) Config.auto_create_users = Config.parseBoolean(conf.auto_create_users); - if (!NoderedUtil.IsNullEmpty(conf.allow_personal_nodered)) Config.allow_personal_nodered = Config.parseBoolean(conf.allow_personal_nodered); - if (!NoderedUtil.IsNullEmpty(conf.amqp_enabled_exchange)) Config.amqp_enabled_exchange = Config.parseBoolean(conf.amqp_enabled_exchange); - - Logger.instanse.info("db version: " + conf.version, parent); - - Config.skip_history_collections = (!NoderedUtil.IsNullEmpty(conf.skip_history_collections) ? conf.skip_history_collections : Config.getEnv("skip_history_collections", "audit,openrpa_instances,workflow_instances")) - Config.history_delta_count = parseInt(!NoderedUtil.IsNullEmpty(conf.history_delta_count) ? conf.history_delta_count.toString() : Config.getEnv("history_delta_count", "1000")); - Config.allow_skiphistory = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.allow_skiphistory) ? conf.allow_skiphistory : Config.getEnv("allow_skiphistory", "false")); - Config.max_memory_restart_mb = parseInt(!NoderedUtil.IsNullEmpty(conf.max_memory_restart_mb) ? conf.max_memory_restart_mb.toString() : Config.getEnv("max_memory_restart_mb", "0")); - - Config.log_with_trace = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_with_trace) ? conf.log_with_trace : Config.getEnv("log_with_trace", "false")); - Config.log_with_colors = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_with_colors) ? conf.log_with_colors : Config.getEnv("log_with_colors", "true")); - Config.enable_openai = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.enable_openai) ? conf.enable_openai : Config.getEnv("enable_openai", "false")); - Config.enable_openapi = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.enable_openapi) ? conf.enable_openapi : Config.getEnv("enable_openapi", "true")); - Config.enable_openaiauth = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.enable_openaiauth) ? conf.enable_openaiauth : Config.getEnv("enable_openaiauth", "true")); - Config.openai_token = !NoderedUtil.IsNullEmpty(conf.openai_token) ? conf.openai_token : Config.getEnv("openai_token", ""); - - Config.cache_store_type = !NoderedUtil.IsNullEmpty(conf.cache_store_type) ? conf.cache_store_type : Config.getEnv("cache_store_type", "memory"); - Config.cache_store_max = parseInt(!NoderedUtil.IsNullEmpty(conf.cache_store_max) ? conf.cache_store_max.toString() : Config.getEnv("cache_store_max", "1000")); - Config.cache_store_ttl_seconds = parseInt(!NoderedUtil.IsNullEmpty(conf.cache_store_ttl_seconds) ? conf.cache_store_ttl_seconds.toString() : Config.getEnv("cache_store_ttl_seconds", "300")); - Config.cache_store_redis_host = !NoderedUtil.IsNullEmpty(conf.cache_store_redis_host) ? conf.cache_store_redis_host : Config.getEnv("cache_store_redis_host", ""); - Config.cache_store_redis_port = parseInt(!NoderedUtil.IsNullEmpty(conf.cache_store_redis_port) ? conf.cache_store_redis_port.toString() : Config.getEnv("cache_store_redis_port", "6379")); - Config.cache_store_redis_password = !NoderedUtil.IsNullEmpty(conf.cache_store_redis_password) ? conf.cache_store_redis_password : Config.getEnv("cache_store_redis_password", ""); - Config.cache_workitem_queues = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.cache_workitem_queues) ? conf.cache_workitem_queues : Config.getEnv("cache_workitem_queues", "false")); - - Config.log_cache = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_cache) ? conf.log_cache : Config.getEnv("log_cache", "false")); - Config.log_amqp = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_amqp) ? conf.log_amqp : Config.getEnv("log_amqp", "false")); - Config.log_openapi = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_openapi) ? conf.log_openapi : Config.getEnv("log_openapi", "false")); - - Config.log_login_provider = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_login_provider) ? conf.log_login_provider : Config.getEnv("log_login_provider", "false")); - Config.log_websocket = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_websocket) ? conf.log_websocket : Config.getEnv("log_websocket", "false")); - Config.log_oauth = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_oauth) ? conf.log_oauth : Config.getEnv("log_oauth", "false")); - Config.log_webserver = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_webserver) ? conf.log_webserver : Config.getEnv("log_webserver", "false")); - Config.log_database = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_database) ? conf.log_database : Config.getEnv("log_database", "false")); - Config.log_database_queries = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_database_queries) ? conf.log_database_queries : Config.getEnv("log_database_queries", "false")); - Config.log_database_queries_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.log_database_queries_ms) ? conf.log_database_queries_ms.toString() : Config.getEnv("log_database_queries_ms", "0")); - - Config.log_grafana = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_grafana) ? conf.log_grafana : Config.getEnv("log_grafana", "false")); - Config.log_housekeeping = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_housekeeping) ? conf.log_housekeeping : Config.getEnv("log_housekeeping", "false")); - Config.log_otel = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_otel) ? conf.log_otel : Config.getEnv("log_otel", "false")); - Config.log_blocked_ips = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_blocked_ips) ? conf.log_blocked_ips : Config.getEnv("log_blocked_ips", "true")); - Config.otel_debug_log = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_debug_log) ? conf.otel_debug_log : Config.getEnv("otel_debug_log", "false")); - Config.otel_warn_log = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_warn_log) ? conf.otel_warn_log : Config.getEnv("otel_warn_log", "false")); - Config.otel_err_log = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_err_log) ? conf.otel_err_log : Config.getEnv("otel_err_log", "false")); - Config.otel_measure_queued_messages = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_measure_queued_messages) ? conf.otel_measure_queued_messages : Config.getEnv("otel_measure_queued_messages", "false")); - Config.otel_measure__mongodb_watch = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_measure__mongodb_watch) ? conf.otel_measure__mongodb_watch : Config.getEnv("otel_measure__mongodb_watch", "false")); - Config.otel_measure_onlineuser = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_measure_onlineuser) ? conf.otel_measure_onlineuser : Config.getEnv("otel_measure_onlineuser", "false")); - Config.otel_measure_nodeid = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_measure_nodeid) ? conf.otel_measure_nodeid : Config.getEnv("otel_measure_nodeid", "false")); - - - Config.log_information = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_information) ? conf.log_information : Config.getEnv("log_information", "true")); - Config.log_debug = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_debug) ? conf.log_debug : Config.getEnv("log_debug", "false")); - Config.log_verbose = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_verbose) ? conf.log_verbose : Config.getEnv("log_verbose", "false")); - Config.log_silly = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_silly) ? conf.log_silly : Config.getEnv("log_silly", "false")); - Config.log_to_exchange = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.log_to_exchange) ? conf.log_to_exchange : Config.getEnv("log_to_exchange", "false")); - Config.heapdump_onstop = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.heapdump_onstop) ? conf.heapdump_onstop : Config.getEnv("heapdump_onstop", "false")); - - Config.client_heartbeat_timeout = parseInt(!NoderedUtil.IsNullEmpty(conf.client_heartbeat_timeout) ? conf.client_heartbeat_timeout.toString() : Config.getEnv("client_heartbeat_timeout", "60")); - Config.client_signin_timeout = parseInt(!NoderedUtil.IsNullEmpty(conf.client_signin_timeout) ? conf.client_signin_timeout.toString() : Config.getEnv("client_signin_timeout", "120")); - Config.client_disconnect_signin_error = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.client_disconnect_signin_error) ? conf.client_disconnect_signin_error : Config.getEnv("client_disconnect_signin_error", "false")); - Config.api_bypass_perm_check = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.api_bypass_perm_check) ? conf.api_bypass_perm_check : Config.getEnv("api_bypass_perm_check", "false")); - Config.ignore_expiration = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.ignore_expiration) ? conf.ignore_expiration : Config.getEnv("ignore_expiration", "false")); - - - - - Config.workitem_queue_monitoring_interval = parseInt(!NoderedUtil.IsNullEmpty(conf.workitem_queue_monitoring_interval) ? conf.workitem_queue_monitoring_interval.toString() : Config.getEnv("workitem_queue_monitoring_interval", "10000")); - Config.workitem_queue_monitoring_enabled = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.workitem_queue_monitoring_enabled) ? conf.workitem_queue_monitoring_enabled : Config.getEnv("workitem_queue_monitoring_enabled", "true")); - - Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.amqp_allow_replyto_empty_queuename) ? conf.amqp_allow_replyto_empty_queuename : Config.getEnv("amqp_allow_replyto_empty_queuename", "false")); - Config.enable_web_tours = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.enable_web_tours) ? conf.enable_web_tours : Config.getEnv("enable_web_tours", "true")); - Config.enable_nodered_tours = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.enable_nodered_tours) ? conf.enable_nodered_tours : Config.getEnv("enable_nodered_tours", "true")); - Config.grafana_url = !NoderedUtil.IsNullEmpty(conf.grafana_url) ? conf.grafana_url : Config.getEnv("grafana_url", ""); - Config.housekeeping_skip_collections = !NoderedUtil.IsNullEmpty(conf.housekeeping_skip_collections) ? conf.housekeeping_skip_collections : Config.getEnv("housekeeping_skip_collections", ""); - - - Config.ensure_indexes = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.ensure_indexes) ? conf.ensure_indexes : Config.getEnv("ensure_indexes", "true")); - Config.text_index_name_fields = Config.parseArray(!NoderedUtil.IsNullEmpty(conf.text_index_name_fields) ? conf.text_index_name_fields.toString() : Config.getEnv("text_index_name_fields", "name,_names")) - Config.metadata_collections = Config.parseArray(!NoderedUtil.IsNullEmpty(conf.metadata_collections) ? conf.metadata_collections.toString() : Config.getEnv("metadata_collections", "")) - Config.auto_create_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.auto_create_users) ? conf.auto_create_users : Config.getEnv("auto_create_users", "false")) - - Config.auto_create_user_from_jwt = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.auto_create_user_from_jwt) ? conf.auto_create_user_from_jwt : Config.getEnv("auto_create_user_from_jwt", "")) - Config.auto_create_user_from_jwt = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.auto_create_user_from_jwt) ? conf.auto_create_user_from_jwt : Config.getEnv("auto_create_user_from_jwt", "")) - Config.auto_create_domains = Config.parseArray(!NoderedUtil.IsNullEmpty(conf.auto_create_domains) ? conf.auto_create_domains.toString() : Config.getEnv("auto_create_domains", "")) - Config.persist_user_impersonation = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.persist_user_impersonation) ? conf.persist_user_impersonation : Config.getEnv("persist_user_impersonation", "true")) - Config.ping_clients_interval = parseInt(!NoderedUtil.IsNullEmpty(conf.ping_clients_interval) ? conf.ping_clients_interval.toString() : Config.getEnv("ping_clients_interval", (10000).toString())) - Config.websocket_message_callback_timeout = parseInt(!NoderedUtil.IsNullEmpty(conf.websocket_message_callback_timeout) ? conf.websocket_message_callback_timeout.toString() : Config.getEnv("websocket_message_callback_timeout", (10000).toString())) - - Config.otel_trace_pingclients = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_pingclients) ? conf.otel_trace_pingclients : Config.getEnv("otel_trace_pingclients", "false")); - Config.otel_trace_dashboardauth = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_dashboardauth) ? conf.otel_trace_dashboardauth : Config.getEnv("otel_trace_dashboardauth", "false")); - Config.otel_trace_include_query = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_include_query) ? conf.otel_trace_include_query : Config.getEnv("otel_trace_include_query", "false")); - Config.otel_trace_connection_ips = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_connection_ips) ? conf.otel_trace_connection_ips : Config.getEnv("otel_trace_connection_ips", "false")); - Config.otel_trace_mongodb_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_per_users) ? conf.otel_trace_mongodb_per_users : Config.getEnv("otel_trace_mongodb_per_users", "false")); - Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_query_per_users) ? conf.otel_trace_mongodb_query_per_users : Config.getEnv("otel_trace_mongodb_query_per_users", "false")); - Config.otel_trace_mongodb_count_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_count_per_users) ? conf.otel_trace_mongodb_count_per_users : Config.getEnv("otel_trace_mongodb_query_per_users", "false")); - Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_aggregate_per_users) ? conf.otel_trace_mongodb_aggregate_per_users : Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false")); - Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_insert_per_users) ? conf.otel_trace_mongodb_insert_per_users : Config.getEnv("otel_trace_mongodb_insert_per_users", "false")); - Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_update_per_users) ? conf.otel_trace_mongodb_update_per_users : Config.getEnv("otel_trace_mongodb_update_per_users", "false")); - Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(!NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_delete_per_users) ? conf.otel_trace_mongodb_delete_per_users : Config.getEnv("otel_trace_mongodb_delete_per_users", "false")); - - Config.grpc_keepalive_time_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_keepalive_time_ms) ? conf.grpc_keepalive_time_ms.toString() : Config.getEnv("grpc_keepalive_time_ms", (-1).toString())) - Config.grpc_keepalive_timeout_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_keepalive_timeout_ms) ? conf.grpc_keepalive_timeout_ms.toString() : Config.getEnv("grpc_keepalive_timeout_ms", (-1).toString())) - Config.grpc_http2_min_ping_interval_without_data_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_http2_min_ping_interval_without_data_ms) ? conf.grpc_http2_min_ping_interval_without_data_ms.toString() : Config.getEnv("grpc_http2_min_ping_interval_without_data_ms", (-1).toString())) - Config.grpc_max_connection_idle_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_max_connection_idle_ms) ? conf.grpc_max_connection_idle_ms.toString() : Config.getEnv("grpc_max_connection_idle_ms", (-1).toString())) - Config.grpc_max_connection_age_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_max_connection_age_ms) ? conf.grpc_max_connection_age_ms.toString() : Config.getEnv("grpc_max_connection_age_ms", (-1).toString())) - Config.grpc_max_connection_age_grace_ms = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_max_connection_age_grace_ms) ? conf.grpc_max_connection_age_grace_ms.toString() : Config.getEnv("grpc_max_connection_age_grace_ms", (-1).toString())) - Config.grpc_http2_max_pings_without_data = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_http2_max_pings_without_data) ? conf.grpc_http2_max_pings_without_data.toString() : Config.getEnv("grpc_http2_max_pings_without_data", (-1).toString())) - Config.grpc_keepalive_permit_without_calls = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_keepalive_permit_without_calls) ? conf.grpc_keepalive_permit_without_calls.toString() : Config.getEnv("grpc_keepalive_permit_without_calls", (-1).toString())) - Config.grpc_max_receive_message_length = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_max_receive_message_length) ? conf.grpc_max_receive_message_length.toString() : Config.getEnv("grpc_max_receive_message_length", (-1).toString())) - Config.grpc_max_send_message_length = parseInt(!NoderedUtil.IsNullEmpty(conf.grpc_max_send_message_length) ? conf.grpc_max_send_message_length.toString() : Config.getEnv("grpc_max_send_message_length", (-1).toString())) - + var keys = Object.keys(conf); + for(var i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = conf[key]; + try { + if(key.startsWith("_")) continue; + if(NoderedUtil.IsNullEmpty(value)) continue; + if(["name", "version"].indexOf(key) > -1 ) continue; + if(key == "license_key") { + if(os.hostname().toLowerCase() == "nixos") { + continue; + } + } - - Config.agent_node_selector = (!NoderedUtil.IsNullEmpty(conf.agent_node_selector) ? conf.agent_node_selector : Config.getEnv("agent_node_selector", "")) - - if(!NoderedUtil.IsNullUndefinded(conf.agent_images)) { - Config.agent_images = conf.agent_images; - if(typeof conf.agent_images === "string") conf.agent_images = JSON.parse(conf.agent_images); - } else { - Config.agent_images = JSON.parse(Config.getEnv("agent_images", - JSON.stringify([{"name":"Agent", "image":"openiap/nodeagent", "languages": ["nodejs", "python"]}, {"name":"Agent+Chromium", "image":"openiap/nodechromiumagent", "chromium": true, "languages": ["nodejs", "python"]}, {"name":"NodeRED", "image":"openiap/noderedagent", "port": 3000}, {"name":"DotNet 6", "image":"openiap/dotnetagent", "languages": ["dotnet"]} ]) - )); + if (Object.prototype.hasOwnProperty.call(Config, key)) { + if(typeof Config[key] === "boolean") { + // console.log("Setting boolen " + key + " to " + conf[key]); + Config[key] = Config.parseBoolean(conf[key]); + } else if(typeof Config[key] === "number") { + // console.log("Setting number " + key + " to " + conf[key]); + Config[key] = parseInt(conf[key]); + } else if(Array.isArray(Config[key])) { + // console.log("Setting array " + key + " to " + conf[key]); + if(Array.isArray(conf[key])) { + Config[key] = conf[key]; + } else { + Config[key] = Config.parseArray(conf[key]); + } + } else if(typeof Config[key] === "string") { + // console.log("Setting string " + key + " to " + conf[key]); + Config[key] = conf[key]; + } else { + // console.log("Setting Unknown " + key + " to " + conf[key]); + Config[key] = conf[key]; + } + } + } catch (error) { + Logger.instanse.error("Error setting config " + keys + " to " + value, parent); + } } - Logger.reload(); + await Logger.reload(); return conf; } public static async Reload(jwt: string, parent: Span): Promise { Config.dbConfig = await dbConfig.Load(jwt, parent); + + Logger.instanse.info("Reloaded config version " + Config.dbConfig._version, parent); } } export class Config { @@ -303,279 +120,6 @@ export class Config { Config.log_oauth = false; Config.unittesting = true; } - public static reload(): void { - Config.getversion(); - Config.log_with_colors = Config.parseBoolean(Config.getEnv("log_with_colors", "true")); - Config.enable_openai = Config.parseBoolean(Config.getEnv("enable_openai", "false")); - Config.enable_openapi = Config.parseBoolean(Config.getEnv("enable_openapi", "true")); - Config.enable_openaiauth = Config.parseBoolean(Config.getEnv("enable_openaiauth", "true")); - Config.openai_token = Config.getEnv("openai_token", ""); - - Config.log_with_trace = Config.parseBoolean(Config.getEnv("log_with_trace", "false")); - - Config.log_cache = Config.parseBoolean(Config.getEnv("log_cache", "false")); - Config.log_amqp = Config.parseBoolean(Config.getEnv("log_amqp", "false")); - Config.log_openapi = Config.parseBoolean(Config.getEnv("log_openapi", "false")); - Config.log_login_provider = Config.parseBoolean(Config.getEnv("log_login_provider", "false")); - Config.log_websocket = Config.parseBoolean(Config.getEnv("log_websocket", "false")); - Config.log_oauth = Config.parseBoolean(Config.getEnv("log_oauth", "false")); - Config.log_webserver = Config.parseBoolean(Config.getEnv("log_webserver", "false")); - Config.log_database = Config.parseBoolean(Config.getEnv("log_database", "false")); - Config.log_database_queries = Config.parseBoolean(Config.getEnv("log_database_queries", "false")); - Config.log_database_queries_ms = parseInt(Config.getEnv("log_database_queries_ms", "0")); - Config.log_grafana = Config.parseBoolean(Config.getEnv("log_grafana", "false")); - Config.log_housekeeping = Config.parseBoolean(Config.getEnv("log_housekeeping", "false")); - Config.log_otel = Config.parseBoolean(Config.getEnv("log_otel", "false")); - Config.log_blocked_ips = Config.parseBoolean(Config.getEnv("log_blocked_ips", "true")); - Config.log_information = Config.parseBoolean(Config.getEnv("log_information", "true")); - Config.log_debug = Config.parseBoolean(Config.getEnv("log_debug", "false")); - Config.log_verbose = Config.parseBoolean(Config.getEnv("log_verbose", "false")); - Config.log_silly = Config.parseBoolean(Config.getEnv("log_silly", "false")); - Config.log_to_exchange = Config.parseBoolean(Config.getEnv("log_to_exchange", "false")); - - Config.heapdump_onstop = Config.parseBoolean(Config.getEnv("heapdump_onstop", "false")); - - Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(Config.getEnv("amqp_allow_replyto_empty_queuename", "false")); - - Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", ""); - Config.enable_openflow_amqp = Config.parseBoolean(Config.getEnv("enable_openflow_amqp", "false")); - Config.openflow_amqp_expiration = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min - Config.amqp_prefetch = parseInt(Config.getEnv("amqp_prefetch", "25")); - Config.enable_entity_restriction = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false")); - Config.enable_web_tours = Config.parseBoolean(Config.getEnv("enable_web_tours", "true")); - Config.enable_nodered_tours = Config.parseBoolean(Config.getEnv("enable_nodered_tours", "true")); - Config.grafana_url = Config.getEnv("grafana_url", ""); - Config.auto_hourly_housekeeping = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "true")); - Config.housekeeping_update_usage_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false")); - Config.housekeeping_update_usersize_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true")); - Config.housekeeping_skip_collections = Config.getEnv("housekeeping_skip_collections", ""); - Config.workitem_queue_monitoring_enabled = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true")); - Config.workitem_queue_monitoring_interval = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (10 * 1000).toString())); // 10 sec - - - Config.getting_started_url = Config.getEnv("getting_started_url", ""); - - Config.NODE_ENV = Config.getEnv("NODE_ENV", "development"); - Config.HTTP_PROXY = Config.getEnv("HTTP_PROXY", ""); - Config.HTTPS_PROXY = Config.getEnv("HTTPS_PROXY", ""); - Config.NO_PROXY = Config.getEnv("NO_PROXY", ""); - Config.agent_HTTP_PROXY = Config.getEnv("agent_HTTP_PROXY", ""); - Config.agent_HTTPS_PROXY = Config.getEnv("agent_HTTPS_PROXY", ""); - Config.agent_NO_PROXY = Config.getEnv("agent_NO_PROXY", ""); - - - Config.stripe_api_key = Config.getEnv("stripe_api_key", ""); - Config.stripe_api_secret = Config.getEnv("stripe_api_secret", ""); - Config.stripe_force_vat = Config.parseBoolean(Config.getEnv("stripe_force_vat", "false")); - Config.stripe_force_checkout = Config.parseBoolean(Config.getEnv("stripe_force_checkout", "true")); - Config.stripe_allow_promotion_codes = Config.parseBoolean(Config.getEnv("stripe_allow_promotion_codes", "true")); - - Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false")); - Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true")); - Config.text_index_name_fields = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names")); - Config.metadata_collections = Config.parseArray(Config.getEnv("metadata_collections", "")); - - Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false")); - Config.auto_create_user_from_jwt = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false")); - Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", "")); - Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true")); - Config.ping_clients_interval = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 10 seconds - Config.allow_personal_nodered = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false")); - Config.use_ingress_beta1_syntax = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "false")); - Config.use_openshift_routes = Config.parseBoolean(Config.getEnv("use_openshift_routes", "false")); - Config.agent_image_pull_secrets = Config.parseArray(Config.getEnv("agent_image_pull_secrets", "")); - - - - Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false")); - Config.auto_create_personal_noderedapi_group = Config.parseBoolean(Config.getEnv("auto_create_personal_noderedapi_group", "false")); - Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true")); - Config.validate_emails = Config.parseBoolean(Config.getEnv("validate_emails", "false")); - Config.forgot_pass_emails = Config.parseBoolean(Config.getEnv("forgot_pass_emails", "false")); - Config.smtp_service = Config.getEnv("smtp_service", ""); - Config.smtp_from = Config.getEnv("smtp_from", ""); - Config.smtp_user = Config.getEnv("smtp_user", ""); - Config.smtp_pass = Config.getEnv("smtp_service", ""); - Config.smtp_url = Config.getEnv("smtp_url", ""); - Config.debounce_lookup = Config.parseBoolean(Config.getEnv("debounce_lookup", "false")); - Config.validate_emails_disposable = Config.parseBoolean(Config.getEnv("validate_emails_disposable", "false")); - - - - Config.tls_crt = Config.getEnv("tls_crt", ""); - Config.tls_key = Config.getEnv("tls_key", ""); - Config.tls_ca = Config.getEnv("tls_ca", ""); - Config.tls_passphrase = Config.getEnv("tls_passphrase", ""); - - Config.cache_store_type = Config.getEnv("cache_store_type", "memory"); - Config.cache_store_max = parseInt(Config.getEnv("cache_store_max", "1000")); - Config.cache_store_ttl_seconds = parseInt(Config.getEnv("cache_store_ttl_seconds", "300")); - Config.cache_store_redis_host = Config.getEnv("cache_store_redis_host", ""); - Config.cache_store_redis_port = parseInt(Config.getEnv("cache_store_redis_port", "6379")); - Config.cache_store_redis_password = Config.getEnv("cache_store_redis_password", ""); - Config.cache_workitem_queues = Config.parseBoolean(Config.getEnv("cache_workitem_queues", "false")); - - Config.oidc_access_token_ttl = parseInt(Config.getEnv("oidc_access_token_ttl", "480")); - Config.oidc_authorization_code_ttl = parseInt(Config.getEnv("oidc_authorization_code_ttl", "480")); - Config.oidc_client_credentials_ttl = parseInt(Config.getEnv("oidc_client_credentials_ttl", "480")); - Config.oidc_refresh_token_ttl = parseInt(Config.getEnv("oidc_refresh_token_ttl", "20160")); - Config.oidc_session_ttl = parseInt(Config.getEnv("oidc_session_ttl", "20160")); - - Config.api_rate_limit = Config.parseBoolean(Config.getEnv("api_rate_limit", "true")); - Config.api_rate_limit_points = parseInt(Config.getEnv("api_rate_limit_points", "60")); - Config.api_rate_limit_duration = parseInt(Config.getEnv("api_rate_limit_duration", "1")); - Config.socket_rate_limit = Config.parseBoolean(Config.getEnv("socket_rate_limit", "true")); - Config.socket_rate_limit_points = parseInt(Config.getEnv("socket_rate_limit_points", "30")); - Config.socket_rate_limit_points_disconnect = parseInt(Config.getEnv("socket_rate_limit_points_disconnect", "100")); - Config.socket_rate_limit_duration = parseInt(Config.getEnv("socket_rate_limit_duration", "1")); - Config.socket_error_rate_limit_points = parseInt(Config.getEnv("socket_error_rate_limit_points", "16")); - Config.socket_error_rate_limit_duration = parseInt(Config.getEnv("socket_error_rate_limit_duration", "2")); - - Config.client_heartbeat_timeout = parseInt(Config.getEnv("client_heartbeat_timeout", "60")); - Config.client_signin_timeout = parseInt(Config.getEnv("client_signin_timeout", "120")); - Config.client_disconnect_signin_error = Config.parseBoolean(Config.getEnv("client_disconnect_signin_error", "false")); - - - Config.expected_max_roles = parseInt(Config.getEnv("expected_max_roles", "4000")); - Config.decorate_roles_fetching_all_roles = Config.parseBoolean(Config.getEnv("decorate_roles_fetching_all_roles", "true")); - Config.update_acl_based_on_groups = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "true")); - Config.allow_merge_acl = Config.parseBoolean(Config.getEnv("allow_merge_acl", "false")); - Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false")); - Config.cleanup_on_delete_customer = Config.parseBoolean(Config.getEnv("cleanup_on_delete_customer", "false")); - Config.cleanup_on_delete_user = Config.parseBoolean(Config.getEnv("cleanup_on_delete_user", "false")); - - Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false")); - Config.ignore_expiration = Config.parseBoolean(Config.getEnv("ignore_expiration", "false")); - Config.force_audit_ts = Config.parseBoolean(Config.getEnv("force_audit_ts", "false")); - Config.force_dbusage_ts = Config.parseBoolean(Config.getEnv("force_dbusage_ts", "false")); - Config.migrate_audit_to_ts = Config.parseBoolean(Config.getEnv("migrate_audit_to_ts", "true")); - - Config.websocket_package_size = parseInt(Config.getEnv("websocket_package_size", "25000"), 10); - Config.websocket_max_package_count = parseInt(Config.getEnv("websocket_max_package_count", "1024"), 10); - Config.websocket_message_callback_timeout = parseInt(Config.getEnv("websocket_message_callback_timeout", "3600"), 10); - Config.protocol = Config.getEnv("protocol", "http"); // used by personal nodered and baseurl() - Config.port = parseInt(Config.getEnv("port", "80")); - Config.domain = Config.getEnv("domain", "localhost"); // sent to website and used in baseurl() - Config.cookie_secret = Config.getEnv("cookie_secret", "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu"); - - Config.amqp_reply_expiration = parseInt(Config.getEnv("amqp_reply_expiration", "10000")); // 10 seconds - Config.amqp_force_queue_prefix = Config.parseBoolean(Config.getEnv("amqp_force_queue_prefix", "false")); - Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "false")); - Config.amqp_force_sender_has_read = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_read", "true")); - Config.amqp_force_sender_has_invoke = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_invoke", "false")); - Config.amqp_force_consumer_has_update = Config.parseBoolean(Config.getEnv("amqp_force_consumer_has_update", "false")); - - Config.amqp_enabled_exchange = Config.parseBoolean(Config.getEnv("amqp_enabled_exchange", "false")); - Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered - Config.amqp_username = Config.getEnv("amqp_username", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url - Config.amqp_password = Config.getEnv("amqp_password", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url - Config.amqp_check_for_consumer = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer", "true")); - Config.amqp_check_for_consumer_count = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer_count", "false")); - Config.amqp_default_expiration = parseInt(Config.getEnv("amqp_default_expiration", "10000")); // 10 seconds - Config.amqp_requeue_time = parseInt(Config.getEnv("amqp_requeue_time", "1000")); // 1 seconds - Config.amqp_dlx = Config.getEnv("amqp_dlx", "openflow-dlx"); // Dead letter exchange, used to pickup dead or timeout messages - - Config.mongodb_url = Config.getEnv("mongodb_url", "mongodb://localhost:27017"); - Config.mongodb_db = Config.getEnv("mongodb_db", "openflow"); - Config.mongodb_minpoolsize = parseInt(Config.getEnv("mongodb_minpoolsize", "25")); - Config.mongodb_maxpoolsize = parseInt(Config.getEnv("mongodb_maxpoolsize", "25")); - - Config.skip_history_collections = Config.getEnv("skip_history_collections", "audit,openrpa_instances,workflow_instances"); - Config.history_delta_count = parseInt(Config.getEnv("history_delta_count", "1000")); - Config.allow_skiphistory = Config.parseBoolean(Config.getEnv("allow_skiphistory", "false")); - Config.max_memory_restart_mb = parseInt(Config.getEnv("max_memory_restart_mb", "0")); - - Config.saml_issuer = Config.getEnv("saml_issuer", "the-issuer"); // define uri of STS, also sent to personal nodereds - Config.aes_secret = Config.getEnv("aes_secret", ""); - Config.signing_crt = Config.getEnv("signing_crt", ""); - Config.singing_key = Config.getEnv("singing_key", ""); - Config.wapid_mail = Config.getEnv("wapid_mail", ""); - Config.wapid_pub = Config.getEnv("wapid_pub", ""); - Config.wapid_key = Config.getEnv("wapid_key", ""); - Config.shorttoken_expires_in = Config.getEnv("shorttoken_expires_in", "5m"); - Config.longtoken_expires_in = Config.getEnv("longtoken_expires_in", "365d"); - Config.downloadtoken_expires_in = Config.getEnv("downloadtoken_expires_in", "15m"); - Config.personalnoderedtoken_expires_in = Config.getEnv("personalnoderedtoken_expires_in", "365d"); - - Config.nodered_images = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]")); - Config.agent_images = JSON.parse(Config.getEnv("agent_images", - JSON.stringify([{"name":"Agent", "image":"openiap/nodeagent", "languages": ["nodejs", "python"]}, {"name":"Agent+Chromium", "image":"openiap/nodechromiumagent", "chromium": true, "languages": ["nodejs", "python"]}, {"name":"NodeRED", "image":"openiap/noderedagent", "port": 3000}, {"name":"NodeRED+Chromium", "image":"openiap/noderedagent:chromium", "chromium": true, "port": 3000}, {"name":"DotNet 6", "image":"openiap/dotnetagent", "languages": ["dotnet"]} ]) - )); - Config.agent_domain_schema = Config.getEnv("agent_domain_schema", ""); - Config.agent_node_selector = Config.getEnv("agent_node_selector", ""); - - Config.agent_apiurl = Config.getEnv("agent_apiurl", ""); - Config.agent_oidc_config = Config.getEnv("agent_oidc_config", ""); - Config.agent_oidc_client_id = Config.getEnv("agent_oidc_client_id", ""); - Config.agent_oidc_client_secret = Config.getEnv("agent_oidc_client_secret", ""); - Config.agent_oidc_userinfo_endpoint = Config.getEnv("agent_oidc_userinfo_endpoint", ""); - Config.agent_oidc_issuer = Config.getEnv("agent_oidc_issuer", ""); - Config.agent_oidc_authorization_endpoint = Config.getEnv("agent_oidc_authorization_endpoint", ""); - Config.agent_oidc_token_endpoint = Config.getEnv("agent_oidc_token_endpoint", ""); - - Config.saml_federation_metadata = Config.getEnv("saml_federation_metadata", ""); - Config.api_ws_url = Config.getEnv("api_ws_url", ""); - Config.nodered_ws_url = Config.getEnv("nodered_ws_url", ""); - Config.nodered_saml_entrypoint = Config.getEnv("nodered_saml_entrypoint", ""); - Config.agent_docker_entrypoints = Config.getEnv("agent_docker_entrypoints", "web"); - Config.agent_docker_use_project = Config.parseBoolean(Config.getEnv("agent_docker_use_project", "false")); - Config.agent_docker_certresolver = Config.getEnv("agent_docker_certresolver", ""); - Config.namespace = Config.getEnv("namespace", ""); // also sent to website - Config.nodered_domain_schema = Config.getEnv("nodered_domain_schema", ""); // also sent to website - Config.nodered_initial_liveness_delay = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60")); - Config.nodered_allow_nodeselector = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false")); - // Config.nodered_requests_memory = Config.getEnv("nodered_requests_memory", ""); - // Config.nodered_requests_cpu = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU - // Config.nodered_limits_memory = Config.getEnv("nodered_limits_memory", ""); - // Config.nodered_limits_cpu = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU - - Config.nodered_liveness_failurethreshold = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5")); - Config.nodered_liveness_timeoutseconds = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5")); - Config.noderedcatalogues = Config.getEnv("noderedcatalogues", ""); - - Config.otel_measure_nodeid = Config.parseBoolean(Config.getEnv("otel_measure_nodeid", "false")); - Config.otel_measure_queued_messages = Config.parseBoolean(Config.getEnv("otel_measure_queued_messages", "false")); - Config.otel_measure__mongodb_watch = Config.parseBoolean(Config.getEnv("otel_measure__mongodb_watch", "false")); - Config.otel_measure_onlineuser = Config.parseBoolean(Config.getEnv("otel_measure_onlineuser", "false")); - Config.enable_analytics = Config.parseBoolean(Config.getEnv("enable_analytics", "true")); - Config.enable_detailed_analytic = Config.parseBoolean(Config.getEnv("enable_detailed_analytic", "false")); - - Config.otel_debug_log = Config.parseBoolean(Config.getEnv("otel_debug_log", "false")); - Config.otel_warn_log = Config.parseBoolean(Config.getEnv("otel_warn_log", "false")); - Config.otel_err_log = Config.parseBoolean(Config.getEnv("otel_err_log", "false")); - Config.otel_trace_url = Config.getEnv("otel_trace_url", ""); - Config.otel_metric_url = Config.getEnv("otel_metric_url", ""); - Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000")); - Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000")); - - Config.otel_trace_pingclients = Config.parseBoolean(Config.getEnv("otel_trace_pingclients", "false")); - Config.otel_trace_dashboardauth = Config.parseBoolean(Config.getEnv("otel_trace_dashboardauth", "false")); - Config.otel_trace_include_query = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false")); - Config.otel_trace_connection_ips = Config.parseBoolean(Config.getEnv("otel_trace_connection_ips", "false")); - Config.otel_trace_mongodb_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_per_users", "false")); - Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_query_per_users", "false")); - Config.otel_trace_mongodb_count_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_count_per_users", "false")); - Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false")); - Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_insert_per_users", "false")); - Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false")); - Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false")); - - Config.grpc_keepalive_time_ms = parseInt(Config.getEnv("grpc_keepalive_time_ms", "-1")); - Config.grpc_keepalive_timeout_ms = parseInt(Config.getEnv("grpc_keepalive_timeout_ms", "-1")); - Config.grpc_http2_min_ping_interval_without_data_ms = parseInt(Config.getEnv("grpc_http2_min_ping_interval_without_data_ms", "-1")); - Config.grpc_max_connection_idle_ms = parseInt(Config.getEnv("grpc_max_connection_idle_ms", "-1")); - Config.grpc_max_connection_age_ms = parseInt(Config.getEnv("grpc_max_connection_age_ms", "-1")); - Config.grpc_max_connection_age_grace_ms = parseInt(Config.getEnv("grpc_max_connection_age_grace_ms", "-1")); - Config.grpc_http2_max_pings_without_data = parseInt(Config.getEnv("grpc_http2_max_pings_without_data", "-1")); - Config.grpc_keepalive_permit_without_calls = parseInt(Config.getEnv("grpc_keepalive_permit_without_calls", "-1")); - Config.grpc_max_receive_message_length = parseInt(Config.getEnv("grpc_max_receive_message_length", "-1")); - Config.grpc_max_send_message_length = parseInt(Config.getEnv("grpc_max_send_message_length", "-1")); - - - Config.validate_user_form = Config.getEnv("validate_user_form", ""); - } - public static load_drom_db(): void { - } public static unittesting: boolean = false; public static db: DatabaseConnection = null; public static license_key: string = Config.getEnv("license_key", ""); @@ -629,8 +173,6 @@ export class Config { public static enable_nodered_tours: boolean = Config.parseBoolean(Config.getEnv("enable_nodered_tours", "true")); public static grafana_url:string = Config.getEnv("grafana_url", ""); public static auto_hourly_housekeeping: boolean = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "true")); - public static housekeeping_update_usage_hourly: boolean = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false")); - public static housekeeping_update_usersize_hourly: boolean = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true")); public static housekeeping_skip_collections: string = Config.getEnv("housekeeping_skip_collections", ""); public static workitem_queue_monitoring_enabled: boolean = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true")); public static workitem_queue_monitoring_interval: number = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (10 * 1000).toString())); // 10 sec @@ -656,7 +198,6 @@ export class Config { public static supports_watch: boolean = Config.parseBoolean(Config.getEnv("supports_watch", "false")); public static ensure_indexes: boolean = Config.parseBoolean(Config.getEnv("ensure_indexes", "true")); public static text_index_name_fields: string[] = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names")); - public static metadata_collections: string[] = Config.parseArray(Config.getEnv("metadata_collections", "")); public static auto_create_users: boolean = Config.parseBoolean(Config.getEnv("auto_create_users", "false")); public static auto_create_user_from_jwt: boolean = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false")); @@ -664,7 +205,6 @@ export class Config { public static persist_user_impersonation: boolean = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true")); public static ping_clients_interval: number = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 10 seconds - public static allow_personal_nodered: boolean = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false")); public static use_ingress_beta1_syntax: boolean = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "false")); public static use_openshift_routes: boolean = Config.parseBoolean(Config.getEnv("use_openshift_routes", "false")); public static agent_image_pull_secrets: string[] = Config.parseArray(Config.getEnv("agent_image_pull_secrets", "")); @@ -772,8 +312,6 @@ export class Config { public static downloadtoken_expires_in: string = Config.getEnv("downloadtoken_expires_in", "15m"); public static personalnoderedtoken_expires_in: string = Config.getEnv("personalnoderedtoken_expires_in", "365d"); - // public static nodered_image: string = Config.getEnv("nodered_image", "openiap/nodered"); - public static nodered_images: NoderedImage[] = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]")); public static agent_images: NoderedImage[] = JSON.parse(Config.getEnv("agent_images", JSON.stringify([{"name":"Agent", "image":"openiap/nodeagent", "languages": ["nodejs", "python"]}, {"name":"Agent+Chromium", "image":"openiap/nodechromiumagent", "chromium": true, "languages": ["nodejs", "python"]}, {"name":"NodeRED", "image":"openiap/noderedagent", "port": 3000}, {"name":"DotNet 6", "image":"openiap/dotnetagent", "languages": ["dotnet"]} , {"name":"PowerShell 7.3", "image":"openiap/nodeagent:pwsh", "languages": ["powershell"]} ]) )); @@ -802,10 +340,6 @@ export class Config { public static nodered_domain_schema: string = Config.getEnv("nodered_domain_schema", ""); // also sent to website public static nodered_initial_liveness_delay: number = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60")); public static nodered_allow_nodeselector: boolean = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false")); - // public static nodered_requests_memory: string = Config.getEnv("nodered_requests_memory", ""); - // public static nodered_requests_cpu: string = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU - // public static nodered_limits_memory: string = Config.getEnv("nodered_limits_memory", ""); - // public static nodered_limits_cpu: string = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU public static nodered_liveness_failurethreshold: number = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5")); public static nodered_liveness_timeoutseconds: number = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5")); public static noderedcatalogues: string = Config.getEnv("noderedcatalogues", ""); @@ -835,18 +369,19 @@ export class Config { public static otel_trace_mongodb_update_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false")); public static otel_trace_mongodb_delete_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false")); - public static grpc_keepalive_time_ms = parseInt(Config.getEnv("grpc_keepalive_time_ms", "-1")); - public static grpc_keepalive_timeout_ms = parseInt(Config.getEnv("grpc_keepalive_timeout_ms", "-1")); - public static grpc_http2_min_ping_interval_without_data_ms = parseInt(Config.getEnv("grpc_http2_min_ping_interval_without_data_ms", "-1")); - public static grpc_max_connection_idle_ms = parseInt(Config.getEnv("grpc_max_connection_idle_ms", "-1")); - public static grpc_max_connection_age_ms = parseInt(Config.getEnv("grpc_max_connection_age_ms", "-1")); - public static grpc_max_connection_age_grace_ms = parseInt(Config.getEnv("grpc_max_connection_age_grace_ms", "-1")); - public static grpc_http2_max_pings_without_data = parseInt(Config.getEnv("grpc_http2_max_pings_without_data", "-1")); - public static grpc_keepalive_permit_without_calls = parseInt(Config.getEnv("grpc_keepalive_permit_without_calls", "-1")); - public static grpc_max_receive_message_length = parseInt(Config.getEnv("grpc_max_receive_message_length", "-1")); - public static grpc_max_send_message_length = parseInt(Config.getEnv("grpc_max_send_message_length", "-1")); + public static grpc_keepalive_time_ms: number = parseInt(Config.getEnv("grpc_keepalive_time_ms", "-1")); + public static grpc_keepalive_timeout_ms: number = parseInt(Config.getEnv("grpc_keepalive_timeout_ms", "-1")); + public static grpc_http2_min_ping_interval_without_data_ms: number = parseInt(Config.getEnv("grpc_http2_min_ping_interval_without_data_ms", "-1")); + public static grpc_max_connection_idle_ms: number = parseInt(Config.getEnv("grpc_max_connection_idle_ms", "-1")); + public static grpc_max_connection_age_ms: number = parseInt(Config.getEnv("grpc_max_connection_age_ms", "-1")); + public static grpc_max_connection_age_grace_ms: number = parseInt(Config.getEnv("grpc_max_connection_age_grace_ms", "-1")); + public static grpc_http2_max_pings_without_data: number = parseInt(Config.getEnv("grpc_http2_max_pings_without_data", "-1")); + public static grpc_keepalive_permit_without_calls: number = parseInt(Config.getEnv("grpc_keepalive_permit_without_calls", "-1")); + public static grpc_max_receive_message_length: number = parseInt(Config.getEnv("grpc_max_receive_message_length", "-1")); + public static grpc_max_send_message_length: number = parseInt(Config.getEnv("grpc_max_send_message_length", "-1")); public static validate_user_form: string = Config.getEnv("validate_user_form", ""); + public static externalbaseurl(): string { let result: string = ""; diff --git a/OpenFlow/src/DatabaseConnection.ts b/OpenFlow/src/DatabaseConnection.ts index 4c6f9bac..6f98b108 100644 --- a/OpenFlow/src/DatabaseConnection.ts +++ b/OpenFlow/src/DatabaseConnection.ts @@ -411,6 +411,7 @@ export class DatabaseConnection extends events.EventEmitter { if (collectionname === "config" && _type === "config") { discardspan = false; await dbConfig.Reload(Crypt.rootToken(), span); + } } span.updateName("Watch " + collectionname + " " + next.operationType + " " + _type); @@ -1090,9 +1091,11 @@ export class DatabaseConnection extends events.EventEmitter { // } } span?.setAttribute("results", arr.length); - let ms = Logger.otel.endTimer(ot_end, DatabaseConnection.mongodb_query, DatabaseConnection.otel_label(collectionname, user, "query")); + var ms = Logger.otel.endTimer(ot_end, DatabaseConnection.mongodb_query, DatabaseConnection.otel_label(collectionname, user, "query")); if (decrypt) for (let i: number = 0; i < arr.length; i++) { arr[i] = this.decryptentity(arr[i]); } DatabaseConnection.traversejsondecode(arr); + var log_database_queries = Config.log_database_queries; + var log_database_queries_ms = Config.log_database_queries_ms; if (Config.log_database_queries && ms >= Config.log_database_queries_ms) { Logger.instanse.debug(JSON.stringify(query), span, { collection: collectionname, user: user?.username, ms, count: arr.length }); } else { diff --git a/OpenFlow/src/Logger.ts b/OpenFlow/src/Logger.ts index 7000d31d..2f7c85f5 100644 --- a/OpenFlow/src/Logger.ts +++ b/OpenFlow/src/Logger.ts @@ -96,6 +96,10 @@ export class Logger { } public json(obj, span: Span) { if (Config.unittesting) return; + if(obj.func == "_Housekeeping") { + obj.cls = "Housekeeping"; + } + const { cls, func, message, lvl } = obj; if (!NoderedUtil.IsNullEmpty(func) && span != null && span.isRecording()) { var stringifyError = function (err, filter, space) { @@ -112,10 +116,9 @@ export class Logger { } span.addEvent(obj.message, obj) } - if (obj.ms != null && obj.ms != "") { + if (obj.ms != null && obj.ms != "" && obj.func != "query" && Config.log_database_queries) { if (obj.ms < Config.log_database_queries_ms) return; - } - if (Logger.enabled[cls]) { + } else if (Logger.enabled[cls]) { if (Logger.enabled[cls] < lvl) return; } else { if (Config.log_silly) { @@ -279,7 +282,7 @@ export class Logger { if (Config.db != null) await Config.db.shutdown(); await Logger.otel.shutdown(); } - public static reload() { + public static async reload() { Logger.log_with_trace = Config.log_with_trace; Logger.usecolors = Config.log_with_colors; // if (Config.NODE_ENV == "development") Logger.log_with_trace = true; @@ -302,6 +305,11 @@ export class Logger { if (Config.otel_err_log) Logger.enabled["WebSocketServerClient"] = level.Error; if (Config.log_database_queries) Logger.enabled["log_database_queries"] = level.Verbose; + try { + await Logger.License?.validate(); + } catch (error) { + + } } static hasDockerEnv(): boolean { try { @@ -333,114 +341,125 @@ export class Logger { Logger._isKubernetes = true; return true; } - + static async relaodotel() { + + } + static _otel_require: any = null; static async configure(skipotel: boolean, skiplic: boolean): Promise { Logger.DBHelper = new DBHelper(); - Logger.reload() - Logger.instanse = new Logger(); - let _lic_require: any = null; - try { - if (!skiplic) _lic_require = require("./ee/license-file"); - } catch (error) { - } - if (_lic_require != null) { - Logger.License = new _lic_require.LicenseFile(); - } else { - Logger.License = {} as any; - Logger.License.ofid = Logger.ofid; - Logger.License.shutdown = () => undefined; + await Logger.reload() + if(Logger.instanse == null) Logger.instanse = new Logger(); + if(Logger.License == null) { + let _lic_require: any = null; + try { + if (!skiplic && _lic_require == null) _lic_require = require("./ee/license-file"); + } catch (error) { + } + if (_lic_require != null) { + Logger.License = new _lic_require.LicenseFile(); + } else { + Logger.License = {} as any; + Logger.License.ofid = Logger.ofid; + Logger.License.shutdown = () => undefined; + } } - let _otel_require: any = null; - try { - if (!skipotel) _otel_require = require("./ee/otel"); - } catch (error) { - - } - if (_otel_require != null) { - Logger.otel = await _otel_require.otel.configure(); + if(Logger.otel == null) { + try { + if (!skipotel && Logger._otel_require == null) Logger._otel_require = require("./ee/otel"); + } catch (error) { + + } + if (Logger._otel_require != null) { + Logger.otel = await Logger._otel_require.otel.configure(); + } else { + const fakespan = { + context: () => undefined, + setAttribute: () => undefined, + setAttributes: () => undefined, + addEvent: () => undefined, + setStatus: () => undefined, + updateName: () => undefined, + end: () => undefined, + isRecording: () => undefined, + recordException: () => undefined, + }; + Logger.otel = + { + startSpan: () => fakespan, + startSubSpan: () => fakespan, + startSpanExpress: () => fakespan, + GetTraceSpanId(span: Span): [string, string] { return ["", ""]; }, + endSpan: () => undefined, + startTimer: () => undefined, + endTimer: () => undefined, + setdefaultlabels: () => undefined, + shutdown: () => undefined, + meter: { + createHistogram: () => undefined, + createCounter: () => undefined, + createObservableUpDownCounter: () => undefined, + createUpDownCounter: () => undefined, + createValueObserver: () => undefined, + createObservableGauge: () => undefined, + } + } as any; + } } else { - const fakespan = { - context: () => undefined, - setAttribute: () => undefined, - setAttributes: () => undefined, - addEvent: () => undefined, - setStatus: () => undefined, - updateName: () => undefined, - end: () => undefined, - isRecording: () => undefined, - recordException: () => undefined, - }; - Logger.otel = - { - startSpan: () => fakespan, - startSubSpan: () => fakespan, - startSpanExpress: () => fakespan, - GetTraceSpanId(span: Span): [string, string] { return ["", ""]; }, - endSpan: () => undefined, - startTimer: () => undefined, - endTimer: () => undefined, - setdefaultlabels: () => undefined, - shutdown: () => undefined, - meter: { - createHistogram: () => undefined, - createCounter: () => undefined, - createObservableUpDownCounter: () => undefined, - createUpDownCounter: () => undefined, - createValueObserver: () => undefined, - createObservableGauge: () => undefined, - } - } as any; + if (Logger._otel_require != null) { + Logger.otel = await Logger._otel_require.otel.configure(); + } } - this.agentdriver = null; // with npm -omit=optional we need to install npm i openid-client + if(this.agentdriver == null) { + this.agentdriver = null; // with npm -omit=optional we need to install npm i openid-client - if (NoderedUtil.IsNullEmpty(process.env["USE_KUBERNETES"])) { - try { - this.agentdriver = new dockerdriver(); - if (!(await this.agentdriver.detect())) { + if (NoderedUtil.IsNullEmpty(process.env["USE_KUBERNETES"])) { + try { + this.agentdriver = new dockerdriver(); + if (!(await this.agentdriver.detect())) { + this.agentdriver = null; + } + } catch (error) { this.agentdriver = null; } - } catch (error) { - this.agentdriver = null; } - } - if (this.agentdriver == null && (!NoderedUtil.IsNullEmpty(process.env["KUBERNETES_SERVICE_HOST"]) || !NoderedUtil.IsNullEmpty(process.env["USE_KUBERNETES"]))) { - let _driver: any = null; - try { - _driver = require("./ee/kubedriver"); - } catch (error) { - console.log(error) + if (this.agentdriver == null && (!NoderedUtil.IsNullEmpty(process.env["KUBERNETES_SERVICE_HOST"]) || !NoderedUtil.IsNullEmpty(process.env["USE_KUBERNETES"]))) { + let _driver: any = null; + try { + _driver = require("./ee/kubedriver"); + } catch (error) { + console.log(error) + } + try { + if (_driver != null) { + this.agentdriver = new _driver.kubedriver(); + } else { + this.agentdriver = new dockerdriver(); + } + if (_driver != null) { + if (!(await this.agentdriver.detect())) { + this.agentdriver = null; + } + } + } catch (error) { + this.agentdriver = null; + Logger.instanse.error(error, null); + } } - try { - if (_driver != null) { - this.agentdriver = new _driver.kubedriver(); - } else { + if (this.agentdriver == null) { + try { this.agentdriver = new dockerdriver(); - } - if (_driver != null) { if (!(await this.agentdriver.detect())) { this.agentdriver = null; } - } - } catch (error) { - this.agentdriver = null; - Logger.instanse.error(error, null); - } - } - if (this.agentdriver == null) { - try { - this.agentdriver = new dockerdriver(); - if (!(await this.agentdriver.detect())) { + } catch (error) { this.agentdriver = null; + Logger.instanse.error(error, null); } - } catch (error) { - this.agentdriver = null; - Logger.instanse.error(error, null); } } - } static instanse: Logger = null; private static _ofid = null; diff --git a/OpenFlow/src/LoginProvider.ts b/OpenFlow/src/LoginProvider.ts index 4931d853..cc7c77d0 100644 --- a/OpenFlow/src/LoginProvider.ts +++ b/OpenFlow/src/LoginProvider.ts @@ -1148,7 +1148,6 @@ export class LoginProvider { wsurl: _url, domain: Config.domain, auto_create_users: Config.auto_create_users, - allow_personal_nodered: Config.allow_personal_nodered, auto_create_personal_nodered_group: Config.auto_create_personal_nodered_group, auto_create_personal_noderedapi_group: Config.auto_create_personal_noderedapi_group, namespace: Config.namespace, @@ -1162,7 +1161,6 @@ export class LoginProvider { validate_emails: Config.validate_emails, forgot_pass_emails: Config.forgot_pass_emails, supports_watch: Config.supports_watch, - nodered_images: Config.nodered_images, agent_images: Config.agent_images, amqp_enabled_exchange: Config.amqp_enabled_exchange, multi_tenant: Config.multi_tenant, diff --git a/OpenFlow/src/Messages/Message.ts b/OpenFlow/src/Messages/Message.ts index 9b283b8d..3aff3203 100644 --- a/OpenFlow/src/Messages/Message.ts +++ b/OpenFlow/src/Messages/Message.ts @@ -295,12 +295,12 @@ export class Message { // if ((error.consumedPoints % 10) == 1 || error.consumedPoints > 0) { // // Logger.instanse.warn("[" + username + "/" + cli.clientagent + "/" + cli.id + "] SOCKET_RATE_LIMIT consumedPoints: " + error.consumedPoints + " remainingPoints: " + error.remainingPoints + " msBeforeNext: " + error.msBeforeNext, span); // } - // if (error.consumedPoints >= Config.socket_rate_limit_points_disconnect) { + if (error.consumedPoints >= Config.socket_rate_limit_points_disconnect) { // Logger.instanse.warn("[" + username + "/" + cli.clientagent + "/" + cli.id + "] SOCKET_RATE_LIMIT: Disconnecing client ! consumedPoints: " + error.consumedPoints + " remainingPoints: " + error.remainingPoints + " msBeforeNext: " + error.msBeforeNext, span); // cli.devnull = true; // cli.Close(span); // return; - // } + } // setTimeout(() => { this.Process(cli); }, 250); // } // return; @@ -591,7 +591,7 @@ export class Message { await this.DeleteWorkitem(span); break; case "customcommand": - await this.CustomCommand(span); + await this.CustomCommand(cli, span); break; default: if (command != "error") { @@ -3457,7 +3457,7 @@ export class Message { const span: Span = Logger.otel.startSubSpan("message.QueueMessage", parent); try { try { - Logger.instanse.info("Ensure Indexes", span); + Logger.instanse.debug("Ensure Indexes", span); await Config.db.ensureindexes(span); } catch (error) { @@ -3465,23 +3465,23 @@ export class Message { try { if(Logger.agentdriver != null) { try { - Logger.instanse.info("HouseKeeping Run InstanceCleanup", span); + Logger.instanse.debug("HouseKeeping Run InstanceCleanup", span); await Logger.agentdriver.InstanceCleanup(span); } catch (error) { Logger.instanse.error(error, span); } const jwt: string = Crypt.rootToken(); var agents = await Config.db.query({ collectionname: "agents", query: { _type: "agent", "autostart": true }, jwt }, span); - Logger.instanse.info("HouseKeeping ensure " + agents.length + " agents", span); + Logger.instanse.debug("HouseKeeping ensure " + agents.length + " agents", span); for (let i = 0; i < agents.length; i++) { const agent = agents[i]; var pods = await Logger.agentdriver.GetInstancePods(rootuser, jwt, agent, false, span); if(pods == null || pods.length == 0) { if(agent.name != agent.slug) { - Logger.instanse.info("HouseKeeping ensure " + agent.name + " (" + agent.slug + ")", span); + Logger.instanse.debug("HouseKeeping ensure " + agent.name + " (" + agent.slug + ")", span); } else { - Logger.instanse.info("HouseKeeping ensure " + agent.name, span); + Logger.instanse.debug("HouseKeeping ensure " + agent.name, span); } try { await Logger.agentdriver.EnsureInstance(rootuser, jwt, agent, span); @@ -3500,7 +3500,7 @@ export class Message { try { const jwt: string = Crypt.rootToken(); - Logger.instanse.info("Begin validating builtin roles", span); + Logger.instanse.debug("Begin validating builtin roles", span); for(var i = 0; i < Config.db.WellknownIdsArray.length; i++) { const item: Role = await Config.db.GetOne({ query: {_id: Config.db.WellknownIdsArray[i], @@ -3539,7 +3539,7 @@ export class Message { // doensure = true; // } // if (doensure) { - // Logger.instanse.info("EnsureNoderedInstance for " + user.name, span); + // Logger.instanse.debug("EnsureNoderedInstance for " + user.name, span); // var ensuremsg: EnsureNoderedInstanceMessage = new EnsureNoderedInstanceMessage(); // ensuremsg._id = user._id; // var msg: Message = new Message(); msg.jwt = jwt; @@ -3553,7 +3553,7 @@ export class Message { } catch (error) { } - Logger.instanse.info("Begin validating prefered timeseries collections", span); + Logger.instanse.debug("Begin validating prefered timeseries collections", span); let collections = await DatabaseConnection.toArray(Config.db.db.listCollections()); try { let audit = collections.find(x => x.name == "audit"); @@ -3700,7 +3700,7 @@ export class Message { if (DatabaseConnection.usemetadata(collectionname)) { let exists = await Config.db.db.collection(collectionname).findOne({ "metadata._searchnames": { $exists: false } }); if (!NoderedUtil.IsNullUndefinded(exists)) { - Logger.instanse.info("Start creating metadata._searchnames for collection " + collectionname, span); + Logger.instanse.debug("Start creating metadata._searchnames for collection " + collectionname, span); await Config.db.db.collection(collectionname).updateMany({ "metadata._searchnames": { $exists: false } }, [ { @@ -3760,12 +3760,12 @@ export class Message { { "$set": { "metadata._searchnames": { $concatArrays: ["$metadata._searchnames", [{ $toLower: "$metadata.name" }]] } } } ] ) - Logger.instanse.info("Done creating _searchnames for collection " + collectionname, span); + Logger.instanse.debug("Done creating _searchnames for collection " + collectionname, span); } } else { let exists = await Config.db.db.collection(collectionname).findOne({ "_searchnames": { $exists: false } }); if (!NoderedUtil.IsNullUndefinded(exists)) { - Logger.instanse.info("Start creating _searchnames for collection " + collectionname, span); + Logger.instanse.debug("Start creating _searchnames for collection " + collectionname, span); await Config.db.db.collection(collectionname).updateMany({ "_searchnames": { $exists: false } }, [ { @@ -3825,7 +3825,7 @@ export class Message { { "$set": { "_searchnames": { $concatArrays: ["$_searchnames", [{ $toLower: "$name" }]] } } } ] ) - Logger.instanse.info("Done creating _searchnames for collection " + collectionname, span); + Logger.instanse.debug("Done creating _searchnames for collection " + collectionname, span); } } } @@ -4253,7 +4253,7 @@ export class Message { Logger.instanse.error(error, span); } } finally { - Logger.instanse.info("Completed housekeeping", span); + Logger.instanse.debug("Completed housekeeping", span); } } Logger.otel.endSpan(span); @@ -5148,7 +5148,7 @@ export class Message { delete msg.jwt; this.data = JSON.stringify(msg); } - async CustomCommand(parent: Span): Promise { + async CustomCommand(cli: WebSocketServerClient, parent: Span): Promise { this.Reply(); let msg: CustomCommandMessage; const rootjwt = Crypt.rootToken(); @@ -5422,7 +5422,7 @@ export class Message { if(exists != null && exists.issuemonths != null) data.months = parseInt(exists.issuemonths); } // throw new Error("Access denied"); - msg.result = Logger.License.generate2(data); + msg.result = await Logger.License.generate2(data, cli?.remoteip, this.tuser, parent); break; default: msg.error = "Unknown custom command"; diff --git a/OpenFlow/src/amqpwrapper.ts b/OpenFlow/src/amqpwrapper.ts index f0004514..681fe00f 100644 --- a/OpenFlow/src/amqpwrapper.ts +++ b/OpenFlow/src/amqpwrapper.ts @@ -558,7 +558,7 @@ export class amqpwrapper extends events.EventEmitter { } public of_logger_ready: boolean = false; async AddOFLogExchange(parent: Span) { - if (!Config.enable_openflow_amqp) return; + // if (!Config.enable_openflow_amqp) return; // Listen no matter what, but we don't use it unless enable_openflow_amqp is true await amqpwrapper.Instance().AddExchangeConsumer(Crypt.rootUser(), "openflow_logs", "fanout", "", null, null, true, async (msg: any, options: any, ack: any, done: any) => { ack(); @@ -567,7 +567,7 @@ export class amqpwrapper extends events.EventEmitter { this.of_logger_ready = true; } async AddOFExchange(parent: Span) { - if (!Config.enable_openflow_amqp) return; + // if (!Config.enable_openflow_amqp) return; // Listen no matter what, but we don't use it unless enable_openflow_amqp is true await this.AddExchangeConsumer(Crypt.rootUser(), "openflow", "fanout", "", null, null, true, async (msg: any, options: QueueMessageOptions, ack: any, done: any) => { ack(); diff --git a/OpenFlow/src/commoninterfaces.ts b/OpenFlow/src/commoninterfaces.ts index 21f5d7d9..d3c09b14 100644 --- a/OpenFlow/src/commoninterfaces.ts +++ b/OpenFlow/src/commoninterfaces.ts @@ -16,14 +16,14 @@ export interface i_license_file { licenserror: string; data: i_license_data; ofid(force: boolean): any; - validate(): void; + validate(): Promise; shutdown(): void; /** * Generate license file * * @param options */ - generate2(options: any): any; + generate2(options: any, remoteip: string, tuser: TokenUser, span: Span): Promise; /** * Generate license file * diff --git a/OpenFlow/src/index.ts b/OpenFlow/src/index.ts index 6441753e..f4446d13 100644 --- a/OpenFlow/src/index.ts +++ b/OpenFlow/src/index.ts @@ -73,6 +73,20 @@ async function initDatabase(parent: Span): Promise { const jwt: string = Crypt.rootToken(); const rootuser = Crypt.rootUser(); Config.dbConfig = await dbConfig.Load(jwt, span); + try { + var lic = Logger.License; + await lic?.validate(); + } catch (error) { + console.log(error); + } + try { + await Logger.configure(false, true); + } catch (error) { + console.error(error); + process.exit(404); + } + + const admins: Role = await Logger.DBHelper.EnsureRole(jwt, "admins", WellknownIds.admins, span); const users: Role = await Logger.DBHelper.EnsureRole(jwt, "users", WellknownIds.users, span); @@ -435,13 +449,6 @@ var server: http.Server = null; await Config.db.connect(span); await initamqp(span); Logger.instanse.info("VERSION: " + Config.version, span); - if (Logger.License.validlicense) { - if (NoderedUtil.IsNullEmpty(Logger.License.data.domain)) { - Logger.instanse.info("License valid to " + Logger.License.data.expirationDate, span); - } else { - Logger.instanse.info("License valid for " + Logger.License.data.domain + " until the " + Logger.License.data.expirationDate, span); - } - } server = await WebServer.configure(Config.baseurl(), span); if (GrafanaProxy != null) { const grafana = await GrafanaProxy.GrafanaProxy.configure(WebServer.app, span); diff --git a/OpenFlow/src/public/Config.html b/OpenFlow/src/public/Config.html new file mode 100644 index 00000000..8f086dd4 --- /dev/null +++ b/OpenFlow/src/public/Config.html @@ -0,0 +1,102 @@ + + +
+
+ enabled streaming to + Console +
+ cache + amqp + websocket + webserver + oauth + database + grafana + housekeeping + login_provider + otel + blocked_ips + + open-api + +
database queries + ms + +
On high volume systems, these 3 can crash your system!!! + debug + verbose + silly +
+
+
+ + +
+ + {{ctrl.model.version}} + + {{ctrl.model.updatedat}} +
+ +
+ + + + + + + +
diff --git a/OpenFlow/src/public/Controllers.ts b/OpenFlow/src/public/Controllers.ts index 5a3809f4..8c8e8c2b 100644 --- a/OpenFlow/src/public/Controllers.ts +++ b/OpenFlow/src/public/Controllers.ts @@ -7247,9 +7247,11 @@ export class ConsoleCtrl extends entityCtrl { WebSocketClientService.onSignedin(async (_user: TokenUser) => { await this.RegisterQueue(); this.loadData(); + this.loading = false; this.$scope.$on('signin', (event, data) => { this.RegisterQueue(); this.loadData(); + this.loading = false; }); }); } @@ -7371,6 +7373,379 @@ export class ConsoleCtrl extends entityCtrl { } } +export class ConfigCtrl extends entityCtrl { + public arguments: any; + public users: TokenUser[]; + public user: TokenUser; + public messages: any[] = []; + public watchid: string = ""; + public timeout: string = (60 * 1000).toString(); // 1 min; + public lines: string = "100"; + public exchange: RegisterExchangeResponse = null; + public paused: boolean = false; + public host: boolean = false; + public agent: boolean = false; + public cls: boolean = false; + public func: boolean = true; + public searchstring: string = ""; + public settings: any[] = []; + constructor( + public $rootScope: ng.IRootScopeService, + public $scope: ng.IScope, + public $location: ng.ILocationService, + public $routeParams: ng.route.IRouteParamsService, + public $sce: ng.ISCEService, + public $interval: ng.IIntervalService, + public WebSocketClientService: WebSocketClientService, + public api: api, + public userdata: userdata + ) { + super($rootScope, $scope, $location, $routeParams, $sce, $interval, WebSocketClientService, api, userdata); + console.debug("ConsoleCtrl"); + this.collection = "config"; + this.basequery = { "_type": "config" } + this.messages = []; + this.postloadData = this.processdata; + this.settings = [ + {"name": "license_key", "type": "string", "default": ""}, + {"name": "enable_openai", "type": "boolean", "default": "false"}, + {"name": "enable_openapi", "type": "boolean", "default": "true"}, + {"name": "enable_openaiauth", "type": "boolean", "default": "true"}, + {"name": "openai_token", "type": "string", "default": ""}, + {"name": "log_with_colors", "type": "boolean", "default": "true"}, + {"name": "cache_store_type", "type": "string", "default": "memory"}, + {"name": "cache_store_max", "type": "number", "default": "1000"}, + {"name": "cache_store_ttl_seconds", "type": "number", "default": "300"}, + {"name": "cache_store_redis_host", "type": "string", "default": ""}, + {"name": "cache_store_redis_port", "type": "number", "default": "6379"}, + {"name": "cache_store_redis_password", "type": "string", "default": ""}, + {"name": "cache_workitem_queues", "type": "boolean", "default": "false"}, + {"name": "heapdump_onstop", "type": "boolean", "default": "false"}, + {"name": "amqp_allow_replyto_empty_queuename", "type": "boolean", "default": "false"}, + {"name": "enable_openflow_amqp", "type": "boolean", "default": "false"}, + // {"name": "log_to_exchange", "type": "boolean", "default": "false"}, + {"name": "openflow_amqp_expiration", "type": "number", "default": "1500000"}, // 25 min in milliseconds + {"name": "amqp_prefetch", "type": "number", "default": "25"}, + {"name": "enable_entity_restriction", "type": "boolean", "default": "false"}, + {"name": "enable_web_tours", "type": "boolean", "default": "true"}, + {"name": "enable_nodered_tours", "type": "boolean", "default": "true"}, + {"name": "grafana_url", "type": "string", "default": ""}, + {"name": "auto_hourly_housekeeping", "type": "boolean", "default": "true"}, + {"name": "housekeeping_skip_collections", "type": "string", "default": ""}, + {"name": "workitem_queue_monitoring_enabled", "type": "boolean", "default": "true"}, + {"name": "workitem_queue_monitoring_interval", "type": "number", "default": "10000"}, // 10 sec + {"name": "upload_max_filesize_mb", "type": "number", "default": "25"}, + {"name": "getting_started_url", "type": "string", "default": ""}, + {"name": "NODE_ENV", "type": "string", "default": "development"}, + {"name": "HTTP_PROXY", "type": "string", "default": ""}, + {"name": "HTTPS_PROXY", "type": "string", "default": ""}, + {"name": "NO_PROXY", "type": "string", "default": ""}, + {"name": "agent_HTTP_PROXY", "type": "string", "default": ""}, + {"name": "agent_HTTPS_PROXY", "type": "string", "default": ""}, + {"name": "agent_NO_PROXY", "type": "string", "default": ""}, + {"name": "stripe_api_key", "type": "string", "default": ""}, + {"name": "stripe_api_secret", "type": "string", "default": ""}, + {"name": "stripe_force_vat", "type": "boolean", "default": "false"}, + {"name": "stripe_force_checkout", "type": "boolean", "default": "false"}, + {"name": "stripe_allow_promotion_codes", "type": "boolean", "default": "true"}, + {"name": "supports_watch", "type": "boolean", "default": "false"}, + {"name": "ensure_indexes", "type": "boolean", "default": "true"}, + {"name": "text_index_name_fields", "type": "string[]", "default": "name,_names"}, + {"name": "auto_create_users", "type": "boolean", "default": "false"}, + {"name": "auto_create_user_from_jwt", "type": "boolean", "default": "false"}, + {"name": "auto_create_domains", "type": "string[]", "default": ""}, + {"name": "persist_user_impersonation", "type": "boolean", "default": "true"}, + {"name": "ping_clients_interval", "type": "number", "default": "10000"}, // 10 seconds + {"name": "use_ingress_beta1_syntax", "type": "boolean", "default": "false"}, + {"name": "use_openshift_routes", "type": "boolean", "default": "false"}, + {"name": "agent_image_pull_secrets", "type": "string[]", "default": ""}, + {"name": "auto_create_personal_nodered_group", "type": "boolean", "default": "false"}, + {"name": "auto_create_personal_noderedapi_group", "type": "boolean", "default": "false"}, + {"name": "force_add_admins", "type": "boolean", "default": "true"}, + {"name": "validate_emails", "type": "boolean", "default": "false"}, + {"name": "forgot_pass_emails", "type": "boolean", "default": "false"}, + {"name": "smtp_service", "type": "string", "default": ""}, + {"name": "smtp_from", "type": "string", "default": ""}, + {"name": "smtp_user", "type": "string", "default": ""}, + {"name": "smtp_pass", "type": "string", "default": ""}, + {"name": "smtp_url", "type": "string", "default": ""}, + {"name": "debounce_lookup", "type": "boolean", "default": "false"}, + {"name": "validate_emails_disposable", "type": "boolean", "default": "false"}, + {"name": "tls_crt", "type": "string", "default": ""}, + {"name": "tls_key", "type": "string", "default": ""}, + {"name": "tls_ca", "type": "string", "default": ""}, + {"name": "tls_passphrase", "type": "string", "default": ""}, + + {"name": "oidc_access_token_ttl", "type": "number", "default": "480"}, + {"name": "oidc_authorization_code_ttl", "type": "number", "default": "480"}, + {"name": "oidc_client_credentials_ttl", "type": "number", "default": "480"}, + {"name": "oidc_refresh_token_ttl", "type": "number", "default": "20160"}, + {"name": "oidc_session_ttl", "type": "number", "default": "20160"}, + + {"name": "oidc_cookie_key", "type": "string", "default": ""}, + {"name": "api_rate_limit", "type": "boolean", "default": "true"}, + {"name": "api_rate_limit_points", "type": "number", "default": "20"}, + {"name": "api_rate_limit_duration", "type": "number", "default": "1"}, + {"name": "socket_rate_limit", "type": "boolean", "default": "true"}, + {"name": "socket_rate_limit_points", "type": "number", "default": "30"}, + {"name": "socket_rate_limit_points_disconnect", "type": "number", "default": "100"}, + {"name": "socket_rate_limit_duration", "type": "number", "default": "1"}, + {"name": "socket_error_rate_limit_points", "type": "number", "default": "30"}, + {"name": "socket_error_rate_limit_duration", "type": "number", "default": "1"}, + + {"name": "client_heartbeat_timeout", "type": "number", "default": "60"}, + {"name": "client_signin_timeout", "type": "number", "default": "120"}, + {"name": "client_disconnect_signin_error", "type": "boolean", "default": "false"}, + + {"name": "expected_max_roles", "type": "number", "default": "20000"}, + {"name": "decorate_roles_fetching_all_roles", "type": "boolean", "default": "true"}, + {"name": "max_recursive_group_depth", "type": "number", "default": "2"}, + {"name": "update_acl_based_on_groups", "type": "boolean", "default": "true"}, + {"name": "allow_merge_acl", "type": "boolean", "default": "false"}, + + {"name": "multi_tenant", "type": "boolean", "default": "false"}, + {"name": "cleanup_on_delete_customer", "type": "boolean", "default": "false"}, + {"name": "cleanup_on_delete_user", "type": "boolean", "default": "false"}, + {"name": "api_bypass_perm_check", "type": "boolean", "default": "false"}, + {"name": "ignore_expiration", "type": "boolean", "default": "false"}, + {"name": "force_audit_ts", "type": "boolean", "default": "false"}, + {"name": "force_dbusage_ts", "type": "boolean", "default": "false"}, + {"name": "migrate_audit_to_ts", "type": "boolean", "default": "true"}, + {"name": "websocket_package_size", "type": "number", "default": "25000"}, + {"name": "websocket_max_package_count", "type": "number", "default": "25000"}, + {"name": "websocket_message_callback_timeout", "type": "number", "default": "3600"}, + {"name": "websocket_disconnect_out_of_sync", "type": "boolean", "default": "false"}, + {"name": "protocol", "type": "string", "default": "http"}, + {"name": "port", "type": "number", "default": "80"}, + {"name": "domain", "type": "string", "default": "localhost"}, + {"name": "cookie_secret", "type": "string", "default": "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu"}, + {"name": "max_ace_count", "type": "number", "default": "128"}, + + {"name": "amqp_reply_expiration", "type": "number", "default": "60000"}, + {"name": "amqp_force_queue_prefix", "type": "boolean", "default": "false"}, + {"name": "amqp_force_exchange_prefix", "type": "boolean", "default": "false"}, + {"name": "amqp_force_sender_has_read", "type": "boolean", "default": "true"}, + {"name": "amqp_force_sender_has_invoke", "type": "boolean", "default": "false"}, + {"name": "amqp_force_consumer_has_update", "type": "boolean", "default": "false"}, + {"name": "amqp_enabled_exchange", "type": "boolean", "default": "false"}, + {"name": "amqp_url", "type": "string", "default": "amqp://localhost"}, + {"name": "amqp_username", "type": "string", "default": "guest"}, + {"name": "amqp_password", "type": "string", "default": "guest"}, + + {"name": "amqp_check_for_consumer", "type": "boolean", "default": "true"}, + {"name": "amqp_check_for_consumer_count", "type": "boolean", "default": "false"}, + {"name": "amqp_default_expiration", "type": "number", "default": "60000"}, + {"name": "amqp_requeue_time", "type": "number", "default": "1000"}, + {"name": "amqp_dlx", "type": "string", "default": "openflow-dlx"}, + + {"name": "mongodb_url", "type": "string", "default": "mongodb://localhost:27017"}, + {"name": "mongodb_db", "type": "string", "default": "openflow"}, + {"name": "mongodb_minpoolsize", "type": "number", "default": "25"}, + {"name": "mongodb_maxpoolsize", "type": "number", "default": "25"}, + + {"name": "skip_history_collections", "type": "string", "default": "audit,openrpa_instances,workflow_instances"}, + {"name": "history_delta_count", "type": "number", "default": "1000"}, + {"name": "allow_skiphistory", "type": "boolean", "default": "false"}, + {"name": "max_memory_restart_mb", "type": "number", "default": "0"}, + {"name": "saml_issuer", "type": "string", "default": "the-issuer"}, + // {"name": "aes_secret", "type": "string", "default": ""}, + {"name": "signing_crt", "type": "string", "default": ""}, + {"name": "singing_key", "type": "string", "default": ""}, + {"name": "wapid_mail", "type": "string", "default": ""}, + {"name": "wapid_pub", "type": "string", "default": ""}, + {"name": "wapid_key", "type": "string", "default": ""}, + {"name": "shorttoken_expires_in", "type": "string", "default": "5m"}, + {"name": "longtoken_expires_in", "type": "string", "default": "365d"}, + {"name": "downloadtoken_expires_in", "type": "string", "default": "15m"}, + {"name": "personalnoderedtoken_expires_in", "type": "string", "default": "365d"}, + {"name": "agent_images", "type": "NoderedImage[]", "default": "[{\"name\":\"Agent\", \"image\":\"openiap/nodeagent\", \"languages\": [\"nodejs\", \"python\"]}, {\"name\":\"Agent+Chromium\", \"image\":\"openiap/nodechromiumagent\", \"chromium\": true, \"languages\": [\"nodejs\", \"python\"]}, {\"name\":\"NodeRED\", \"image\":\"openiap/noderedagent\", \"port\": 3000}, {\"name\":\"DotNet 6\", \"image\":\"openiap/dotnetagent\", \"languages\": [\"dotnet\"]} , {\"name\":\"PowerShell 7.3\", \"image\":\"openiap/nodeagent:pwsh\", \"languages\": [\"powershell\"]}]"}, + {"name": "agent_domain_schema", "type": "string", "default": ""}, + {"name": "agent_node_selector", "type": "string", "default": ""}, + {"name": "agent_apiurl", "type": "string", "default": ""}, + {"name": "agent_oidc_config", "type": "string", "default": ""}, + {"name": "agent_oidc_client_id", "type": "string", "default": ""}, + {"name": "agent_oidc_client_secret", "type": "string", "default": ""}, + {"name": "agent_oidc_userinfo_endpoint", "type": "string", "default": ""}, + {"name": "agent_oidc_issuer", "type": "string", "default": ""}, + {"name": "agent_oidc_authorization_endpoint", "type": "string", "default": ""}, + {"name": "agent_oidc_token_endpoint", "type": "string", "default": ""}, + {"name": "saml_federation_metadata", "type": "string", "default": ""}, + {"name": "api_ws_url", "type": "string", "default": ""}, + {"name": "nodered_ws_url", "type": "string", "default": ""}, + {"name": "nodered_saml_entrypoint", "type": "string", "default": ""}, + {"name": "agent_docker_entrypoints", "type": "string", "default": "web"}, + {"name": "agent_docker_use_project", "type": "boolean", "default": "false"}, + {"name": "agent_docker_certresolver", "type": "string", "default": ""}, + {"name": "namespace", "type": "string", "default": ""}, + {"name": "nodered_domain_schema", "type": "string", "default": ""}, + {"name": "nodered_initial_liveness_delay", "type": "number", "default": "60"}, + {"name": "nodered_allow_nodeselector", "type": "boolean", "default": "false"}, + {"name": "nodered_liveness_failurethreshold", "type": "number", "default": "5"}, + {"name": "nodered_liveness_timeoutseconds", "type": "number", "default": "5"}, + {"name": "noderedcatalogues", "type": "string", "default": ""}, + + {"name": "otel_measure_nodeid", "type": "boolean", "default": "false"}, + {"name": "otel_measure_queued_messages", "type": "boolean", "default": "false"}, + {"name": "otel_measure__mongodb_watch", "type": "boolean", "default": "false"}, + {"name": "otel_measure_onlineuser", "type": "boolean", "default": "false"}, + {"name": "enable_analytics", "type": "boolean", "default": "true"}, + {"name": "enable_detailed_analytic", "type": "boolean", "default": "false"}, + {"name": "otel_debug_log", "type": "boolean", "default": "false"}, + {"name": "otel_warn_log", "type": "boolean", "default": "false"}, + {"name": "otel_err_log", "type": "boolean", "default": "false"}, + {"name": "otel_trace_url", "type": "string", "default": ""}, + {"name": "otel_metric_url", "type": "string", "default": ""}, + {"name": "otel_trace_interval", "type": "number", "default": "5000"}, + {"name": "otel_metric_interval", "type": "number", "default": "5000"}, + {"name": "otel_trace_pingclients", "type": "boolean", "default": "false"}, + {"name": "otel_trace_dashboardauth", "type": "boolean", "default": "false"}, + {"name": "otel_trace_include_query", "type": "boolean", "default": "false"}, + {"name": "otel_trace_connection_ips", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_query_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_count_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_aggregate_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_insert_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_update_per_users", "type": "boolean", "default": "false"}, + {"name": "otel_trace_mongodb_delete_per_users", "type": "boolean", "default": "false"}, + + {"name": "grpc_keepalive_time_ms", "type": "number", "default": "-1"}, + {"name": "grpc_keepalive_timeout_ms", "type": "number", "default": "-1"}, + {"name": "grpc_http2_min_ping_interval_without_data_ms", "type": "number", "default": "-1"}, + {"name": "grpc_max_connection_idle_ms", "type": "number", "default": "-1"}, + {"name": "grpc_max_connection_age_ms", "type": "number", "default": "-1"}, + {"name": "grpc_max_connection_age_grace_ms", "type": "number", "default": "-1"}, + {"name": "grpc_http2_max_pings_without_data", "type": "number", "default": "-1"}, + {"name": "grpc_keepalive_permit_without_calls", "type": "number", "default": "-1"}, + {"name": "grpc_max_receive_message_length", "type": "number", "default": "-1"}, + {"name": "grpc_max_send_message_length", "type": "number", "default": "-1"}, + {"name": "validate_user_form", "type": "string", "default": ""} + ] + WebSocketClientService.onSignedin(async (_user: TokenUser) => { + await this.RegisterWatch(); + console.log("Load data") + this.loading = false; + this.loadData(); + this.$scope.$on('signin', (event, data) => { + this.RegisterWatch(); + console.log("Load data") + this.loading = false; + this.loadData(); + }); + }); + } + async RegisterWatch() { + console.log("RegisterWatch") + try { + if (!NoderedUtil.IsNullEmpty(this.watchid)) { + await NoderedUtil.UnWatch({ id: this.watchid }); + } + this.watchid = await NoderedUtil.Watch({ + aggregates: [{ "$match": { "fullDocument._type": "config" } }], collectionname: "config", callback: (data) => { + console.log(data); + this.loading = false; + this.loadData(); + } + }) + console.debug("watchid: ", this.watchid); + } catch (error) { + console.debug("register queue failed, start reconnect. " + error.message ? error.message : error) + setTimeout(this.RegisterWatch.bind(this), (Math.floor(Math.random() * 6) + 1) * 500); + } + } + processdata() { + console.log("processdata") + // console.log(this.model); + // for(let i = 0; i < this.settings.length; i++) { + // if (this.model[this.settings[i].name] == null) { + // this.model[this.settings[i].name] = this.settings[i].default; + // } + // } + const ids: string[] = []; + if (this.collection == "files") { + for (let i: number = 0; i < (this.model as any).metadata._acl.length; i++) { + ids.push((this.model as any).metadata._acl[i]._id); + } + } else { + for (let i: number = 0; i < this.model._acl.length; i++) { + ids.push(this.model._acl[i]._id); + } + } + if (this.model._encrypt == null) { this.model._encrypt = []; } + if (!this.$scope.$$phase) { this.$scope.$apply(); } + this.fixtextarea(); + this.loading = false; + } + async submit(): Promise { + try { + for(let i = 0; i < this.settings.length; i++) { + if (this.model[this.settings[i].name] == null || this.model[this.settings[i].name] == "" + || this.model[this.settings[i].name] == this.settings[i].default) { + delete this.model[this.settings[i].name]; + } + } + + if (this.model._id) { + await NoderedUtil.UpdateOne({ collectionname: this.collection, item: this.model }); + } else { + await NoderedUtil.InsertOne({ collectionname: this.collection, item: this.model }); + } + // this.$location.path("/Providers"); + } catch (error) { + this.errormessage = error.message ? error.message : error; + } + if (!this.$scope.$$phase) { this.$scope.$apply(); } + } + hasprop(name) { + return this.messages.filter(x => !NoderedUtil.IsNullEmpty(x[name])).length > 0 + } + cached = {} + getstep(key, obj) { + if (this.gettype(obj) == "number") { + if (obj.toString().indexOf(".") > -1) { + var decimals = obj.toString().split(".")[1].length; + this.cached[key] = 1 / Math.pow(10, decimals); + return this.cached[key]; + } else { + if (this.cached[key]) return this.cached[key]; + } + } + this.cached[key] = 1; + return 1; + } + gettype(obj) { + return typeof obj; + } + getinputtype(obj, key) { + if (this.model._encrypt.indexOf(key)) + if (typeof obj === "string") return "text"; + if (typeof obj === "number") return "number"; + if (typeof obj === "boolean") return "checkbox"; + } + + isobject(object: any) { + return typeof object === 'object'; + } + fixtextarea() { + setTimeout(() => { + const tx = document.getElementsByTagName('textarea'); + for (let i = 0; i < tx.length; i++) { + tx[i].setAttribute('style', 'height:' + (tx[i].scrollHeight) + 'px;overflow-y:hidden;'); + } + }, 500); + } + delayhandler = null; + delayedUpdate() { + if(this.loading == true) return; + if(this.delayhandler ! = null) return; + console.log("delayedUpdate", this.loading) + this.delayhandler = setTimeout(() => { + console.log("do it") + this.delayhandler = null; + this.submit(); + }, 500); + } +} export class AgentsCtrl extends entitiesCtrl { diff --git a/OpenFlow/src/public/Nodered.html b/OpenFlow/src/public/Nodered.html deleted file mode 100644 index 6d4e2a68..00000000 --- a/OpenFlow/src/public/Nodered.html +++ /dev/null @@ -1,682 +0,0 @@ -
-

nodered

-
- -
-
-
-
- - - - - - - Open - Nodered -
-
-
-
- -
-
-
- -
- {{ instance.metadata.name }} -
- -
- {{ instance.metrics.cpu + "/" + - instance.spec.containers[0].resources.limits.cpu }} -
- -
- {{ instance.metrics.memory + "/" + - instance.spec.containers[0].resources.limits.memory }} -
- -
- {{ (this.instance.metadata.deletionTimestamp != null ? " deleting" : - instance.status.phase) }} -
- -
- - - -
-
-
- -
- {{ instance.Image || instance.spec.containers[0].image }} -
-
- - -
-
-
- {{ instance.status.message }} -
-
-
-
-
-
- -
-
{{ ctrl.instancelog }}
-
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- -
- -
-
- - - -
-
-
- -
- -
-
-
-
-
- -
- - {{key + '=' + - ctrl.label[key]}} -
- - - - -
-
-
-
-
-
- -
-
-
-
-
- - Free nodered instances will be shutdown after 8 hours. Create a customer, and add billing information, in order to - buy the option to get more RAM for a nodered that will not stop after 8 hours. - -
-
\ No newline at end of file diff --git a/OpenFlow/src/public/WebSocketClientService.ts b/OpenFlow/src/public/WebSocketClientService.ts index 4ee5e0dd..c1f702ba 100644 --- a/OpenFlow/src/public/WebSocketClientService.ts +++ b/OpenFlow/src/public/WebSocketClientService.ts @@ -26,7 +26,6 @@ export class WebSocketClientService { this.version = data.version; this.allow_user_registration = data.allow_user_registration; - this.allow_personal_nodered = data.allow_personal_nodered; this.auto_create_personal_nodered_group = data.auto_create_personal_nodered_group; this.namespace = data.namespace; this.nodered_domain_schema = data.nodered_domain_schema; @@ -39,7 +38,6 @@ export class WebSocketClientService { this.forgot_pass_emails = data.forgot_pass_emails; this.multi_tenant = data.multi_tenant; - this.nodered_images = data.nodered_images; this.agent_images = data.agent_images; this.enable_entity_restriction = data.enable_entity_restriction; this.enable_web_tours = data.enable_web_tours; @@ -180,7 +178,6 @@ export class WebSocketClientService { public connected: boolean = false; public domain: string = ""; public allow_user_registration: boolean = false; - public allow_personal_nodered: boolean = false; public auto_create_personal_nodered_group: boolean = false; public namespace: string = ""; public nodered_domain_schema: string = ""; @@ -190,7 +187,6 @@ export class WebSocketClientService { public validate_user_form: string = ""; public validate_emails: boolean = false; public forgot_pass_emails: boolean = false; - public nodered_images: nodered_image[]; public agent_images: nodered_image[]; public multi_tenant: boolean; public enable_entity_restriction: boolean; diff --git a/OpenFlow/src/public/app.ts b/OpenFlow/src/public/app.ts index 34be772f..569a07ac 100644 --- a/OpenFlow/src/public/app.ts +++ b/OpenFlow/src/public/app.ts @@ -5,7 +5,9 @@ import { MenuCtrl, ProvidersCtrl, MainCtrl, LoginCtrl, ProviderCtrl, UsersCtrl, UserCtrl, RolesCtrl, RoleCtrl, RPAWorkflowsCtrl, RPAWorkflowCtrl, WorkflowsCtrl, ReportsCtrl, EditFormCtrl, FormsCtrl, FormCtrl, FilesCtrl, EntitiesCtrl, EntityCtrl, HistoryCtrl, hdrobotsCtrl, ClientsCtrl, AuditlogsCtrl, CredentialsCtrl, CredentialCtrl, DuplicatesCtrl, - OAuthClientsCtrl, OAuthClientCtrl, DeletedCtrl, CustomerCtrl, EntityRestrictionsCtrl, EntityRestrictionCtrl, CustomersCtrl, ResourcesCtrl, ResourceCtrl, WorkitemsCtrl, WorkitemCtrl, WorkitemQueuesCtrl, WorkitemQueueCtrl, MailHistCtrl, MailHistsCtrl, FormResourcesCtrl, FormResourceCtrl, WebsocketClientsCtrl, ConsoleCtrl, AgentsCtrl, AgentCtrl, PackagesCtrl, PackageCtrl, RunPackageCtrl + OAuthClientsCtrl, OAuthClientCtrl, DeletedCtrl, CustomerCtrl, EntityRestrictionsCtrl, EntityRestrictionCtrl, CustomersCtrl, ResourcesCtrl, + ResourceCtrl, WorkitemsCtrl, WorkitemCtrl, WorkitemQueuesCtrl, WorkitemQueueCtrl, MailHistCtrl, MailHistsCtrl, FormResourcesCtrl, FormResourceCtrl, + WebsocketClientsCtrl, ConsoleCtrl, AgentsCtrl, AgentCtrl, PackagesCtrl, PackageCtrl, RunPackageCtrl, ConfigCtrl } from "./Controllers"; require('angular-route'); @@ -141,6 +143,7 @@ module openflow { .when('/WebsocketClients', { templateUrl: 'WebsocketClients.html', controller: WebsocketClientsCtrl, controllerAs: 'ctrl' }) .when('/Console', { templateUrl: 'Console.html', controller: ConsoleCtrl, controllerAs: 'ctrl' }) + .when('/Config', { templateUrl: 'Config.html', controller: ConfigCtrl, controllerAs: 'ctrl' }) // .when('/WebsocketClients/:id', { templateUrl: 'WebsocketClients.html', controller: WebsocketClientsCtrl, controllerAs: 'ctrl' }) .when('/MailHists', { templateUrl: 'MailHists.html', controller: MailHistsCtrl, controllerAs: 'ctrl' }) diff --git a/OpenFlow/src/public/index.html b/OpenFlow/src/public/index.html index 9633e771..dc5f0ff3 100644 --- a/OpenFlow/src/public/index.html +++ b/OpenFlow/src/public/index.html @@ -102,6 +102,9 @@ ng-show="menuctrl.hasrole('customer admins') || menuctrl.hasrole('resellers')" ng-class="{active: menuctrl.PathIs(['/FormResources', '/FormResource', '/FormResource/'])}">formresources + config providers @@ -212,7 +215,7 @@ ng-show="(menuctrl.hasrole('users') && !menuctrl.hasrole('menu hide rpaworkflows')) || menuctrl.hasrole('admins')">rpaworkflows clients