static void Main(string[] args) { // Set up the crash dump handler. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(unhandledException); cultureInfo = new System.Globalization.CultureInfo("en-GB"); settingsManager = new SettingsManager(); cloudFlareAPI = new CloudFlareAPI(); if (args.Length > 0) { if (args[0] == "/service") { runService(); return; } if (args[0] == "/install") { if(!isAdmin) { AttachConsole( -1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Install(new System.Collections.Hashtable()); ti.Dispose(); return; } if (args[0] == "/uninstall") { if (!isAdmin) { AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Uninstall(null); ti.Dispose(); return; } } runGUI(); return; }//end Main()
private static void Main(string[] args) { // Set up the crash dump handler. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(unhandledException); cultureInfo = new System.Globalization.CultureInfo("en-GB"); settingsManager = new SettingsManager(); cloudFlareAPI = new CloudFlareAPI(); if (args.Length > 0) { if (args[0] == "/service") { runService(); return; } if (args[0] == "/install") { if (!isAdmin) { AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Install(new System.Collections.Hashtable()); ti.Dispose(); return; } if (args[0] == "/uninstall") { if (!isAdmin) { AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Uninstall(null); ti.Dispose(); return; } } runGUI(); return; }//end Main()
public CloudFlareDDNS(CloudFlareAPI api, Config config, Logger logger) { this.api = api; this.logger = logger; this.config = config; logger.Info($"Cooldown: {config.Cooldown} seconds"); logger.Info($"Records ({config.Records.Count}): {string.Join(", ", config.Records)}"); }
public async Task MainAsync() { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine( " .--.. . .---.. .--. .--. . . .-. \n" + ": | | | | | :| :|\\ |( )\n" + "| | .-. . . .-.| |--- | .-. .--..-. | || || \\ | `-. \n" + ": |( )| |( | | |( ) | (.-' | ;| ;| \\|( )\n" + " `--'`-`-' `--`-`-'`-' `-`-'`-' `--''--' '--' ' ' `-' \n" + ".--. . . . . \n" + "| ) | / o | / \n" + "|--: . . |-' . .--..-. |-' . . .--. \n" + "| )| | | \\ | | ( ) | \\ | | | | \n" + "'--' `--| ' `-' `-' `-'`-' ``--`-' `- \n" + " ; \n" + " `-' \n" + $"\nVersion: {Assembly.GetExecutingAssembly().GetName().Version.ToString()}\n"); Console.ResetColor(); List <Config> configs = ConfigReader.ReadAll(); if (configs == null || configs.Count == 0) { Console.WriteLine("[!] Domain configs not found. A default one has been generated."); Console.WriteLine("[!] Please edit your domain.com.json and run the service again."); Console.WriteLine("[?] Note: You can name it to whatever you want (used only for logging)."); Environment.Exit(0); } List <Task> tasks = new List <Task>(); foreach (Config config in configs) { Logger logger = new Logger(config.Name, config.LogToFile, config.ColoredLogging); CloudFlareAPI api = new CloudFlareAPI(config.ApiEndpoint, config.Email, config.ApiKey, logger); tasks.Add(new CloudFlareDDNS(api, config, logger).Start()); } await Task.WhenAll(tasks); }
static void Main(string[] args) { // Set up the crash dump handler. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(unhandledException); cultureInfo = new System.Globalization.CultureInfo("en-GB"); settingsManager = new SettingsManager(); cloudFlareAPI = new CloudFlareAPI(); if (!Environment.UserInteractive || args.Length > 0 && args[0] == "/service") { runService(); return; } if (args.Length > 0) { if (args[0] == "/install") { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Install(new System.Collections.Hashtable()); ti.Dispose(); return; } if (args[0] == "/uninstall") { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Uninstall(null); ti.Dispose(); return; } } runGUI(); }