コード例 #1
0
ファイル: CASC.cs プロジェクト: MaxtorCoder/CASCToolHost
        public static uint[] GetFileDataIDsInBuild(string buildConfig, string cdnConfig)
        {
            var rootcdn = Database.GetRootCDNByBuildConfig(buildConfig);

            RootFile root;

            if (!string.IsNullOrEmpty(rootcdn))
            {
                root = NGDP.GetRoot(Path.Combine(SettingsManager.cacheDir, "tpr", "wow"), rootcdn, true);
            }
            else
            {
                if (string.IsNullOrEmpty(cdnConfig))
                {
                    cdnConfig = Database.GetCDNConfigByBuildConfig(buildConfig);
                }

                if (!buildDictionary.ContainsKey(buildConfig))
                {
                    LoadBuild("wowt", buildConfig, cdnConfig);
                }

                root = buildDictionary[buildConfig].root;
            }

            return(root.entriesFDID.Keys.ToArray());
        }
コード例 #2
0
        public static async Task Main(string[] args)
        {
            var webHost = CreateWebHostBuilder(args).Build();

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                await Task.Run(() => NGDP.LoadAllIndexes());

                Console.WriteLine("Loaded indexes");

                var keys = await KeyService.LoadKeys();

                Console.WriteLine("Loaded " + keys.Count + " keys");
            }

            await webHost.RunAsync();
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: MaxtorCoder/CASCToolHost
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                NGDP.LoadAllIndexes();
            }

            KeyService.LoadKeys();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseResponseCompression();

            app.UseCors("AllowSpecificOrigin");

            app.UseMvc();
        }
コード例 #4
0
        public static async Task <Build> LoadBuild(string program, string buildConfigHash, string cdnConfigHash)
        {
            Logger.WriteLine("Loading build " + buildConfigHash + "..");

            var build = new Build();

            build.buildConfig = await Config.GetBuildConfig(buildConfigHash);

            build.cdnConfig = await Config.GetCDNConfig(cdnConfigHash);

            Logger.WriteLine("Loading encoding..");
            if (build.buildConfig.encodingSize == null || build.buildConfig.encodingSize.Count() < 2)
            {
                await NGDP.GetEncoding(build.buildConfig.encoding[1].ToHexString(), 0);
            }
            else
            {
                await NGDP.GetEncoding(build.buildConfig.encoding[1].ToHexString(), int.Parse(build.buildConfig.encodingSize[1]));
            }

            Logger.WriteLine("Loading root..");

            if (NGDP.encodingDictionary.TryGetValue(build.buildConfig.root, out var rootEntry))
            {
                build.root_cdn = rootEntry;
            }
            else
            {
                throw new KeyNotFoundException("Root encoding key not found!");
            }

            build.root = await NGDP.GetRoot(build.root_cdn.ToHexString().ToLower(), true);

            build.loadedAt = DateTime.Now;

            Logger.WriteLine("Loading indexes..");
            NGDP.GetIndexes(Path.Combine(CDNCache.cacheDir, "tpr/wow"), build.cdnConfig.archives);

            Logger.WriteLine("Done loading build " + buildConfigHash);
            return(build);
        }
コード例 #5
0
        public static async Task <uint[]> GetFileDataIDsInBuild(string buildConfig, string cdnConfig)
        {
            var rootcdn = await Database.GetRootCDNByBuildConfig(buildConfig);

            RootFile root;

            if (!string.IsNullOrEmpty(rootcdn))
            {
                root = await NGDP.GetRoot(rootcdn, true);
            }
            else
            {
                if (string.IsNullOrEmpty(cdnConfig))
                {
                    cdnConfig = await Database.GetCDNConfigByBuildConfig(buildConfig);
                }

                var build = await BuildCache.GetOrCreate(buildConfig, cdnConfig);

                root = build.root;
            }

            return(root.entriesFDID.Keys.ToArray());
        }
コード例 #6
0
ファイル: CASC.cs プロジェクト: MaxtorCoder/CASCToolHost
        public static void LoadBuild(string program, string buildConfigHash, string cdnConfigHash)
        {
            Logger.WriteLine("Loading build " + buildConfigHash + "..");

            var unloadList = new List <string>();

            if (buildDictionary.Count > 15)
            {
                Logger.WriteLine("More than 15 builds loaded. Unloading all builds!");
                buildDictionary.Clear();
            }

            foreach (var loadedBuild in buildDictionary)
            {
                if (loadedBuild.Value.loadedAt < DateTime.Now.AddHours(-1))
                {
                    Logger.WriteLine("Unloading build " + loadedBuild.Key + " as it its been loaded over an hour ago.");
                    unloadList.Add(loadedBuild.Key);
                }
            }

            foreach (var unloadBuild in unloadList)
            {
                buildDictionary.Remove(unloadBuild);
            }

            var build = new Build();

            var cdnsFile = NGDP.GetCDNs(program);

            build.buildConfig = Config.GetBuildConfig(Path.Combine(CDN.cacheDir, cdnsFile.entries[0].path), buildConfigHash);
            build.cdnConfig   = Config.GetCDNConfig(Path.Combine(CDN.cacheDir, cdnsFile.entries[0].path), cdnConfigHash);

            Logger.WriteLine("Loading encoding..");
            if (build.buildConfig.encodingSize == null || build.buildConfig.encodingSize.Count() < 2)
            {
                build.encoding = NGDP.GetEncoding("http://" + cdnsFile.entries[0].hosts[0] + "/" + cdnsFile.entries[0].path + "/", build.buildConfig.encoding[1].ToHexString(), 0);
            }
            else
            {
                build.encoding = NGDP.GetEncoding("http://" + cdnsFile.entries[0].hosts[0] + "/" + cdnsFile.entries[0].path + "/", build.buildConfig.encoding[1].ToHexString(), int.Parse(build.buildConfig.encodingSize[1]));
            }

            Logger.WriteLine("Loading root..");

            string rootHash;

            if (build.encoding.aEntries.TryGetValue(build.buildConfig.root, out var rootEntry))
            {
                rootHash = rootEntry.eKey.ToHexString().ToLower();
            }
            else
            {
                throw new KeyNotFoundException("Root encoding key not found!");
            }

            build.root = NGDP.GetRoot("http://" + cdnsFile.entries[0].hosts[0] + "/" + cdnsFile.entries[0].path + "/", rootHash, true);

            build.loadedAt = DateTime.Now;

            Logger.WriteLine("Loading indexes..");
            NGDP.GetIndexes(Path.Combine(CDN.cacheDir, cdnsFile.entries[0].path), build.cdnConfig.archives);

            if (buildDictionary.ContainsKey(buildConfigHash))
            {
                Logger.WriteLine("Build was already loaded while this iteration was loading, not adding to cache!");
            }
            else
            {
                buildDictionary.Add(buildConfigHash, build);
                Logger.WriteLine("Loaded build " + build.buildConfig.buildName + "!");
            }
        }