public IRequestRepo Create() { string TwoFaHandler(string login, bool isAutoRelogin) { Logger.Info($"Waiting 2FA code for {login}"); var code = _settings.TwoFaHandler?.Get(login, isAutoRelogin); Logger.Info($"Got 2FA code for {login}"); return(code); } IRequestRepo repo = _settings.Protocol switch { Protocol.YadWeb => new YadWebRequestRepo(_settings.Proxy, _credentials), Protocol.WebM1Bin => new WebBinRequestRepo(_settings.Proxy, _credentials, TwoFaHandler), Protocol.WebV2 => new WebV2RequestRepo(_settings.Proxy, _credentials, TwoFaHandler), _ => throw new Exception("Unknown protocol") }; if (!string.IsNullOrWhiteSpace(_settings.UserAgent)) { repo.HttpSettings.UserAgent = _settings.UserAgent; } return(repo); } }
public async Task Invoke(HttpContext context, IRequestRepo requestRepo, IAuxUserAgentService userAgentService) { //getting user agent from header StringValues user_agent = ""; context.Request.Headers.TryGetValue("User-Agent", out user_agent); //waiting for user agent // var result = await userAgentService.ParseUserAgentData(user_agent.ToString()); //saving request(request+useragentdata) data to dbcontext requestRepo.Add(new Request { Source = context.Connection.RemoteIpAddress.ToString() + ":" + context.Connection.RemotePort.ToString(), Destination = context.Request.Path.ToString(), Method = context.Request.Method, //UserAgent = result, }); //save changes to db await requestRepo.SaveChangesAsync(); //calling next to go to next middleware await _next(context); }
public HomeController(ILogger <HomeController> logger, IBookRepo bookR, IReportRepo reportR, IReviewRepo reviewR, IRequestRepo requestR) { _logger = logger; bookRepo = bookR; reportRepo = reportR; reviewRepo = reviewR; requestRepo = requestR; }
public RequestController( IRequestRepo requestRepo, ILinkService <RequestDto, RequestResourceParameters> linkService, IMapper mapper) { _requestRepo = requestRepo; _mapper = mapper; _linkService = linkService; }
public ShardManager(IRequestRepo repo) { var httpsettings = repo.HttpSettings; _metaServer = new Cached <ServerRequestResult>(_ => { Logger.Debug("Requesting new meta server"); var server = new MobMetaServerRequest(httpsettings).MakeRequestAsync().Result; return(server); }, _ => TimeSpan.FromSeconds(MetaServerExpiresSec)); BannedShards = new Cached <List <ShardInfo> >(_ => new List <ShardInfo>(), _ => TimeSpan.FromMinutes(2)); //CachedShards = new Cached<Dictionary<ShardType, ShardInfo>>(old => new ShardInfoRequest(httpsettings, auth).MakeRequestAsync().Result.ToShardInfo(), // value => TimeSpan.FromSeconds(ShardsExpiresInSec)); CachedShards = new Cached <Dictionary <ShardType, ShardInfo> >(_ => repo.GetShardInfo1(), _ => TimeSpan.FromSeconds(ShardsExpiresInSec)); DownloadServersPending = new Pending <Cached <ServerRequestResult> >(8, () => new Cached <ServerRequestResult>(_ => { var server = new GetServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"Download server changed to {server.Url}"); return(server); }, _ => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); UploadServer = new Cached <ShardInfo>(_ => { var server = new GetUploadServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"Upload server changed to {server.Url}"); return(new ShardInfo { Count = 0, Type = ShardType.Upload, Url = server.Url }); }, _ => TimeSpan.FromSeconds(ShardsExpiresInSec)); WeblinkDownloadServersPending = new Pending <Cached <ServerRequestResult> >(8, () => new Cached <ServerRequestResult>(_ => { var data = new WeblinkGetServerRequest(httpsettings).MakeRequestAsync().Result; var serverUrl = data.Body.WeblinkGet[0].Url; Logger.Debug($"weblink Download server changed to {serverUrl}"); var res = new ServerRequestResult { Url = serverUrl }; return(res); }, _ => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); }
public UnpublishRequest(IRequestRepo repo, HttpCommonSettings settings, IAuth auth, string publicLink) : base(settings, auth) { _publicLink = publicLink; if (repo.PublicBaseUrlDefault.Length > 0 && _publicLink.StartsWith(repo.PublicBaseUrlDefault, StringComparison.InvariantCultureIgnoreCase)) { _publicLink = _publicLink.Remove(0, repo.PublicBaseUrlDefault.Length); } }
public ReviewController(ApplicationDbContext context, UserManager <AppUser> userMgr, IBookRepo bookR, IReportRepo reportR, IReviewRepo reviewR, IRequestRepo requestR) { _context = context; userManager = userMgr; bookRepo = bookR; reportRepo = reportR; reviewRepo = reviewR; requestRepo = requestR; }
public AccountController(UserManager <AppUser> userMgr, SignInManager <AppUser> signinMgr, RoleManager <IdentityRole> roleMgr, IBookRepo bookR, IReportRepo reportR, IReviewRepo reviewR, IRequestRepo requestR) { userManager = userMgr; signInManager = signinMgr; roleManager = roleMgr; bookRepo = bookR; reportRepo = reportR; reviewRepo = reviewR; requestRepo = requestR; }
public void TestCheckForOwnerName() { //Arrange repo = new FakeRequestRepo(); SeedRequestData(); foreach (Request r in requests) { repo.AddRequest(r); } //Act bool stiles = repo.CheckForOwnerName("Stiles"); bool robin = repo.CheckForOwnerName("robinhood"); //Assert Assert.True(stiles); Assert.False(robin); }
public void TestAddRequest() { //Arrange repo = new FakeRequestRepo(); SeedData(); Request request = new Request() { Requester = users[0].UserName, Owner = users[1].UserName, BookTitle = books[0].Title, Duration = "1 week" }; //Act repo.AddRequest(request); //Assert Assert.Single(repo.Requests); Assert.Equal("Stiles", repo.Requests.ElementAt(0).Owner); Assert.Equal("The Lightning Thief", repo.Requests.ElementAt(0).BookTitle); }
public ShardManager(HttpCommonSettings httpsettings, IAuth auth, IRequestRepo repo) { _metaServer = new Cached <Requests.WebBin.MobMetaServerRequest.Result>(old => { Logger.Debug("Requesting new meta server"); var server = new Requests.WebBin.MobMetaServerRequest(httpsettings).MakeRequestAsync().Result; return(server); }, value => TimeSpan.FromSeconds(MetaServerExpiresSec)); BannedShards = new Cached <List <ShardInfo> >(old => new List <ShardInfo>(), value => TimeSpan.FromMinutes(2)); //CachedShards = new Cached<Dictionary<ShardType, ShardInfo>>(old => new ShardInfoRequest(httpsettings, auth).MakeRequestAsync().Result.ToShardInfo(), // value => TimeSpan.FromSeconds(ShardsExpiresInSec)); CachedShards = new Cached <Dictionary <ShardType, ShardInfo> >(old => repo.GetShardInfo1(), value => TimeSpan.FromSeconds(ShardsExpiresInSec)); DownloadServersPending = new Pending <Cached <Requests.WebBin.ServerRequest.Result> >(8, () => new Cached <Requests.WebBin.ServerRequest.Result>(old => { var server = new Requests.WebBin.GetServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"Download server changed to {server.Url}"); return(server); }, value => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); WeblinkDownloadServersPending = new Pending <Cached <Requests.WebBin.ServerRequest.Result> >(8, () => new Cached <Requests.WebBin.ServerRequest.Result>(old => { var server = new Requests.WebBin.WeblinkGetServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"weblink Download server changed to {server.Url}"); return(server); }, value => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); }
public RequestController(IRequestRepo repo) { _repo = repo; }
public DownloadRequest(IRequestRepo repo, File file, long instart, long inend, IAuth authent, HttpCommonSettings settings, Cached <Dictionary <ShardType, ShardInfo> > shards) { _repo = repo; Request = CreateRequest(authent, settings.Proxy, file, instart, inend, settings.UserAgent, shards); }
public RequestsController(IRequestRepo repository, IMapper mapper, IRequestService service) { _repository = repository; _mapper = mapper; _service = service; }
public Handler(IPublishEndpoint publishEndpoint, IRequestRepo consumerRepo) { this.publishEndpoint = publishEndpoint; this.consumerRepo = consumerRepo; }
public RequestService() { this.Repository = new RequestRepo(); }
public HomeController(IOfferRepo offerRepo, ICategoryRepo categoryRepo, IRequestRepo requestRepo) { this.offerRepo = offerRepo; this.categoryRepo = categoryRepo; this.requestRepo = requestRepo; }
public Handler(IRequestRepo repo) { this.repo = repo; }
public OrderRepo(IRequestRepo requestRepo) : base() { RequestRepo = requestRepo; }
public RequestService(IRequestRepo requestRepo, IMapper mapper, IBookRepo bookRepo) { this.requestRepo = requestRepo; this.mapper = mapper; this.bookRepo = bookRepo; }
public RequestStatusUpdatedConsumer(IRequestRepo repo) { this.repo = repo; }
public RequestService(IRequestRepo Repository) { this.Repository = Repository; }
public RequestsController(IRequestRepo repository, IMapper mapper) { _repository = repository; _mapper = mapper; }