public static IHostBuilder CreateHostBuilder(string[] args)
        {
            var builder = Host.CreateDefaultBuilder(args);

            var ft = Environment.GetEnvironmentVariable("Settings__Features__Metrics");

            if (bool.TryParse(ft, out var metrics) && metrics)
            {
                builder.UseMetricsWebTracking().UseMetrics(opt => opt.EndpointOptions = endpoint => {
                    endpoint.MetricsTextEndpointOutputFormatter = new MetricsPrometheusTextOutputFormatter();
                    endpoint.MetricsEndpointOutputFormatter     = new MetricsPrometheusProtobufOutputFormatter();
                    endpoint.EnvironmentInfoEndpointEnabled     = false;
                });
            }

            builder.ConfigureServices((hostContext, services) =>
            {
                var settings = hostContext.Configuration.GetSection("Settings").Get <Settings>();
                Console.WriteLine($"info: Registering {settings.Instance.Username} with url: {args[1]}");

                if (args.Any(arg => arg == "--register") && args.Length == 2)
                {
                    var client = new SimulatorOrkManager(settings.Instance.Username, settings.BuildClient());
                    client.Add(new OrkNode {
                        Id     = settings.Instance.Username,
                        Url    = args[1],
                        PubKey = settings.Instance.GetPrivateKey().GetPublic().ToString()
                    }).GetAwaiter().GetResult();
                }
            });

            return(builder.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); }));
        }
Exemple #2
0
        public DnsController(IKeyManagerFactory factory, ILogger <KeyController> logger, Settings settings)
        {
            _manager = factory.BuildDnsManager();
            _logger  = logger;
            _orkId   = settings.Instance.Username;

            var cln = new SimulatorClient(settings.Endpoints.Simulator.Api, _orkId, settings.Instance.GetPrivateKey());

            _orkManager = new SimulatorOrkManager(_orkId, cln);
        }
 public IndexController(OrkConfig config, Settings settings)
 {
     _config     = config;
     _orkManager = new SimulatorOrkManager(config.UserName, settings.BuildClient());
 }