private string GetSecurityToken(VrtuConfig vconfig) { List <Claim> claimset = new List <Claim>(); claimset.Add(new Claim($"http://{vconfig.Hostname}/name", vconfig.VirtualRtuId.ToLowerInvariant())); return(CreateJwt($"http://{vconfig.Hostname.ToLowerInvariant()}/", $"http://{vconfig.Hostname.ToLowerInvariant()}/", claimset, vconfig.SymmetricKey, vconfig.LifetimeMinutes.Value)); }
public static ILoggingBuilder AddLogging(this ILoggingBuilder builder, VrtuConfig config) { LogLevel logLevel = config.LoggingLevel; builder.AddConsole(); builder.SetMinimumLevel(logLevel); return(builder); }
public ScadaClientAdapter(VrtuConfig config, IChannel channel, ILogger logger) { Id = Guid.NewGuid().ToString(); this.config = config; this.channel = channel; this.logger = logger; subscribed = new HashSet <byte>(); mapper = new MbapMapper("vrtu"); OpenWebSocketAsync().GetAwaiter(); }
public VirtualRtuPipeline(VrtuConfig config, IChannel input, IChannel output, List <IFilter> inputFiters, List <IFilter> outputFilters, ILogger logger = null) { Id = Guid.NewGuid().ToString(); this.config = config; this.logger = logger; InputChannel = input; OutputChannel = output; InputFilters = inputFiters; OutputFilters = outputFilters; map = RtuMap.LoadAsync(config.StorageConnectionString, config.Container, config.Filename).GetAwaiter().GetResult(); }
//public static IServiceCollection AddModuleConfiguration(this IServiceCollection services, out ModuleConfig config) //{ // IConfigurationBuilder builder = new ConfigurationBuilder(); // builder.AddJsonFile("./secrets.json") // .AddEnvironmentVariables("MC_"); // IConfigurationRoot root = builder.Build(); // config = new ModuleConfig(); // ConfigurationBinder.Bind(root, config); // services.AddSingleton<ModuleConfig>(config); // return services; //} public static IServiceCollection AddModuleConfiguration(this IServiceCollection services, out VrtuConfig config) { IConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile("./secrets.json") .AddEnvironmentVariables("VRTU_"); IConfigurationRoot root = builder.Build(); config = new VrtuConfig(); root.Bind(config); services.AddSingleton(config); return(services); }
public VirtualRtuChannel(VrtuConfig config, ILogger logger = null) { this.config = config; map = RtuMap.LoadAsync(config.StorageConnectionString, config.Container, config.Filename).GetAwaiter().GetResult(); this.logger = logger; subscriptions = new HashSet <byte>(); name = Guid.NewGuid().ToString(); cache = new LocalCache(name); cache.OnExpired += Cache_OnExpired; securityToken = GetSecurityToken(config); endpointUrl = new Uri($"wss://{config.Hostname}/ws/api/connect"); }
public DiagnosticsConnection(VrtuConfig config, PiraeusMqttClient mqttClient, ILogger logger = null) { this.name = config.VirtualRtuId; this.mqttClient = mqttClient; this.logger = logger; this.cache = new LocalCache("vrtudiag"); this.inputPiSystem = UriGenerator.GetVirtualRtuDiagnosticsPiSystem(config.Hostname, config.VirtualRtuId); this.outputPiSystem = UriGenerator.GetVirtualRtuTelemetryPiSystem(config.Hostname, config.VirtualRtuId); if (!string.IsNullOrEmpty(config.InstrumentationKey)) { tconfig = new TelemetryConfiguration(config.InstrumentationKey); tconfig.DisableTelemetry = true; tclient = new TelemetryClient(tconfig); } }
public static Pipeline Create(VrtuConfig config, IChannel input, IChannel output, List <IFilter> inputFiters, List <IFilter> outputFilters, ILogger logger = null) { return(new VirtualRtuPipeline(config, input, output, inputFiters, outputFilters, logger)); }
public VirtualRtuService(VrtuConfig config, Logger logger = null) { this.config = config; this.logger = logger; }
public ScadaClientListener(VrtuConfig config, ILogger logger = null) { this.config = config; this.logger = logger; pipelines = new Dictionary <string, Pipeline>(); }
public WebSocketConnection(VrtuConfig config, ILogger logger = null) { hostname = config.Hostname; securityToken = GetSecurityToken(config); this.logger = logger; }