public override void onAddProtection(Protection protection) { protection.AddProtection(new QuickLzProtection()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <ChainSettings>(Configuration.GetSection("Chain")); services.Configure <NetworkSettings>(Configuration.GetSection("Network")); services.Configure <IndexerSettings>(Configuration.GetSection("Indexer")); services.Configure <HubSettings>(Configuration.GetSection("Hub")); services.Configure <GatewaySettings>(Configuration.GetSection("Gateway")); services.AddTransient <MessageSerializer>(); Assembly assembly = typeof(MessageSerializer).Assembly; services.AddSingleton <IHubMessageProcessing, HubMessageProcessing>(); services.AddSingleton <IHubStorage, DiskStorage>(); services.AddSingleton <HubConnectionManager>(); services.AddSingleton <HubManager>(); services.AddSingleton <WebSocketHub>(); services.AddSingleton <CommandDispatcher>(); services.AddHostedService <HubService>(); var availableServices = new AvailableServices(); availableServices.List.Add("DocumentStorage"); // Allows storage and retrieval of small documents, used by dapps. availableServices.List.Add("FileSharing"); // Allows query (directory listing) and download of large binary files in an encrypted manner. availableServices.List.Add("Node"); // Allows forward queries to node, including broadcast of transaction. services.AddSingleton(availableServices); // Register the DataProtection service, used to protect the auto-generated recovery phrase. Protection.AddProtection(services); // Register all hub handlers. assembly.GetTypesImplementing <IHubMessageHandler>().ForEach((t) => { services.AddSingleton(typeof(IHubMessageHandler), t); }); services.AddResponseCompression(); // services.AddControllers(); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddSignalR().AddNewtonsoftJsonProtocol(options => { var settings = new JsonSerializerSettings(); Serializer.RegisterFrontConverters(settings); options.PayloadSerializerSettings = settings; options.PayloadSerializerSettings.Converters.Add(new StringEnumConverter()); }); // Add service and create Policy to allow Cross-Origin Requests services.AddCors ( options => { options.AddPolicy ( "CorsPolicy", builder => { string[] allowedDomains = new[] { "http://localhost", "http://localhost:9912", "http://localhost:4200", "http://localhost:8080" }; builder .WithOrigins(allowedDomains) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); } ); }); }