예제 #1
0
        /*
         * 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();
        }
예제 #2
0
        /// <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();
            }
        }
예제 #3
0
        /*
         * 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();
        }
예제 #4
0
        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;
            }
        }