예제 #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
 protected AwsAdapterBase(
     ILogger <AwsAdapterBase> logger,
     AwsContext awsContext,
     ClientConfig amazonClientConfig
     ) : base(logger, awsContext, amazonClientConfig)
 {
     Ttl = 60 * 60;
 }
 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";
 }
 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)
 {
 }
 public UsersController(AwsContext context)
 {
     _context = context;
 }