コード例 #1
0
 public AwsApiGatewayAdapter(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext,
     AmazonAPIGatewayConfig amazonClientConfig)
     : base(logger, awsContext, amazonClientConfig)
 {
 }
コード例 #2
0
 public AwsVpcReader(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext,
     AmazonEC2Config amazonEc2Config)
     : base(logger, awsContext, amazonEc2Config)
 {
 }
コード例 #3
0
ファイル: AwsAdapterBase.cs プロジェクト: BLun78/DnsProxy
 protected AwsAdapterBase(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext,
     ClientConfig amazonClientConfig
     ) : base(logger, awsContext, amazonClientConfig)
 {
     Ttl = 60 * 60;
 }
コード例 #4
0
 public AwsApiGatewayResolverStrategy(
     IDnsContextAccessor dnsContextAccessor,
     CacheManager cacheManager,
     AwsContext awsContext,
     AmazonAPIGatewayConfig amazonApiGatewayConfig,
     IServiceProvider serviceProvider)
     : base(dnsContextAccessor, cacheManager, awsContext,
            amazonApiGatewayConfig, serviceProvider)
 {
     StrategyName = "AwsApiGateway";
 }
コード例 #5
0
 public AwsDocDbResolverStrategy(
     IDnsContextAccessor dnsContextAccessor,
     CacheManager cacheManager,
     AwsContext awsContext,
     AmazonDocDBConfig amazonDocDbConfig,
     IServiceProvider serviceProvider)
     : base(dnsContextAccessor, cacheManager, awsContext,
            amazonDocDbConfig, serviceProvider)
 {
     StrategyName = "AwsDocDb";
 }
コード例 #6
0
 public AwsElasticCacheResolverStrategy(
     IDnsContextAccessor dnsContextAccessor,
     CacheManager cacheManager,
     AwsContext awsContext,
     AmazonElastiCacheConfig amazonElastiCacheConfig,
     IServiceProvider serviceProvider)
     : base(dnsContextAccessor, cacheManager, awsContext,
            amazonElastiCacheConfig, serviceProvider)
 {
     StrategyName = "AwsElasticCache";
 }
コード例 #7
0
 protected AwsBaseResolverStrategy(
     IDnsContextAccessor dnsContextAccessor,
     CacheManager cacheManager,
     AwsContext awsContext,
     ClientConfig awsClientConfig,
     IServiceProvider serviceProvider)
     : base(dnsContextAccessor, cacheManager, null)
 {
     AwsContext        = awsContext;
     AwsClientConfig   = awsClientConfig;
     ServiceProvider   = serviceProvider;
     NeedsQueryTimeout = true;
 }
コード例 #8
0
ファイル: AwsBase.cs プロジェクト: BLun78/DnsProxy
 protected AwsBase(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext,
     ClientConfig amazonClientConfig
     )
 {
     Logger             = logger;
     AwsContext         = awsContext;
     AmazonClientConfig = amazonClientConfig;
     if (AmazonClientConfig != null)
     {
         AmazonClientConfig.RegionEndpoint = RegionEndpoint.GetBySystemName(awsContext?.AwsSettings?.Region);
     }
 }
コード例 #9
0
        public async Task StartReadingVpcAsync(AwsContext awsContext, CancellationToken cancellationToken)
        {
            if (awsContext?.AwsSettings?.UserAccounts == null)
            {
                return;
            }
            _proxyBypassList.Clear();
            try
            {
                foreach (var awsSettingsUserAccount in awsContext.AwsSettings.UserAccounts)
                {
                    if (awsSettingsUserAccount.DoScan)
                    {
                        await ReadVpcAsync(awsSettingsUserAccount.AwsCredentials, awsSettingsUserAccount,
                                           cancellationToken)
                        .ConfigureAwait(false);
                    }

                    foreach (var userRoleExtended in awsSettingsUserAccount.Roles)
                    {
                        if (userRoleExtended.DoScan)
                        {
                            await ReadVpcAsync(userRoleExtended.AwsCredentials, userRoleExtended, cancellationToken)
                            .ConfigureAwait(false);
                        }
                    }
                }

                var path = Path.Combine(Environment.CurrentDirectory, awsContext.AwsSettings.OutputFileName);
                _logger.LogInformation("AWS write ProxyBypassList in File: [{0}]", path);

                await File.WriteAllTextAsync(path, CreateContentForProxyBypassFile(), Encoding.UTF8, cancellationToken)
                .ConfigureAwait(false);

                _logger.LogInformation("AWS import finished!");
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
            }
        }
コード例 #10
0
        public override async Task <List <DnsRecordBase> > ResolveAsync(DnsQuestion dnsQuestion,
                                                                        CancellationToken cancellationToken)
        {
            if (AwsContext == null)
            {
                AwsContext = ServiceProvider.GetService <AwsContext>();
            }

            var result = new List <DnsRecordBase>();

            AwsClient?.Dispose();
            foreach (var awsSettingsUserAccount in AwsContext.AwsSettings.UserAccounts)
            {
                await DoScanAsync(dnsQuestion, cancellationToken, awsSettingsUserAccount, result).ConfigureAwait(false);

                foreach (var userRoleExtended in awsSettingsUserAccount.Roles)
                {
                    await DoScanAsync(dnsQuestion, cancellationToken, userRoleExtended, result).ConfigureAwait(false);
                }
            }

            AwsClient?.Dispose();
            return(result);
        }
コード例 #11
0
 public AwsInstancesController(AwsContext context)
 {
     _context = context;
 }
コード例 #12
0
 public SearchController(AwsContext context)
 {
     _context = context;
 }
コード例 #13
0
ファイル: AwsBase.cs プロジェクト: BLun78/DnsProxy
 protected AwsBase(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext) : this(logger, awsContext, default(ClientConfig))
 {
 }
コード例 #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AwsContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            // app.UseStaticFiles();

            app.UseStaticFiles(new StaticFileOptions()
            {
                OnPrepareResponse = c =>
                {
                    //Do not add cache to json files. We need to have new versions when we add new translations.

                    if (!c.Context.Request.Path.Value.Contains(".json"))
                    {
                        c.Context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
                        {
                            MaxAge = TimeSpan.FromDays(30) // Cache everything except json for 30 days
                        };
                    }
                    else
                    {
                        c.Context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
                        {
                            MaxAge = TimeSpan.FromMinutes(15) // Cache json for 15 minutes
                        };
                    }
                }
            });

            DbInitializer.Initialize(context);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
                {
                    HotModuleReplacement         = true,
                    HotModuleReplacementEndpoint = "/dist/"
                });
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                });

                // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.


                app.MapWhen(x => !x.Request.Path.Value.StartsWith("/swagger", StringComparison.OrdinalIgnoreCase), builder =>
                {
                    builder.UseMvc(routes =>
                    {
                        routes.MapSpaFallbackRoute(
                            name: "spa-fallback",
                            defaults: new { controller = "Home", action = "Index" });
                    });
                });
            }
            else
            {
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");

                    routes.MapRoute(
                        "Sitemap",
                        "sitemap.xml",
                        new { controller = "Home", action = "SitemapXml" });

                    routes.MapSpaFallbackRoute(
                        name: "spa-fallback",
                        defaults: new { controller = "Home", action = "Index" });
                });
                app.UseExceptionHandler("/Home/Error");
            }
        }
コード例 #15
0
 public AwsVpcEndpointAdapter(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext) : base(logger, awsContext)
 {
 }
コード例 #16
0
 public UsersController(AwsContext context)
 {
     _context = context;
 }