예제 #1
0
 public LookupClientWrapper(IPAddress ipAddress, LookupClientProvider provider)
 {
     _ipAddress            = ipAddress;
     LookupClient          = new LookupClient(ipAddress);
     LookupClient.UseCache = false;
     _provider             = provider;
 }
 public AcmeCertificateGenerator(ILogger <AcmeCertificateGenerator> logger, TokenCredential credential, ILookupClient lookupClient, ArmDeployment armDeployment)
 {
     _logger        = logger;
     _credential    = credential;
     _lookupClient  = lookupClient;
     _armDeployment = armDeployment;
 }
예제 #3
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">The services.</param>
        public void ConfigureServices(IServiceCollection services)
        {
            //Localisation settings
            services.AddLocalization(options => options.ResourcesPath = "Resources");

            // Add framework services.
            services.AddMvc()
            .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
            .AddDataAnnotationsLocalization();

            // Adds a default in-memory implementation of IDistributedCache.
            services.AddDistributedMemoryCache();
            services.AddSession();

            //register catalog DB
            services.AddDbContext <CatalogDbContext>(options => options.UseSqlServer(GetCatalogConnectionString(CatalogConfig, DatabaseConfig)));

            //Add Application services
            services.AddTransient <ICatalogRepository, CatalogRepository>();
            services.AddTransient <ITenantRepository, TenantRepository>();
            services.AddSingleton <ITenantRepository>(p => new TenantRepository(GetBasicSqlConnectionString()));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton <ILookupClient>(p => new LookupClient());

            //create instance of utilities class
            services.AddTransient <IUtilities, Utilities>();
            var provider = services.BuildServiceProvider();

            _utilities         = provider.GetService <IUtilities>();
            _catalogRepository = provider.GetService <ICatalogRepository>();
            _tenantRepository  = provider.GetService <ITenantRepository>();
            _client            = provider.GetService <ILookupClient>();
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (useInMemory)
            {
                services.AddDbContext <AppDbContext>(options => options.UseInMemoryDatabase("name"));
            }
            else
            {
                services.AddDbContext <AppDbContext>(options =>
                                                     options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            }

            ///* Temporary code to allow EF Core to apply code first changes */
            //services.AddDbContext<CustomerDbContext>(options =>
            //    options.UseSqlServer(Configuration.GetConnectionString("TenantDbConnection2")));

            services.AddIdentity <AppUser, IdentityRole>()
            .AddEntityFrameworkStores <AppDbContext>()
            .AddDefaultTokenProviders();

            services.AddLogging();

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddRazorPagesOptions(options =>
            {
                options.Conventions.AuthorizeFolder(authorizationFolder);
                options.Conventions.AuthorizePage(authorizationPage);
            });

            //register catalog DB
            services.AddDbContext <CatalogDbContext>(options => options.UseSqlServer(GetCatalogConnectionString(CatalogConfig, DatabaseConfig)));

            //Add Application services
            services.AddTransient <ICatalogRepository, CatalogRepository>();
            services.AddTransient <ICustomerRepository, CustomerRepository>();
            services.AddSingleton <ICustomerRepository>(p => new CustomerRepository(GetBasicSqlConnectionString()));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton <ILookupClient>(p => new LookupClient());

            //create instance of utilities class
            services.AddTransient <IUtilities, Utilities.Utilities>();
            var provider = services.BuildServiceProvider();

            _utilities          = provider.GetService <IUtilities>();
            _catalogRepository  = provider.GetService <ICatalogRepository>();
            _customerRepository = provider.GetService <ICustomerRepository>();
            _client             = provider.GetService <ILookupClient>();

            // Register no-op EmailSender used by account confirmation and password reset during development
            // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=532713
            services.AddSingleton <IEmailSender, EmailSender>();
        }
예제 #5
0
 public LookupClientWrapper(DomainParseService domainParser, ILogService logService, ILookupClient lookupClient, LookupClientProvider provider)
 {
     LookupClient          = lookupClient;
     lookupClient.UseCache = false;
     _log          = logService;
     _domainParser = domainParser;
     _provider     = provider;
 }
예제 #6
0
 public LookupClientWrapper(DomainParser domainParser, ILogService logService, ILookupClient lookupClient, LookupClientWrapper @default)
 {
     LookupClient          = lookupClient;
     lookupClient.UseCache = false;
     _log          = logService;
     _domainParser = domainParser;
     _default      = @default;
 }
예제 #7
0
 public LookupClientWrapper(ILogService logService, IPAddress?ipAddress, LookupClientProvider provider)
 {
     _ipAddress            = ipAddress;
     LookupClient          = ipAddress == null ? new LookupClient() : new LookupClient(ipAddress);
     LookupClient.UseCache = false;
     _log      = logService;
     _provider = provider;
 }
        public void SetUp()
        {
            _lookupClient = A.Fake <ILookupClient>();
            _logger       = A.Fake <ILogger <DkimDnsClient> >();
            _dnsResponse  = A.Fake <IDnsQueryResponse>();

            _client = new DkimDnsClient(_lookupClient, _logger);
        }
예제 #9
0
 public BaseController(IStringLocalizer <BaseController> localizer, ITenantRepository tenantRepository,
                       IConfiguration configuration, DnsClient.ILookupClient client)
 {
     _localizer        = localizer;
     _tenantRepository = tenantRepository;
     _configuration    = configuration;
     _client           = client;
 }
예제 #10
0
        /// <summary>
        ///     Method mocks the response from a DNS server when querying for TXT records.
        /// </summary>
        /// <param name="domainName"></param>
        /// <param name="value"></param>
        /// <param name="lookupClient"></param>
        public static void CreateFakeLookupResult(string domainName, string value, ILookupClient lookupClient)
        {
            var queryResponse = Substitute.For <IDnsQueryResponse>();
            var answers       = DevDnsQueryResponse.BuildDnsResourceRecords(domainName, value);

            queryResponse.Answers.Returns(answers);
            lookupClient.QueryAsync(Arg.Is(domainName), Arg.Any <QueryType>())
            .Returns(Task.FromResult(queryResponse));
        }
예제 #11
0
 public void Setup()
 {
     _lookupClient             = A.Fake <ILookupClient>();
     _logger                   = A.Fake <ILogger <BlocklistSourceProcessor> >();
     _blocklistSourceProcessor = new BlocklistSourceProcessor(
         new BlockListSource
     {
         Suffix = ".testSuffix", Data = new List <BlockListAddressData>()
     }, _lookupClient,
         _logger);
 }
예제 #12
0
 public FindRoomsController(ITenantRepository tenantRepository, ICatalogRepository catalogRepository, IStringLocalizer <FindRoomsController> localizer, IStringLocalizer <BaseController> baseLocalizer,
                            ILogger <FindRoomsController> logger, IConfiguration configuration, ILookupClient client, IEmailService emailService)
     : base(baseLocalizer, tenantRepository, configuration, client)
 {
     _tenantRepository  = tenantRepository;
     _catalogRepository = catalogRepository;
     _localizer         = localizer;
     _logger            = logger;
     _client            = client;
     _emailService      = emailService;
 }
예제 #13
0
 public DirectConnectClient(ILogger <DirectConnectClient> logger, ILoggerFactory factory)
 {
     _logger = logger;
     if (!_loggerInit)
     {
         _logger.LogDebug("DNSClient logging not wrapped. Constructing wrapper from factory");
         Logging.LoggerFactory = new LoggerFactoryWrapper(factory);
         _loggerInit           = true;
     }
     _lookupClient = new LookupClient();
 }
예제 #14
0
        public LookupClientWrapper(ILogService logService, IPAddress?ipAddress, LookupClientProvider provider)
        {
            _ipAddress = ipAddress;
            var clientOptions = _ipAddress != null ?
                                new LookupClientOptions(new[] { _ipAddress }) :
                                new LookupClientOptions();

            clientOptions.UseCache = true;
            _lookupClient          = new LookupClient(clientOptions);
            _log      = logService;
            _provider = provider;
        }
예제 #15
0
        public Utilities(Main_MadPayDbContext dbContext, IConfiguration config, UserManager <User> userManager,
                         IHttpContextAccessor http, ILookupClient lookupClient)
        {
            _db     = dbContext;
            _config = config;
            var tokenSettingSection = _config.GetSection("TokenSetting");

            _tokenSetting = tokenSettingSection.Get <TokenSetting>();
            _http         = http;
            _userManager  = userManager;
            _lookupClient = lookupClient;
        }
예제 #16
0
        public Utilitiess(IUnitOfWork <PayDelDbContext> dbContext, IConfiguration config, UserManager <Data.Models.User> userManager, IHttpContextAccessor http
                          , ILookupClient lookupClient)
        {
            _http        = http;
            _config      = config;
            _userManager = userManager;
            _userManager = userManager;
            _db          = dbContext;
            var tokenSettingSection = _config.GetSection("TokenSetting");

            _tokenSetting = tokenSettingSection.Get <TokenSetting>();
            _lookupClient = lookupClient;
        }
예제 #17
0
        static SIPDns()
        {
            var nameServers = NameServer.ResolveNameServers(skipIPv6SiteLocal: true, fallbackToGooglePublicDns: true);
            LookupClientOptions clientOptions = new LookupClientOptions(nameServers.ToArray())
            {
                Retries                    = DNS_RETRIES_PER_SERVER,
                Timeout                    = TimeSpan.FromSeconds(DNS_TIMEOUT_SECONDS),
                UseCache                   = true,
                CacheFailedResults         = true,
                FailedResultsCacheDuration = TimeSpan.FromSeconds(CACHE_FAILED_RESULTS_DURATION)
            };

            _lookupClient = new LookupClient(clientOptions);
        }
예제 #18
0
        public static IDns MockDnsClient(IPeerSettings settings = default, ILookupClient lookupClient = default)
        {
            var peerSetting = settings ?? PeerSettingsHelper.TestPeerSettings();

            peerSetting.SeedServers.ToList().ForEach(domain =>
            {
                MockQueryResponse.CreateFakeLookupResult(domain,
                                                         "0x" + PeerIdHelper.GetPeerId(
                                                             StringHelper.RandomString(32)).ToString().ToHexUTF8(),
                                                         lookupClient ?? Substitute.For <ILookupClient>()
                                                         );
            });

            return(new DevDnsClient(settings));
        }
예제 #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddDataAnnotationsLocalization();

            services.AddMvcCore()
            .AddDataAnnotations();

            // Adds a default in-memory implementation of IDistributedCache.
            services.AddDistributedMemoryCache();
            services.AddSession();

            //register catalog DB
            services.AddDbContext <CatalogDbContext>(options => options.UseSqlServer(GetCatalogConnectionString(CatalogConfig, DatabaseConfig)));

            //Add Application services
            services.AddTransient <ICatalogRepository, CatalogRepository>();
            services.AddTransient <ITenantRepository, TenantRepository>();
            services.AddSingleton <ITenantRepository>(p => new TenantRepository(GetBasicSqlConnectionString()));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton <ILookupClient>(p => new LookupClient());
            services.AddSingleton <IEmailService>(p => new EmailService());
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath  = "/Account/Login";
                options.LogoutPath = "Account/Logout";
            });

            //create instance of utilities class
            services.AddTransient <IUtilities, Utilities>();
            var provider = services.BuildServiceProvider();

            _utilities         = provider.GetService <IUtilities>();
            _catalogRepository = provider.GetService <ICatalogRepository>();
            _tenantRepository  = provider.GetService <ITenantRepository>();
            _client            = provider.GetService <ILookupClient>();
        }
