public Loading() { InitializeComponent(); mlVersion.Text = mlVersion.Tag.ToString() + $"{StaticData.Version.Major}.{StaticData.Version.Minor} | by TH3C0D3R"; if (!i18n.initialized) { if (Utils.Settings.SettingsExists()) { Utils.Settings temp = Utils.Settings.ReadSettings(); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(temp.Language.Code); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(temp.Language.Code); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo(temp.Language.Code); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(temp.Language.Code); i18n.Initialize(temp.Language.Code, this); } else { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en"); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en"); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en"); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en"); i18n.Initialize("en", this); } } i18n.TranslateForm(); //TopMost = true; }
/// <summary> /// Конструктор с установкой общих параметров конфигурации и log-файла /// </summary> public ServerCommEx(Settings.CommonParams commonParams, Log log) : base() { this.commSettings = new CommSettings(commonParams.ServerHost, commonParams.ServerPort, commonParams.ServerUser, commonParams.ServerPwd, commonParams.ServerTimeout); this.log = log; }
/// <summary> /// CommandIPConfig without args /// </summary> public override ReturnInfo Execute() { if (NetworkStack.ConfigEmpty()) { Console.WriteLine("No network configuration detected! Use ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Ethernet Card : " + device.NameID + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Wireless Card : " + device.NameID + " - " + device.Name); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC Address : " + device.MACAddress.ToString()); Console.WriteLine("IP Address : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Subnet mask : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Default Gateway : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Preferred DNS server : " + settings.GetValue("dns01")); } return(new ReturnInfo(this, ReturnCode.OK)); }
/// <summary> /// Start Aura after login. /// </summary> private static void Start(string username) { Console.Clear(); Kernel.SystemExists = true; Kernel.userLogged = username; Kernel.JustInstalled = true; Kernel.running = true; Console.Clear(); Utils.Settings config = new Utils.Settings(@"0:\System\settings.conf"); string debugger = config.GetValue("debugger"); if (debugger == "on") { Kernel.debugger.enabled = true; } NetworkInit.Enable(); WelcomeMessage.Display(); Text.Display("logged", username); Console.WriteLine(); Kernel.Logged = true; }
public void Ask(string url) { Utils.Settings settings = new Utils.Settings(@"0:\System\" + NetworkInterfaces.Interface("eth0") + ".conf"); Address gateway = Address.Parse(settings.Get("dns01")); Address source = Config.FindNetwork(gateway); askpacket = new DNSPacketAsk(source, gateway, 0x1234, 0x0100, 1, url); OutgoingBuffer.AddPacket(askpacket); NetworkStack.Update(); }
/* * Method called to applied the differents options received in the DHCP packet ACK **/ /// <summary> /// Apply the new IP configuration received. /// </summary> /// <param name="Options">DHCPOption class using the packetData from the received dhcp packet.</param> /// <param name="message">Enable/Disable the displaying of messages about DHCP applying and conf. Disabled by default. /// </param> public static void Apply(DHCPAck packet, bool message = false) { NetworkStack.RemoveAllConfigIP(); //cf. Roadmap. (have to change this, because some network interfaces are not configured in dhcp mode) [have to be done in 0.5.x] foreach (NetworkDevice networkDevice in NetworkDevice.Devices) { if (packet.Client.ToString() == null || packet.Client.ToString() == null || packet.Client.ToString() == null || packet.Client.ToString() == null) { CustomConsole.WriteLineError("Parsing DHCP ACK Packet failed, can't apply network configuration."); } else { if (message) { Console.WriteLine(); CustomConsole.WriteLineInfo("[DHCP ACK][" + networkDevice.Name + "] Packet received, applying IP configuration..."); CustomConsole.WriteLineInfo(" IP Address : " + packet.Client.ToString()); CustomConsole.WriteLineInfo(" Subnet mask : " + packet.Subnet.ToString()); CustomConsole.WriteLineInfo(" Gateway : " + packet.Server.ToString()); CustomConsole.WriteLineInfo(" DNS server : " + packet.DNS.ToString()); } Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); settings.EditValue("ipaddress", packet.Client.ToString()); settings.EditValue("subnet", packet.Subnet.ToString()); settings.EditValue("gateway", packet.Server.ToString()); settings.EditValue("dns01", packet.DNS.ToString()); settings.EditValue("dhcp_server", packet.Server.ToString()); settings.PushValues(); NetworkInit.Enable(networkDevice, packet.Client, packet.Subnet, packet.Server, packet.DNS); if (message) { CustomConsole.WriteLineOK("[DHCP CONFIG][" + networkDevice.Name + "] IP configuration applied."); Console.WriteLine(); DHCPAsked = false; } } } Kernel.BeforeCommand(); }
/// <summary> /// c = command, c_SystemInfomation /// </summary> public static void c_IPConfig(string cmd) { string[] args = cmd.Split(' '); if (args.Length == 1) { L.List_Translation.Ipconfig(); return; } if (args[1] == "/release") { System.Network.DHCP.Core.SendReleasePacket(); } else if (args[1] == "/set") { if (args.Length <= 3) { Console.WriteLine("Usage : " + args[0] + " /set {interface} {IPv4} {Subnet} -g {Gateway} -d {PrimaryDNS}"); //ipconfig /set PCNETII 192.168.1.32 255.255.255.0 -g 192.168.1.254 -d 8.8.8.8 } else { if (NetworkInterfaces.Interface(args[2]) != "null") { Utils.Settings settings = new Utils.Settings(@"0:\System\" + NetworkInterfaces.Interface(args[2]) + ".conf"); NetworkStack.RemoveAllConfigIP(); ApplyIP(args, settings); settings.Push(); NetworkInit.Enable(); } else { Console.WriteLine("This interface doesn't exists."); } } } else if (args[1] == "/renew") { System.Network.DHCP.Core.SendDiscoverPacket(); } else { L.List_Translation.Ipconfig(); } }
/// <summary> /// CommandIPConfig without args /// </summary> public override ReturnInfo Execute() { if (NetworkStack.ConfigEmpty()) { Console.WriteLine("No network configuration detected! Use ipconfig /help"); } foreach (NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case CardType.Ethernet: Console.Write("Ethernet Card : " + device.NameID + " - " + device.Name); break; case CardType.Wireless: Console.Write("Wireless Card : " + device.NameID + " - " + device.Name); break; } if (NetworkConfig.CurrentConfig.Key == device) { Console.WriteLine(" (current)"); } else { Console.WriteLine(); } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC Address : " + device.MACAddress.ToString()); Console.WriteLine("IP Address : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Subnet mask : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Default Gateway : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("DNS Nameservers : "); foreach (Address dnsnameserver in DNSConfig.DNSNameservers) { Console.WriteLine(" " + dnsnameserver.ToString()); } } return(new ReturnInfo(this, ReturnCode.OK)); }
/// <summary> /// Send a packet to the DHCP server to make the address available again /// </summary> public static void SendReleasePacket() { foreach (NetworkDevice networkDevice in NetworkDevice.Devices) { Address source = Config.FindNetwork(DHCPServerAddress(networkDevice)); DHCPRelease dhcp_release = new DHCPRelease(source, DHCPServerAddress(networkDevice)); OutgoingBuffer.AddPacket(dhcp_release); NetworkStack.Update(); NetworkStack.RemoveAllConfigIP(); Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); settings.EditValue("ipaddress", "0.0.0.0"); settings.EditValue("subnet", "0.0.0.0"); settings.EditValue("gateway", "0.0.0.0"); settings.EditValue("dns01", "0.0.0.0"); settings.PushValues(); NetworkInit.Enable(); } }
/* * Method called to applied the differents options received in the DHCP packet ACK **/ /// <summary> /// Apply the new IP configuration received. /// </summary> /// <param name="Options">DHCPOption class using the packetData from the received dhcp packet.</param> /// <param name="message">Enable/Disable the displaying of messages about DHCP applying and conf. Disabled by default. /// </param> public static void Apply(DHCPOption Options, bool message = false) { NetworkStack.RemoveAllConfigIP(); //cf. Roadmap. (have to change this, because some network interfaces are not configured in dhcp mode) [have to be done in 0.5.x] foreach (NetworkDevice networkDevice in NetworkDevice.Devices) { if (message) { Console.WriteLine(); CustomConsole.WriteLineInfo("[DHCP ACK][" + networkDevice.Name + "] Packet received, applying IP configuration..."); CustomConsole.WriteLineInfo(" IP Address : " + Options.Address().ToString()); CustomConsole.WriteLineInfo(" Subnet mask : " + Options.Subnet().ToString()); CustomConsole.WriteLineInfo(" Gateway : " + Options.Gateway().ToString()); CustomConsole.WriteLineInfo(" DNS server : " + Options.DNS01().ToString()); } Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); settings.EditValue("ipaddress", Options.Address().ToString()); settings.EditValue("subnet", Options.Subnet().ToString()); settings.EditValue("gateway", Options.Gateway().ToString()); settings.EditValue("dns01", Options.DNS01().ToString()); settings.EditValue("dhcp_server", Options.Server().ToString()); settings.PushValues(); NetworkInit.Enable(); if (message) { CustomConsole.WriteLineOK("[DHCP CONFIG][" + networkDevice.Name + "] IP configuration applied."); Console.WriteLine(); DHCPAsked = false; } } Uszka.Kernel.BeforeCommand(); }
/// <summary> /// Применить изменения настроек /// </summary> private bool ApplySettings() { // фиксация изменений для активного элемента управления типа NumericUpDown if (ActiveControl is NumericUpDown) { Control control = ActiveControl; ActiveControl = null; ActiveControl = control; } // применение изменений настроек Settings newSettings = new Settings(); ControlsToSettings(newSettings); string errMsg; if (newSettings.Save(configDir + Settings.DefFileName, out errMsg)) { settings = newSettings; btnSettingsApply.Enabled = false; btnSettingsCancel.Enabled = false; ScadaUtils.ShowInfo(AppPhrases.RestartNeeded); return true; } else { errLog.WriteAction(errMsg); ScadaUtils.ShowError(errMsg); return false; } }
/// <summary> /// Создать линию связи и КП на основе настроек /// </summary> private CommLine CreateCommLine(Settings.CommLine commLineSett) { try { return CommLine.Create(commLineSett, Settings.Params, AppDirs, PassCmd, kpTypes, AppLog); } catch (Exception ex) { AppLog.WriteAction(string.Format(Localization.UseRussian ? "Ошибка при создании линии связи {0}: {1}" : "Error creating communication line {0}: {1}", commLineSett.Number, ex.Message), Log.ActTypes.Exception); return null; } }
private ServiceController svcContr; // контроллер службы #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public FrmMain() { InitializeComponent(); // установка формата дат и времени элементов управления dtpSrezDate.CustomFormat = dtpEvDate1.CustomFormat = dtpEvDate2.CustomFormat = Localization.Culture.DateTimeFormat.ShortDatePattern; dtpSrezTime.CustomFormat = dtpEvTime.CustomFormat = Localization.Culture.DateTimeFormat.LongTimePattern; // инициализация полей exeDir = ""; configDir = ""; langDir = ""; logDir = ""; modDir = ""; errLog = new Log(Log.Formats.Simple); errLog.Encoding = Encoding.UTF8; mutex = null; svcContr = null; prevSvcStatus = ServiceControllerStatus.Stopped; notifyIcons = new Icon[ilNotify.Images.Count]; for (int i = 0; i < notifyIcons.Length; i++) notifyIcons[i] = Icon.FromHandle(((Bitmap)ilNotify.Images[i]).GetHicon()); notifyIconIndex = 0; stateFileName = ""; logFileName = ""; stateFileAge = DateTime.MinValue; logFileAge = DateTime.MinValue; nodeCommonParams = treeView.Nodes["nodeCommonParams"]; nodeSaveParams = treeView.Nodes["nodeSaveParams"]; nodeDirectories = treeView.Nodes["nodeDirectories"]; nodeFiles = treeView.Nodes["nodeFiles"]; nodeBase = nodeFiles.Nodes["nodeBase"]; nodeCurSrez = nodeFiles.Nodes["nodeCurSrez"]; nodeMinSrez = nodeFiles.Nodes["nodeMinSrez"]; nodeHrSrez = nodeFiles.Nodes["nodeHrSrez"]; nodeEvents = nodeFiles.Nodes["nodeEvents"]; nodeModules = treeView.Nodes["nodeModules"]; nodeGenerator = treeView.Nodes["nodeGenerator"]; nodeStats = treeView.Nodes["nodeStats"]; lastNode = null; settings = new Settings(); commSettings = new CommSettings(); serverComm = null; changing = false; modViewDict = new Dictionary<string, ModView>(); lastModView = null; }
/// <summary> /// Create menu with <paramref name="elements"/> /// </summary> /// <param name="elements"><c>elements</c> is the list of menu elements</param> public Menu(List <IElement> elements) { this.Elements = elements; settings = new Utils.Settings(); events = new Utils.Events(); }
/// <summary> /// Авторизация и получение токена /// </summary> /// <param name="appId">Идентификатор приложения</param> /// <param name="emailOrPhone">Email или телефон</param> /// <param name="password">Пароль</param> /// <param name="code">Делегат получения кода для двух факторной авторизации</param> /// <param name="captchaSid">Идентификатор капчи</param> /// <param name="captchaKey">Текст капчи</param> /// <param name="settings">Права доступа для приложения</param> /// <param name="host">Имя узла прокси-сервера.</param> /// <param name="port">Номер порта используемого Host.</param> /// <param name="proxyLogin">Логин для прокси-сервера.</param> /// <param name="proxyPassword">Пароль для прокси-сервера</param> /// <exception cref="VkApiAuthorizationException"></exception> private void AuthorizeWithAntiCaptcha(ulong appId, string emailOrPhone, string password, Settings settings, Func<string> code, long? captchaSid = null, string captchaKey = null, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null) { if (_captchaSolver == null) { Authorize(appId, emailOrPhone, password, settings, code, captchaSid, captchaKey, host, port, proxyLogin, proxyPassword); } else { var numberOfRemainingAttemptsToSolveCaptcha = MaxCaptchaRecognitionCount; var numberOfRemainingAttemptsToAuthorize = MaxCaptchaRecognitionCount + 1; var captchaSidTemp = captchaSid; var captchaKeyTemp = captchaKey; var authorizationCompleted = false; do { try { numberOfRemainingAttemptsToAuthorize--; Authorize(appId, emailOrPhone, password, settings, code, captchaSidTemp, captchaKeyTemp, host, port, proxyLogin, proxyPassword); authorizationCompleted = true; } catch (CaptchaNeededException captchaNeededException) { // Если мы обрабатываем исключение не первый раз, сообщаем решателю капчи // об ошибке распознавания предыдущей капчи if (numberOfRemainingAttemptsToSolveCaptcha < MaxCaptchaRecognitionCount) { _captchaSolver?.CaptchaIsFalse(); } if (numberOfRemainingAttemptsToSolveCaptcha <= 0) continue; captchaSidTemp = captchaNeededException.Sid; captchaKeyTemp = _captchaSolver?.Solve(captchaNeededException.Img?.AbsoluteUri); numberOfRemainingAttemptsToSolveCaptcha--; } } while (numberOfRemainingAttemptsToAuthorize > 0 && !authorizationCompleted); // Повторно выбрасываем исключение, если капча ни разу не была распознана верно if (!authorizationCompleted && captchaSidTemp != null) { throw new CaptchaNeededException((long) captchaSidTemp, captchaKeyTemp); } } }
/// <summary> /// Authorize application on vk.com and getting Access Token. /// </summary> /// <param name="appId">Appliation Id</param> /// <param name="email">Email or Phone</param> /// <param name="password">Password</param> /// <param name="settings">Access rights requested by your application</param> public void Authorize(int appId, string email, string password, Settings settings) { var authorization = Browser.Authorize(appId, email, password, settings); if (!authorization.IsAuthorized) throw new VkApiAuthorizationException(InvalidAuthorization, email, password); AccessToken = authorization.AccessToken; UserId = authorization.UserId; }
/// <summary> /// Get the IP address of the DHCP server /// </summary> /// <returns></returns> public static Address DHCPServerAddress(NetworkDevice networkDevice) { Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); return(Address.Parse(settings.GetValue("dhcp_server"))); }
internal void _authorize(int appId, string email, string password, Settings settings, long? captchaSid = null, string captchaKey = null) { var authorization = Browser.Authorize(appId, email, password, settings, captchaSid, captchaKey); if (!authorization.IsAuthorized) throw new VkApiAuthorizationException(InvalidAuthorization, email, password); _stopTimer(); _expireTimer = new Timer(_alertExpires, null, Convert.ToInt32(authorization.ExpiresIn) - 10000, Timeout.Infinite); AccessToken = authorization.AccessToken; UserId = authorization.UserId; }
public void Authorize(int appId, string emailOrPhone, string password, Settings settings, Func<string> code = null, long? captchaSid = null, string captchaKey = null) { VkErrors.ThrowIfNumberIsNegative(() => appId); Authorize(new ApiAuthParams { ApplicationId = Convert.ToUInt64(appId), Login = emailOrPhone, Password = password, Settings = settings, TwoFactorAuthorization = code, CaptchaSid = captchaSid, CaptchaKey = captchaKey }); }
/// <summary> /// Authorize application on vk.com and getting Access Token. /// </summary> /// <param name="appId">Appliation Id</param> /// <param name="email">Email or Phone</param> /// <param name="password">Password</param> /// <param name="captcha_sid">Идентикикатор капчи</param> /// <param name="captcha_key">Текст капчи</param> /// <param name="settings">Access rights requested by your application</param> public void Authorize(int appId, string email, string password, Settings settings, long? captcha_sid = null, string captcha_key = null) { _credentials = new KeyValuePair<string, string>(email, password); _appId = appId; _settings = settings; var captchaRecognitionCount = MaxCaptchaRecognitionCount; var numberOfRemainingAttempts = captchaRecognitionCount + 1; long? captchaSid = captcha_sid; string captchaKey = captcha_key; var authorizationCompleted = false; if (CaptchaSolver == null) { _authorize(appId, email, password, settings, captchaSid, captchaKey); } else { do { try { _authorize(appId, email, password, settings, captchaSid, captchaKey); authorizationCompleted = true; return; } catch (CaptchaNeededException captchaNeededException) { if (numberOfRemainingAttempts <= captchaRecognitionCount) { CaptchaSolver?.CaptchaIsFalse(); } captchaSid = captchaNeededException.Sid; captchaKey = CaptchaSolver?.Solve(captchaNeededException.Img?.AbsoluteUri); } } while (!(authorizationCompleted || --numberOfRemainingAttempts <= 0)); } }
internal void _authorize(int appId, string email, string password, Settings settings, long? captcha_sid = null, string captcha_key = null) { var authorization = Browser.Authorize(appId, email, password, settings, captcha_sid, captcha_key); if (!authorization.IsAuthorized) throw new VkApiAuthorizationException(InvalidAuthorization, email, password); AccessToken = authorization.AccessToken; UserId = authorization.UserId; }
void Awake() { AudioSource[] sources = GetComponents<AudioSource>(); portalSound = sources[0]; settings = GameObject.Find("GameStuff").GetComponent<Settings>(); movePlayer = GameObject.Find("Player").GetComponent<MovePlayer>(); roadTileSize = roadStraightPrefab.FindChild("baseSquare").renderer.bounds.size + new Vector3(0,0,10); }
/// <summary> /// Display IP Configuration and MAC Address /// </summary> public static void Ipconfig() { switch (Uszka.Kernel.langSelected) { case "fr_FR": int counter = 0; foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Carte Ethernet " + counter + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Carte réseau sans fil " + counter + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("Adresse MAC : " + device.MACAddress.ToString()); Console.WriteLine("Adresse IP : " + settings.GetValue("ipaddress")); Console.WriteLine("Masque de sous-réseau : " + settings.GetValue("subnet")); Console.WriteLine("Passerelle par défaut : " + settings.GetValue("gateway")); Console.WriteLine("Serveur DNS préféré : " + settings.GetValue("dns01")); counter++; } counter = 0; break; case "en_US": int counter1 = 0; foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Ethernet Card " + counter1 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Wireless Card " + counter1 + " - " + device.Name); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC Address : " + device.MACAddress.ToString()); Console.WriteLine("IP Address : " + settings.GetValue("ipaddress")); Console.WriteLine("Subnet mask : " + settings.GetValue("subnet")); Console.WriteLine("Default Gateway : " + settings.GetValue("gateway")); Console.WriteLine("Preferred DNS server : " + settings.GetValue("dns01")); counter1++; } counter1 = 0; break; case "nl_NL": int counter2 = 0; foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Ethernetkaart " + counter2 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Draadloze Netwerkkaart " + counter2 + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC-adres : " + device.MACAddress.ToString()); Console.WriteLine("IP-adres : " + settings.GetValue("ipaddress")); Console.WriteLine("Subnetmasker : " + settings.GetValue("subnet")); Console.WriteLine("Standaardgateway : " + settings.GetValue("gateway")); Console.WriteLine("Voorkeur DNS-server : " + settings.GetValue("dns01")); counter2++; } counter2 = 0; break; case "it_IT": int counter3 = 0; foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Scheda Ethernet " + counter3 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Scheda di rete senza fili " + counter3 + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("Indirizzo MAC : " + device.MACAddress.ToString()); Console.WriteLine("Indirizzo IP : " + settings.GetValue("ipaddress")); Console.WriteLine("Maschera di sottorete : " + settings.GetValue("subnet")); Console.WriteLine("Gateway predefinito : " + settings.GetValue("gateway")); Console.WriteLine("Server DNS preferito : " + settings.GetValue("dns01")); counter3++; } counter3 = 0; break; } }
/// <summary> /// Display help on settings commands. /// </summary> public static void Systeminfo() { Utils.Settings config = new Utils.Settings(@"0:\System\settings.conf"); switch (Uszka.Kernel.langSelected) { case "fr_FR": Console.WriteLine("Nom du PC: " + Uszka.Kernel.ComputerName); Console.WriteLine("Nom du système d'exploitation: Aura"); Console.WriteLine("Version du système: " + Uszka.Kernel.version); Console.WriteLine("Révision du système: " + Uszka.Kernel.revision); Console.WriteLine("Date et heure: " + Time.MonthString() + "/" + Time.DayString() + "/" + Time.YearString() + ", " + Time.TimeString(true, true, true)); if (Uszka.Kernel.SystemExists) { Console.WriteLine("Date d'installation originale: " + config.GetValue("setuptime")); } Console.WriteLine("Mémoire totale: " + Core.MemoryManager.TotalMemory + "MB"); Console.WriteLine("Mémoire utilisée: " + Core.MemoryManager.GetUsedMemory() + "MB"); Console.WriteLine("Mémoire restante: " + Core.MemoryManager.GetFreeMemory() + "MB"); /*Console.WriteLine("Processeur(s): " + Computer.Info.GetNumberOfCPU() + " processeur(s) installé(s)."); * int i = 1; * foreach (Processor processor in Computer.CPUInfo.Processors) * { * Console.WriteLine("[" + i + "] : " + processor.GetBrandName() + (int)processor.Frequency + " Mhz"); * i++; * } * Computer.CPUInfo.Processors.Clear();*/ Console.WriteLine("Mode de la console: " + Uszka.Kernel.AConsole.Name); break; case "en_US": Console.WriteLine("Computer name: " + Uszka.Kernel.ComputerName); Console.WriteLine("Operating system name: Aura"); Console.WriteLine("Operating system version: " + Uszka.Kernel.version); Console.WriteLine("Operating system revision: " + Uszka.Kernel.revision); Console.WriteLine("Date and time: " + Time.MonthString() + "/" + Time.DayString() + "/" + Time.YearString() + ", " + Time.TimeString(true, true, true)); if (Uszka.Kernel.SystemExists) { Console.WriteLine("Original Install Date: " + config.GetValue("setuptime")); } Console.WriteLine("Total memory: " + Core.MemoryManager.TotalMemory + "MB"); Console.WriteLine("Used memory: " + Core.MemoryManager.GetUsedMemory() + "MB"); Console.WriteLine("Free memory: " + Core.MemoryManager.GetFreeMemory() + "MB"); /*Console.WriteLine("Processor(s): " + Computer.Info.GetNumberOfCPU() + " installed processor(s)."); * int j = 1; * foreach (Processor processor in Computer.CPUInfo.Processors) * { * Console.WriteLine("[" + j + "] : " + processor.GetBrandName() + (int)processor.Frequency + " Mhz"); * j++; * } * Computer.CPUInfo.Processors.Clear();*/ Console.WriteLine("Console mode: " + Uszka.Kernel.AConsole.Name); break; case "nl_NL": Console.WriteLine("Naam computer: " + Uszka.Kernel.ComputerName); Console.WriteLine("Naam besturingssysteem: Aura"); Console.WriteLine("Versie besturingssysteem: " + Uszka.Kernel.version); Console.WriteLine("Revisie besturingssysteem: " + Uszka.Kernel.revision); Console.WriteLine("Datum en tijd: " + Time.MonthString() + "/" + Time.DayString() + "/" + Time.YearString() + ", " + Time.TimeString(true, true, true)); if (Uszka.Kernel.SystemExists) { Console.WriteLine("Installeer datum: " + config.GetValue("setuptime")); } Console.WriteLine("Totaal geheugen: " + Core.MemoryManager.TotalMemory + "MB"); Console.WriteLine("Gebruikt geheugen: " + Core.MemoryManager.GetUsedMemory() + "MB"); Console.WriteLine("Gratis geheugen: " + Core.MemoryManager.GetFreeMemory() + "MB"); /*Console.WriteLine("Processor(s): " + Computer.Info.GetNumberOfCPU() + " processor(s) geïnstalleerd."); * int k = 1; * foreach (Processor processor in Computer.CPUInfo.Processors) * { * Console.WriteLine("[" + k + "] : " + processor.GetBrandName() + (int)processor.Frequency + " Mhz"); * k++; * } * Computer.CPUInfo.Processors.Clear();*/ Console.WriteLine("Consolewijze: " + Uszka.Kernel.AConsole.Name); break; case "it_IT": Console.WriteLine("Nome del computer: " + Uszka.Kernel.ComputerName); Console.WriteLine("Nome del sistema operativo: Aura"); Console.WriteLine("Versione del sistema operativo: " + Uszka.Kernel.version); Console.WriteLine("Revisione del sistema operativo: " + Uszka.Kernel.revision); Console.WriteLine("Data e ora: " + Time.MonthString() + "/" + Time.DayString() + "/" + Time.YearString() + ", " + Time.TimeString(true, true, true)); if (Uszka.Kernel.SystemExists) { Console.WriteLine("Data Installazione Sistema: " + config.GetValue("setuptime")); } Console.WriteLine("Memoria totale: " + Core.MemoryManager.TotalMemory + "MB"); Console.WriteLine("Memoria utilizzata: " + Core.MemoryManager.GetUsedMemory() + "MB"); Console.WriteLine("Memoria libera: " + Core.MemoryManager.GetFreeMemory() + "MB"); /*Console.WriteLine("Processor(s): " + Computer.Info.GetNumberOfCPU() + " installed processor(s)."); * int h = 1; * foreach (Processor processor in Computer.CPUInfo.Processors) * { * Console.WriteLine("[" + h + "] : " + processor.GetBrandName() + (int)processor.Frequency + " Mhz"); * h++; * } * Computer.CPUInfo.Processors.Clear();*/ break; } }
/// <summary> /// Установить настройки в соответствии с элементами управления /// </summary> private void ControlsToSettings(Settings settings) { // общие параметры settings.TcpPort = decimal.ToInt32(numTcpPort.Value); settings.UseAD = chkUseAD.Checked; settings.LdapPath = txtLdapPath.Text; // директории системы settings.BaseDATDir = txtBaseDATDir.Text; settings.ItfDir = txtItfDir.Text; settings.ArcDir = txtArcDir.Text; settings.ArcCopyDir = txtArcCopyDir.Text; // запись данных settings.WriteCurPer = WriteCurPerItemVals[cbWriteCurPer.SelectedIndex]; settings.InactUnrelTime = InactUnrelTimeItemVals[cbInactUnrelTime.SelectedIndex]; settings.WriteCur = chkWriteCur.Checked; settings.WriteCurCopy = chkWriteCurCopy.Checked; settings.WriteMinPer = WriteMinPerItemVals[cbWriteMinPer.SelectedIndex]; settings.StoreMinPer = decimal.ToInt32(numStoreMinPer.Value); settings.WriteMin = chkWriteMin.Checked; settings.WriteMinCopy = chkWriteMinCopy.Checked; settings.WriteHrPer = cbWriteHrPer.SelectedIndex > 0 ? 3600 /*1 час*/ : 1800 /*30 минут*/; settings.StoreHrPer = decimal.ToInt32(numStoreHrPer.Value); settings.WriteHr = chkWriteHr.Checked; settings.WriteHrCopy = chkWriteHrCopy.Checked; settings.StoreEvPer = decimal.ToInt32(numStoreEvPer.Value); settings.WriteEv = chkWriteEv.Checked; settings.WriteEvCopy = chkWriteEvCopy.Checked; // модули settings.ModuleFileNames.Clear(); settings.ModuleFileNames.AddRange(lbModDll.Items.Cast<string>()); // статистика settings.DetailedLog = chkDetailedLog.Checked; }
/// <summary> /// Display IP Configuration and MAC Address /// </summary> public static void Ipconfig() { switch (Kernel.langSelected) { case "fr_FR": int counter = 0; if (NetworkStack.ConfigEmpty()) { Console.WriteLine("Aucune configuration réseau détectée! Utilisez ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Carte Ethernet " + counter + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Carte réseau sans fil " + counter + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("Adresse MAC : " + device.MACAddress.ToString()); Console.WriteLine("Adresse IP : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Masque de sous-réseau : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Passerelle par défaut : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Serveur DNS préféré : " + settings.GetValue("dns01")); counter++; } break; case "en_US": int counter1 = 0; if (NetworkStack.ConfigEmpty()) { Console.WriteLine("No network configuration detected! Use ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Ethernet Card " + counter1 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Wireless Card " + counter1 + " - " + device.Name); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC Address : " + device.MACAddress.ToString()); Console.WriteLine("IP Address : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Subnet mask : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Default Gateway : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Preferred DNS server : " + settings.GetValue("dns01")); counter1++; } break; case "nl_NL": int counter2 = 0; if (NetworkStack.ConfigEmpty()) { Console.WriteLine("Geen netwerkconfiguratie gedetecteerd! Gebruik ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Ethernetkaart " + counter2 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Draadloze Netwerkkaart " + counter2 + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("MAC-adres : " + device.MACAddress.ToString()); Console.WriteLine("IP-adres : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Subnetmasker : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Standaardgateway : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Voorkeur DNS-server : " + settings.GetValue("dns01")); counter2++; } break; case "it_IT": int counter3 = 0; if (NetworkStack.ConfigEmpty()) { Console.WriteLine("Nessuna configurazione di rete rilevata! Utilizzare ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Scheda Ethernet " + counter3 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Scheda di rete senza fili " + counter3 + " :"); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("Indirizzo MAC : " + device.MACAddress.ToString()); Console.WriteLine("Indirizzo IP : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Maschera di sottorete : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Gateway predefinito : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Server DNS preferito : " + settings.GetValue("dns01")); counter3++; } break; case "pl_PL": int counter4 = 0; if (NetworkStack.ConfigEmpty()) { Console.WriteLine("Nie wykryto zadnej konfiguracji sieci! Uzyj ipconfig /help"); } foreach (HAL.Drivers.Network.NetworkDevice device in NetworkConfig.Keys) { switch (device.CardType) { case HAL.Drivers.Network.CardType.Ethernet: Console.WriteLine("Karta Sieciowa " + counter4 + " - " + device.Name); break; case HAL.Drivers.Network.CardType.Wireless: Console.WriteLine("Karta bezprzewodowa " + counter4 + " - " + device.Name); break; } Utils.Settings settings = new Utils.Settings(@"0:\System\" + device.Name + ".conf"); Console.WriteLine("Adres MAC : " + device.MACAddress.ToString()); Console.WriteLine("Adres IP : " + NetworkConfig.Get(device).IPAddress.ToString()); Console.WriteLine("Maska sieciowa : " + NetworkConfig.Get(device).SubnetMask.ToString()); Console.WriteLine("Brama sieciowa : " + NetworkConfig.Get(device).DefaultGateway.ToString()); Console.WriteLine("Preferowany serwer DNS : " + settings.GetValue("dns01")); counter4++; } break; } }
private Thread thread; // поток взаимодействия с клиентами #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public Comm(MainLogic mainLogic) { if (mainLogic == null) throw new ArgumentNullException("mainLogic"); if (mainLogic.AppLog == null) throw new ArgumentNullException("mainLogic.AppLog"); if (mainLogic.Settings == null) throw new ArgumentNullException("mainLogic.Settings"); // заполнение массива описаний команд CmdDescrs = new string[byte.MaxValue]; for (byte code = 0; code < byte.MaxValue; code++) CmdDescrs[code] = GetCmdDescr(code); // инициализация полей this.mainLogic = mainLogic; appLog = mainLogic.AppLog; settings = mainLogic.Settings; thread = null; terminated = false; tcpListener = null; clients = new List<ClientInfo>(); inBuf = new byte[InBufLenght]; outBuf = new byte[OutBufLenght]; cmdBuf = new List<ModLogic.Command>(); }
/// <summary> /// Авторизация и получение токена /// </summary> /// <param name="appId">Идентификатор приложения</param> /// <param name="emailOrPhone">Email или телефон</param> /// <param name="password">Пароль</param> /// <param name="code">Делегат получения кода для двух факторной авторизации</param> /// <param name="captchaSid">Идентификатор капчи</param> /// <param name="captchaKey">Текст капчи</param> /// <param name="settings">Права доступа для приложения</param> /// <param name="host">Имя узла прокси-сервера.</param> /// <param name="port">Номер порта используемого Host.</param> /// <exception cref="VkApiAuthorizationException"></exception> private void Authorize(ulong appId, string emailOrPhone, string password, Settings settings, Func<string> code, long? captchaSid = null, string captchaKey = null, string host = null, int? port = null) { StopTimer(); LastInvokeTime = DateTimeOffset.Now; var authorization = Browser.Authorize(appId, emailOrPhone, password, settings, code, captchaSid, captchaKey, host, port); if (!authorization.IsAuthorized) { throw new VkApiAuthorizationException("Invalid authorization", emailOrPhone, password); } var expireTime = (Convert.ToInt32(authorization.ExpiresIn) - 10) * 1000; if (expireTime > 0) { _expireTimer = new Timer(AlertExpires, null, expireTime, Timeout.Infinite); } AccessToken = authorization.AccessToken; UserId = authorization.UserId; }
private string workState; // состояние работы #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public MainLogic() { AppDirs = new AppDirs(); AppLog = new Log(Log.Formats.Full); AppLog.Encoding = Encoding.UTF8; Settings = new Settings(); infoFileName = ""; thread = null; terminated = false; serverIsReady = false; startDT = DateTime.MinValue; workState = ""; comm = new Comm(this); calculator = new Calculator(this); inCnls = new SortedList<int, InCnl>(); drCnls = null; drmCnls = null; drhCnls = null; drCnlNums = null; drmCnlNums = null; drhCnlNums = null; avgCnlInds = null; ctrlCnls = new SortedList<int, CtrlCnl>(); users = new SortedList<string, User>(); formulas = new List<string>(); curSrez = null; curSrezMod = false; srezDescr = null; minAvgData = null; hrAvgData = null; activeDTs = null; curSrezAdapter = null; curSrezCopyAdapter = null; eventAdapter = null; eventCopyAdapter = null; minSrezTableCache = null; hrSrezTableCache = null; modules = new List<ModLogic>(); }
/// <summary> /// Shell Interpreter /// </summary> /// <param name="cmd">Command</param> public static void _CommandManger(string cmd) { if (Kernel.debugger != null) { if (Kernel.debugger.enabled) { Kernel.debugger.Send("[Command] > " + cmd); } } #region Power if (cmd.Equals("shutdown") || cmd.Equals("sd")) {//NOTE: Why isn't it just the constructor? This leaves more room for <package>.<class>.HelpInfo; Power.Shutdown.c_Shutdown(); } else if (cmd.Equals("reboot") || cmd.Equals("rb")) { Power.Reboot.c_Reboot(); } #endregion Power #region Console else if ((cmd.Equals("clear")) || (cmd.Equals("cls"))) { c_Console.Clear.c_Clear(); } else if (cmd.StartsWith("echo ")) { c_Console.Echo.c_Echo(cmd); } else if (cmd.Equals("help")) { System.Translation.List_Translation._Help(); } #endregion Console #region FileSystem else if (cmd.StartsWith("cd ")) { FileSystem.CD.c_CD(cmd); } else if (cmd.Equals("cp")) { FileSystem.CP.c_CP_only(); } else if (cmd.StartsWith("cp ")) { FileSystem.CP.c_CP(cmd); } else if ((cmd.Equals("dir")) || (cmd.Equals("ls"))) { FileSystem.Dir.c_Dir(); } else if ((cmd.StartsWith("dir ")) || (cmd.StartsWith("ls "))) { FileSystem.Dir.c_Dir(cmd); } else if (cmd.Equals("mkdir")) { FileSystem.Mkdir.c_Mkdir(); } else if (cmd.StartsWith("mkdir ")) { FileSystem.Mkdir.c_Mkdir(cmd); } else if (cmd.StartsWith("rmdir ")) { FileSystem.Rmdir.c_Rmdir(cmd); }//TODO: orgainize else if (cmd.StartsWith("rmfil ")) { FileSystem.Rmfil.c_Rmfil(cmd); } else if (cmd.Equals("mkfil")) { FileSystem.Mkfil.c_mkfil(); } else if (cmd.StartsWith("mkfil ")) { FileSystem.Mkfil.c_mkfil(cmd); } else if (cmd.StartsWith("edit ")) { FileSystem.Edit.c_Edit(cmd); } else if (cmd.Equals("vol")) { FileSystem.Vol.c_Vol(); } else if (cmd.StartsWith("run ")) { FileSystem.Run.c_Run(cmd); } else if (cmd.StartsWith("cat")) { FileSystem.Cat.c_Cat(cmd); } #endregion FileSystem #region Settings else if (cmd.Equals("logout")) { Settings.Logout.c_Logout(); } else if (cmd.Equals("settings")) { Settings.Settings.c_Settings(); } else if (cmd.StartsWith("settings ")) { Settings.Settings.c_Settings(cmd); } else if (cmd.StartsWith("passwd ")) { Settings.Passwd.c_Passwd(cmd); } else if (cmd.Equals("passwd")) { Settings.Passwd.c_Passwd(Kernel.userLogged); } #endregion Settings #region System Infomation else if (cmd.Equals("systeminfo")) { SystemInfomation.SystemInfomation.c_SystemInfomation(); } else if ((cmd.Equals("ver")) || (cmd.Equals("version"))) { SystemInfomation.Version.c_Version(); } else if ((cmd.StartsWith("ipconfig")) || (cmd.StartsWith("ifconfig")) || (cmd.StartsWith("netconf"))) { SystemInfomation.IPConfig.c_IPConfig(cmd); } else if ((cmd.Equals("time")) || (cmd.Equals("date"))) { SystemInfomation.Time.c_Time(); } #endregion System Infomation #region Tests else if (cmd.Equals("crash")) { Tests.Crash.c_Crash(); } else if (cmd.Equals("crashcpu")) { int value = 1; value = value - 1; int result = 1 / value; //Division by 0 } else if (cmd.Equals("beep")) { Kernel.speaker.beep(); } else if (cmd.Equals("play")) { Kernel.speaker.playmusic(); } else if (cmd.Equals("udp")) { var xClient = new System.Network.IPV4.UDP.UdpClient(4242); xClient.Connect(new System.Network.IPV4.Address(192, 168, 1, 12), 4242); xClient.Send(Encoding.ASCII.GetBytes("Hello from Aura Operating System!")); } else if (cmd.Equals("tcp")) { var xClient = new System.Network.IPV4.TCP.TCPClient(4343); xClient.Connect(new System.Network.IPV4.Address(192, 168, 1, 12), 4224); xClient.Send(Encoding.ASCII.GetBytes("1")); xClient.Send(Encoding.ASCII.GetBytes("2")); xClient.Send(Encoding.ASCII.GetBytes("3")); xClient.Send(Encoding.ASCII.GetBytes("4")); xClient.Send(Encoding.ASCII.GetBytes("5")); } else if (cmd.Equals("haship")) { Console.WriteLine(new HAL.MACAddress(new byte[] { 00, 01, 02, 03, 04, 05 }).Hash); Console.WriteLine(new System.Network.IPV4.Address(192, 168, 1, 12).Hash); } else if (cmd.Equals("dns")) { System.Network.IPV4.UDP.DNS.DNSClient DNSRequest = new System.Network.IPV4.UDP.DNS.DNSClient(53); DNSRequest.Ask("perdu.com"); } else if (cmd.Equals("net /refresh")) { foreach (HAL.Drivers.Network.NetworkDevice networkDevice in HAL.Drivers.Network.NetworkDevice.Devices) { File.Create(@"0:\System\" + networkDevice.Name + ".conf"); Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); settings.Edit("ipaddress", "0.0.0.0"); settings.Edit("subnet", "0.0.0.0"); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); settings.Push(); } } //else if (cmd.StartsWith("xml ")) //{ // Util.xml.CmdXmlParser.c_CmdXmlParser(cmd, 0, 4); //} #endregion Tests #region Tools else if (cmd.Equals("snake")) { Tools.Snake.c_Snake(); } else if (cmd.StartsWith("md5")) { Tools.MD5.c_MD5(cmd); } else if (cmd.StartsWith("sha256")) { Tools.SHA256.c_SHA256(cmd); } else if (cmd.StartsWith("ping")) { Network.Ping.c_Ping(cmd); } else if (cmd.Equals("debug")) { Tools.Debug.c_Debug(); } else if (cmd.StartsWith("debug ")) { Tools.Debug.c_Debug(cmd); } #endregion #region Util else if (cmd.StartsWith("export")) { Util.EnvVar.c_Export(cmd); } else if (cmd.Equals("lspci")) { Util.Lspci.c_Lspci(); } else if (cmd.Equals("about")) { Util.About.c_About(); } else { if (cmd.Length <= 0) { Console.WriteLine(); return; } else if (cmd.Length == 2) { FileSystem.ChangeVol.c_ChangeVol(cmd); } else { Util.CmdNotFound.c_CmdNotFound(); } } CommandsHistory.Add(cmd); //adding last command to the commands history Console.WriteLine(); #endregion Util }
private static void ApplyIP(string[] args, Utils.Settings settings) { int args_count = args.Length; switch (args_count) { default: Console.WriteLine("Usage : " + args[0] + " /set {interface} {IPv4} {Subnet} -g {Gateway} -d {PrimaryDNS}"); break; case 5: if (Utils.Misc.IsIpv4Address(args[3]) && Utils.Misc.IsIpv4Address(args[4])) { settings.Edit("ipaddress", args[3]); settings.Edit("subnet", args[4]); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); } else { L.Text.Display("notcorrectaddress"); } break; case 7: if (Utils.Misc.IsIpv4Address(args[3]) && Utils.Misc.IsIpv4Address(args[4]) && Utils.Misc.IsIpv4Address(args[6])) { settings.Edit("ipaddress", args[3]); settings.Edit("subnet", args[4]); if (args[5] == "-g") { settings.Edit("gateway", args[6]); settings.Edit("dns01", "0.0.0.0"); } else if (args[5] == "-d") { settings.Edit("dns01", args[6]); settings.Edit("gateway", "0.0.0.0"); } else { Console.WriteLine("Usage : " + args[0] + " /set {interface} {IPv4} {Subnet} -g {Gateway} -d {PrimaryDNS}"); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); } } else { L.Text.Display("notcorrectaddress"); } break; case 9: if (Utils.Misc.IsIpv4Address(args[3]) && Utils.Misc.IsIpv4Address(args[4]) && Utils.Misc.IsIpv4Address(args[6]) && Utils.Misc.IsIpv4Address(args[8])) { settings.Edit("ipaddress", args[3]); settings.Edit("subnet", args[4]); if (args[5] == "-g") { settings.Edit("gateway", args[6]); } else if (args[5] == "-d") { settings.Edit("dns01", args[6]); } else { Console.WriteLine("Usage : " + args[0] + " /set {interface} {IPv4} {Subnet} -g {Gateway} -d {PrimaryDNS}"); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); } if (args[7] == "-g") { settings.Edit("gateway", args[8]); } else if (args[7] == "-d") { settings.Edit("dns01", args[8]); } else { Console.WriteLine("Usage : " + args[0] + " /set {interface} {IPv4} {Subnet} -g {Gateway} -d {PrimaryDNS}"); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); } } break; } }
private Thread startThread; // поток повторения попыток запуска #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public Manager() { kpTypes = new Dictionary<string, Type>(); commLines = new List<CommLine>(); commandReader = null; infoThread = null; infoFileName = ""; startThread = null; startDT = DateTime.MinValue; linesStarted = false; lineCaptions = null; lineCmdLock = new object(); AppDirs = new AppDirs(); Settings = new Settings(); ServerComm = null; AppLog = new Log(Log.Formats.Full) { Encoding = Encoding.UTF8 }; AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; }
/// <summary> /// Authorize application on vk.com and getting Access Token. /// </summary> /// <param name="appId">Appliation Id</param> /// <param name="emailOrPhone">Email or Phone</param> /// <param name="password">Password</param> /// <param name="captchaSid">Идентикикатор капчи</param> /// <param name="captchaKey">Текст капчи</param> /// <param name="settings">Access rights requested by your application</param> public void Authorize(int appId, string emailOrPhone, string password, Settings settings, long? captchaSid = null, string captchaKey = null) { _authorize(appId, emailOrPhone, password, settings, captchaSid, captchaKey); _credentials = new KeyValuePair<string, string>(emailOrPhone, password); _appId = appId; _settings = settings; }
/// <summary> /// Авторизация и получение токена /// </summary> /// <param name="appId">Идентификатор приложения</param> /// <param name="emailOrPhone">Email или телефон</param> /// <param name="password">Пароль</param> /// <param name="code">Делегат получения кода для двух факторной авторизации</param> /// <param name="captchaSid">Идентификатор капчи</param> /// <param name="captchaKey">Текст капчи</param> /// <param name="settings">Права доступа для приложения</param> /// <param name="host">Имя узла прокси-сервера.</param> /// <param name="port">Номер порта используемого Host.</param> /// <param name="proxyLogin">Логин для прокси-сервера.</param> /// <param name="proxyPassword">Пароль для прокси-сервера</param> /// <exception cref="VkApiAuthorizationException"></exception> private void Authorize(ulong appId, string emailOrPhone, string password, Settings settings, Func<string> code, long? captchaSid = null, string captchaKey = null, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null) { StopTimer(); LastInvokeTime = DateTimeOffset.Now; var authorization = Browser.Authorize(appId, emailOrPhone, password, settings, code, captchaSid, captchaKey, host, port, proxyLogin, proxyPassword); if (!authorization.IsAuthorized) { throw new VkApiAuthorizationException("Invalid authorization with {0} - {1}", emailOrPhone, password); } var expireTime = (Convert.ToInt32(authorization.ExpiresIn) - 10) * 1000; SetTimer(expireTime); AccessToken = authorization.AccessToken; UserId = authorization.UserId; }
public static void c_Settings(string settings) { Char separator = ' '; string[] cmdargs = settings.Split(separator); if (cmdargs.Length == 2) //No arg { if (cmdargs[1].Equals("setcomputername")) { //method computername Info.AskComputerName(); } else if (cmdargs[1].Equals("setlang")) { L.Text.Display("availablelanguage"); } else if (cmdargs[1].Equals("remuser")) { L.Text.Display("remuser"); } else if (cmdargs[1].Equals("adduser")) { L.Text.Display("adduser"); } else if (cmdargs[1].Equals("passuser")) { L.Text.Display("_passuser"); } } else if (cmdargs.Length == 3) //One arg { if (cmdargs[1].Equals("remuser")) { System.Users.Users users = new System.Users.Users(); users.Remove(cmdargs[2]); } else if (cmdargs[1].Equals("setlang")) { Utils.Settings config = new Utils.Settings(@"0:\System\settings.conf"); if ((cmdargs[2].Equals("en_US")) || cmdargs[2].Equals("en-US")) { Kernel.langSelected = "en_US"; L.Keyboard.Init(); config.EditValue("language", "en_US"); config.PushValues(); } else if ((cmdargs[2].Equals("fr_FR")) || cmdargs[2].Equals("fr-FR")) { Kernel.langSelected = "fr_FR"; L.Keyboard.Init(); config.EditValue("language", "fr_FR"); config.PushValues(); } else if ((cmdargs[2].Equals("nl_NL")) || cmdargs[2].Equals("nl-NL")) { Kernel.langSelected = "nl_NL"; L.Keyboard.Init(); config.EditValue("language", "nl_NL"); config.PushValues(); } else { L.Text.Display("unknownlanguage"); L.Text.Display("availablelanguage"); } } else if (cmdargs[1].Equals("adduser")) { L.Text.Display("adduser"); } else if (cmdargs[1].Equals("passuser")) { L.Text.Display("_passuser"); } } else if (cmdargs.Length == 4) //Two args { if (cmdargs[1].Equals("adduser")) { System.Users.Users users = new System.Users.Users(); users.Create(cmdargs[2], cmdargs[3]); } else if (cmdargs[1].Equals("passuser")) { System.Users.Users users = new System.Users.Users(); users.ChangePassword(cmdargs[2], cmdargs[3]); } else if (cmdargs[1].Equals("setlang")) { L.Text.Display("availablelanguage"); } else if (cmdargs[1].Equals("remuser")) { L.Text.Display("remuser"); } } //else if (cmdargs[1].Equals("textcolor")) //{ // bool save = c_Console.TextColor.c_TextColor(cmdargs[2]); // if (save) // { // config.LoadValues(); // config.EditValue("foregroundcolor", cmdargs[2]); // config.PushValues(); // } //} //else if (cmdargs[1].Equals("backgroundcolor")) //{ // bool save = c_Console.BackGroundColor.c_BackGroundColor(cmdargs[2]); // if (save) // { // config.LoadValues(); // config.EditValue("backgroundcolor", cmdargs[2]); // config.PushValues(); // } //} else { Console.ForegroundColor = ConsoleColor.DarkRed; L.Text.Display("UnknownCommand"); Console.ForegroundColor = ConsoleColor.White; } }
public static void RegisterAllCommands() { CMDs.Add(new CommandEcho(new string[] { "echo" })); CMDs.Add(new CommandReboot(new string[] { "reboot", "rb" })); CMDs.Add(new CommandShutdown(new string[] { "shutdown", "sd" })); CMDs.Add(new CommandClear(new string[] { "clear", "clr" })); CMDs.Add(new CommandPing(new string[] { "ping" })); CMDs.Add(new CommandUdp(new string[] { "udp" })); CMDs.Add(new CommandVersion(new string[] { "version", "ver" })); CMDs.Add(new CommandSystemInfo(new string[] { "systeminfo", "sysinfo" })); CMDs.Add(new CommandTime(new string[] { "time", "date" })); CMDs.Add(new CommandIPConfig(new string[] { "ipconfig", "ifconfig", "netconf" })); CMDs.Add(new CommandLspci(new string[] { "lspci" })); CMDs.Add(new CommandEnv(new string[] { "export", "set" })); CMDs.Add(new CommandAbout(new string[] { "about" })); CMDs.Add(new CommandCrash(new string[] { "crash" })); CMDs.Add(new CommandVol(new string[] { "vol" })); CMDs.Add(new CommandDir(new string[] { "dir", "ls", "l" })); CMDs.Add(new CommandMkdir(new string[] { "mkdir", "md" })); CMDs.Add(new CommandRmdir(new string[] { "rmdir", "rmd" })); CMDs.Add(new CommandCat(new string[] { "cat" })); CMDs.Add(new CommandCD(new string[] { "cd" })); CMDs.Add(new CommandChangeVol(new string[] { "chgvol", "cv" })); CMDs.Add(new CommandMkfil(new string[] { "touch", "mkfil", "mf" })); CMDs.Add(new CommandRmfil(new string[] { "rmfil", "rmf" })); CMDs.Add(new CommandKeyboardMap(new string[] { "setkeyboardmap", "setkeyboard" })); CMDs.Add(new CommandAction(new string[] { "beep" }, () => { Cosmos.System.PCSpeaker.Beep(); })); CMDs.Add(new CommandAction(new string[] { "help" }, () => { List_Translation._Help(); })); CMDs.Add(new CommandAction(new string[] { "play" }, () => { Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.G5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.A5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.B5, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.C6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.F6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.D6, 432); Cosmos.System.PCSpeaker.Beep((uint)Cosmos.System.Notes.E6, 432); })); CMDs.Add(new CommandAction(new string[] { "netrefresh" }, () => { foreach (HAL.Drivers.Network.NetworkDevice networkDevice in HAL.Drivers.Network.NetworkDevice.Devices) { File.Create(@"0:\System\" + networkDevice.Name + ".conf"); Utils.Settings settings = new Utils.Settings(@"0:\System\" + networkDevice.Name + ".conf"); settings.Edit("ipaddress", "0.0.0.0"); settings.Edit("subnet", "0.0.0.0"); settings.Edit("gateway", "0.0.0.0"); settings.Edit("dns01", "0.0.0.0"); settings.Push(); } })); }