Exemple #1
0
        private async Task DownloadConfig()
        {
            if (selectedConfig == null)
            {
                await ShowNoConfigSelectedMessage();

                return;
            }

            if (selectedConfig.IsRemote)
            {
                await js.AlertError(Loc["RemoteConfig"], Loc["CannotDownloadRemoteConfig"]);

                return;
            }

            try
            {
                var fileName = selectedConfig.Metadata.Name.ToValidFileName() + ".opk";
                await BlazorDownloadFileService.DownloadFile(fileName, await ConfigPacker.Pack(selectedConfig), "application/octet-stream");
            }
            catch (Exception ex)
            {
                await js.AlertError(ex.GetType().Name, ex.Message);

                return;
            }
        }
Exemple #2
0
        private async Task CloneConfig()
        {
            if (selectedConfig == null)
            {
                await ShowNoConfigSelectedMessage();

                return;
            }

            // Pack and unpack to clone
            var packed = await ConfigPacker.Pack(selectedConfig);

            using var ms = new MemoryStream(packed);
            var newConfig = await ConfigPacker.Unpack(ms);

            // Change the id and save it again
            newConfig.Id = Guid.NewGuid().ToString();
            await ConfigRepo.Save(newConfig);

            // Set it as currently selected config
            configs.Insert(0, newConfig);
            selectedConfig = newConfig;
            ConfigService.Configs.Add(selectedConfig);
            ConfigService.SelectedConfig = selectedConfig;

            VolatileSettings.DebuggerLog = new();
            Nav.NavigateTo("config/edit/metadata");
        }
        /// <summary>
        /// 重写的OnConfiguring方法
        /// </summary>
        /// <param name="optionsBuilder"></param>
        protected override void OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

            MySqlConfig useConfig = ConfigPacker.GetConfigPacker().GetConfig <MySqlConfig>();

            optionsBuilder.UseMySql(useConfig.Connectstr);
        }
Exemple #4
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

            //获取配置
            SqliteConfig useConfig = ConfigPacker.GetConfigPacker().GetConfig <SqliteConfig>();

            optionsBuilder.UseSqlite(useConfig.Connectstr);
        }
        private static void Run(Options opts)
        {
            options = opts;

            var rlSettings = new RuriLibSettingsService("UserData");
            var pluginRepo = new PluginRepository("UserData/Plugins");

            // Unpack the config
            using var fs = new FileStream(opts.ConfigFile, FileMode.Open);
            var config = ConfigPacker.Unpack(fs).Result;

            // Setup the job
            job = new MultiRunJob(rlSettings, pluginRepo)
            {
                Providers  = new RuriLib.Models.Bots.Providers(rlSettings),
                Bots       = opts.BotsNumber,
                Config     = config,
                DataPool   = new FileDataPool(opts.WordlistFile, opts.WordlistType),
                HitOutputs = new List <IHitOutput> {
                    new FileSystemHitOutput("UserData/Hits")
                },
                ProxyMode    = opts.ProxyMode,
                ProxySources = new List <ProxySource> {
                    new FileProxySource(opts.ProxyFile)
                    {
                        DefaultType = opts.ProxyType
                    }
                }
            };

            // Ask custom inputs (if any)
            foreach (var input in config.Settings.InputSettings.CustomInputs)
            {
                System.Console.WriteLine($"{input.Description} ({input.DefaultAnswer}): ");
                var answer = System.Console.ReadLine();
                job.CustomInputsAnswers[input.VariableName] = string.IsNullOrWhiteSpace(answer)
                    ? input.DefaultAnswer
                    : answer;
            }

            // Hook event handlers
            job.OnCompleted += (sender, args) => completed = true;
            job.OnResult    += PrintResult;
            job.OnTaskError += PrintTaskError;
            job.OnError     += (sender, ex) => System.Console.WriteLine($"Error: {ex.Message}", Color.Tomato);

            // Start the job
            job.Start().Wait();

            // Wait until it finished
            while (!completed)
            {
                Thread.Sleep(100);
                UpdateTitle();
            }

            // Print colored finish message
            System.Console.Write($"Finished. Found: ");
            System.Console.Write($"{job.DataHits} hits, ", Color.GreenYellow);
            System.Console.Write($"{job.DataCustom} custom, ", Color.DarkOrange);
            System.Console.WriteLine($"{job.DataToCheck} to check.", Color.Aquamarine);

            // Prevent console from closing until the user presses return, then close
            System.Console.ReadLine();
            Environment.Exit(0);
        }
Exemple #6
0
        protected override void Prepare(ref string useContectionString)
        {
            MongoDBConfig tempConfig = ConfigPacker.GetConfigPacker().GetConfig <MongoDBConfig>();

            useContectionString = tempConfig.ConnectStr;
        }