예제 #20
0
        public DomainBusiness(IDomainRepository domainNameRepository, IMapper mapper, ILookupClient lookupClient, ITraefikRedisStore traefikCache, IClusterRepository clusterRepository, IClusterDomainRepository clusterDomainRepository, ITraefikRouterService traefikRouterService, ILogger <DomainBusiness> logger)
        {
            if (domainNameRepository == null)
            {
                throw new ArgumentNullException(nameof(domainNameRepository));
            }

            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            if (lookupClient == null)
            {
                throw new ArgumentNullException(nameof(lookupClient));
            }

            if (traefikCache == null)
            {
                throw new ArgumentNullException(nameof(traefikCache));
            }

            if (clusterRepository == null)
            {
                throw new ArgumentNullException(nameof(clusterRepository));
            }

            this.domainRepository        = domainNameRepository;
            this.mapper                  = mapper;
            this.lookupClient            = lookupClient;
            this.traefikCache            = traefikCache;
            this.clusterRepository       = clusterRepository;
            this.clusterDomainRepository = clusterDomainRepository;
            this.traefikRouterService    = traefikRouterService;
            this.logger                  = logger;
        }
 public BlocklistSourceProcessor(BlockListSource source, ILookupClient lookupClient, ILogger <BlocklistSourceProcessor> log)
 {
     _source       = source;
     _lookupClient = lookupClient;
     _log          = log;
 }
 public DnsClientDnsResolver(ILookupClient lookupClient, IDotNetDnsClient dotNetDnsClient, ILogger <DnsClientDnsResolver> logger)
 {
     _lookupClient    = lookupClient ?? throw new ArgumentNullException(nameof(lookupClient));
     _dotNetDnsClient = dotNetDnsClient ?? throw new ArgumentNullException(nameof(dotNetDnsClient));
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #23
0
 internal DnsClientDnsResolver(ILookupClient lookupClient)
 {
     LookupClient = lookupClient;
 }
예제 #24
0
 public DomainScanner(Domain domain, ILookupClient lookupClient, ILogger logger)
 {
     _domain       = domain;
     _lookupClient = lookupClient;
     _logger       = logger;
 }
예제 #25
0
 public DomainScanner(Domain domain, IServiceProvider serviceProvider)
 {
     _domain       = domain;
     _lookupClient = serviceProvider.GetService <ILookupClient>();
     _logger       = serviceProvider.GetService <ILogger <DomainScanner> >();
 }
예제 #26
0
 public IpDataProvider(IMaxMind maxMind, ILookupClient dns, ILogger <IpDataProvider> logger)
 {
     _maxMind = maxMind;
     _dns     = dns;
     _logger  = logger;
 }
 public LookupApplicationService(ILookupClient lookupClient)
 {
     _lookupClient = lookupClient;
 }
예제 #28
0
 public ChatHub(ILogger <ChatHub> logger, ILookupClient lookupClient, IConnectionFactory connectionFactory)
 {
     this.logger            = logger;
     this.lookupClient      = lookupClient;
     this.connectionFactory = connectionFactory;
 }
예제 #29
0
 public DkimWorker(IAsyncWorker previousWorker, ILookupClient lookupClient, ISettings settings)
 {
     this._PreviousWorker = previousWorker;
     this._LookupClient   = lookupClient;
     this.Settings        = settings;
 }
 public void SetUp()
 {
     _lookupClient = A.Fake <ILookupClient>();
     _dnsClient    = new Poller.Dns.DnsClient(_lookupClient, A.Fake <ILogger <Poller.Dns.DnsClient> >());
 }