/// <summary>
        /// Translate structured data from the environment to pure text
        /// </summary>
        /// <param name="message">Message from the environment</param>
        /// <param name="telnetServer"></param>
        /// <param name="telnetClient"></param>
        public void Translate(
            IMessage message,
            TelnetServer telnetServer,
            TelnetClient telnetClient)
        {
            var graph = message.GetMessageAsType <CoreReadItemGraphResponse>();

            void displayGraph(List <ItemGraph> graphItems, int level = 0)
            {
                if (graphItems != null && graphItems.Count > 0)
                {
                    graphItems.ForEach(graphItem =>
                    {
                        var line = "\r\n" + new string(' ', level * 2) +
                                   $"{AnsiColors.purpleB}{graphItem.Name} ({graphItem.Id}){AnsiColors.reset}";
                        telnetServer.SendMessageToClient(telnetClient, line);
                        displayGraph(graphItem.Children, level + 1);
                    });
                }
            }

            displayGraph(new List <ItemGraph>()
            {
                graph.CoreReadItemGraphEvent.ItemGraph
            });
        }
Beispiel #2
0
 public ConnctConfig()
 {
     InitializeComponent();
     this.showToolStripMenuItem.Click += showToolStripMenuItem_Click;
     this.exitToolStripMenuItem.Click += exitMenuItem_Click;
     validComportList = SerialPort.GetPortNames();
     //lmcFtpServer.start();
     if (File.Exists(configFileName))
     {
         tcaTSLsetPath                       = IniFileOperator.getKeyValue("tslPath", "", configFileName);
         defaultComportNmae                  = IniFileOperator.getKeyValue("defaultComPortName", "", configFileName);
         serverPort                          = IniFileOperator.getKeyValue("serverPort", "", configFileName);
         textBox_TCATSLPath.Text             = tcaTSLsetPath;
         textBox_ServerPort.Text             = serverPort;
         comboBox_ComportList.Text           = defaultComportNmae;
         fSMConfiguration.tslPath            = tcaTSLsetPath;
         fSMConfiguration.defaultComPortName = defaultComportNmae;
         fSMConfiguration.serverPort         = serverPort;
         telnetServer                        = new TelnetServer(fSMConfiguration);
     }
     else
     {
         MessageBox.Show("Can not load the configuration file, please configure the infomation and restart the server !",
                         "configuration load error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         textBox_ServerPort.Text = "11000";
         IniFileOperator.setKeyValue("serverPort", "11000", configFileName);
         comboBox_ComportList.DataSource = validComportList;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Synchronizes with an NTP-server
        /// </summary>
        /// <param name="Server">The telnet server object</param>
        /// <param name="NtpServer">Hostname of the NTP server</param>
        private static void Sync(TelnetServer Server, string NtpServer)
        {
            SNTP_Client Client = new SNTP_Client(new IntegratedSocket(NtpServer, 123));

            Client.Synchronize();
            Server.Print("Current time: " + DateTime.Now.ToString());
        }
Beispiel #4
0
        private static void TestWorldOnline()
        {
            Console.WriteLine("Let's go");

            //CreateDummyWorld();
            CreateMidgaard();

            INetworkServer telnetServer = new TelnetServer(11000);

            DependencyContainer.Instance.GetInstance <IServer>().Initialize(new List <INetworkServer> {
                telnetServer
            });
            DependencyContainer.Instance.GetInstance <IServer>().Start();

            bool stopped = false;

            while (!stopped)
            {
                if (Console.KeyAvailable)
                {
                    string line = Console.ReadLine();
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        // server commands
                        if (line.StartsWith("#"))
                        {
                            line = line.Replace("#", string.Empty).ToLower();
                            if (line == "exit" || line == "quit")
                            {
                                stopped = true;
                                break;
                            }
                            else if (line == "alist")
                            {
                                Console.WriteLine("Admins:");
                                foreach (IAdmin a in DependencyContainer.Instance.GetInstance <IServer>().Admins)
                                {
                                    Console.WriteLine(a.Name + " " + a.PlayerState + " " + (a.Impersonating != null ? a.Impersonating.DisplayName : "") + " " + (a.Incarnating != null ? a.Incarnating.DisplayName : ""));
                                }
                            }
                            else if (line == "plist")
                            {
                                Console.WriteLine("players:");
                                foreach (IPlayer p in DependencyContainer.Instance.GetInstance <IServer>().Players)
                                {
                                    Console.WriteLine(p.Name + " " + p.PlayerState + " " + (p.Impersonating != null ? p.Impersonating.DisplayName : ""));
                                }
                            }
                            // TODO: characters/rooms/items
                        }
                    }
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            DependencyContainer.Instance.GetInstance <IServer>().Stop();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var telnetServer = new TelnetServer();

            if (!telnetServer.Setup(2002))
            {
                Console.WriteLine("设置失败!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine();

            if (!telnetServer.Start())
            {
                Console.WriteLine("启动失败!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("服务启动成功");

            Console.ReadLine();

            telnetServer.Stop();

            Console.WriteLine("服务关闭!");
            Console.ReadLine();
        }
Beispiel #6
0
 /// <summary>
 /// Shows the EDLIN help
 /// </summary>
 /// <param name="Server">Reference to the telnet server</param>
 private static void EdlinHelp(TelnetServer Server)
 {
     Server.Print("Edit line                   line#");
     Server.Print("End (save file)             E");
     Server.Print("Quit (throw away changes)   Q");
     Server.Print("List                        [startline][,endline]L");
 }
Beispiel #7
0
        static void TelnetServerUse()
        {
            var server = new TelnetServer();

            server.NewSessionConnected += TelnetServer_NewSessionConnected;
            server.Connect();
        }
Beispiel #8
0
        /// <summary>
        /// Displays a file
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Pathname">Filename</param>
        private static void DisplayFile(TelnetServer Server, string Pathname)
        {
            if (!File.Exists(Pathname))
            {
                DisplayError(Server, "File not found");
                return;
            }

            FileStream Stream = File.OpenRead(Pathname);

            while (true)
            {
                long Length = Stream.Length - Stream.Position;
                if (Length == 0)
                {
                    break;
                }
                if (Length > 255)
                {
                    Length = 255;
                }
                byte[] Buffer = new byte[(int)Length];
                Stream.Read(Buffer, 0, Buffer.Length);
                Server.Print(new String(Tools.Bytes2Chars(Buffer)), true);
            }
            Stream.Close();
            Server.Print("");
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start the server!");

            Console.ReadKey();
            Console.WriteLine();

            var bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("Failed to initialize!");
                Console.ReadKey();
                return;
            }

            var result = bootstrap.Start();

            Console.WriteLine("Start result: {0}!", result);

            if (result == StartResult.Failed)
            {
                Console.WriteLine("Failed to start!");
                Console.ReadKey();
                return;
            }

            foreach (var s in bootstrap.AppServers)
            {
                if (s is TelnetServer)
                {
                    TelnetServer x = s as TelnetServer;
                    x.NewSessionConnected += new SessionHandler <TelnetSession>(telnetServer_NewSessionConnected);
                    x.SessionClosed       += new SessionHandler <TelnetSession, CloseReason>(telnetServer_SessionClosed);
                }
                else if (s is CustomServer)
                {
                    CustomServer x = s as CustomServer;
                    x.NewSessionConnected += new SessionHandler <CustomSession>(customServer_NewSessionConnected);
                    x.SessionClosed       += new SessionHandler <CustomSession, CloseReason>(customServer_SessionClosed);
                }
            }

            Console.WriteLine("Press key 'q' to stop it!");

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();
                continue;
            }

            Console.WriteLine();

            //Stop the appServer
            bootstrap.Stop();

            Console.WriteLine("The server was stopped!");
            Console.ReadKey();
        }
Beispiel #10
0
 /// <summary>
 /// Shows a directory entry (child of ListDir)
 /// </summary>
 /// <param name="Server">Reference to the telnet server</param>
 /// <param name="Path">Path</param>
 /// <param name="Name">If filled, this name will be shown instead (useful for "." and "..")</param>
 private static void ShowDirEntry(TelnetServer Server, DirectoryInfo Path, string Name = "")
 {
     if (Name == "")
     {
         Name = Path.Name;
     }
     Server.Print(Path.CreationTime.ToString() + "    <DIR>             " + Name);
 }
Beispiel #11
0
        /// <summary>
        /// Shows a specific help page
        /// </summary>
        /// <param name="Server">The telnet server object</param>
        /// <param name="Page">The page</param>
        /// <returns>True when the page exists</returns>
        private static bool DoHelp(TelnetServer Server, string Page)
        {
            switch (Page)
            {
            case "":
                Server.Print("LISTPINS                           Shows a list of all pins");
                Server.Print("CONFIG [PIN] [TYPE]                Configures a pin");
                Server.Print("READPIN [PIN]                      Reads a pin value");
                Server.Print("GETPINTYPE [PIN]                   Reads a pin type");
                Server.Print("WRITEPIN [PIN] [VALUE]             Writes a pin value");
                Server.Print("DUTYCYCLE [PIN] [DUTYCYCLE]        Sets the PWM dutycycle");
                Server.Print("SETPULSE [PIN] [PULSE] [DURATION]  Sets the PWM pulse");
                return(true);

            case "LISTPINS":
                Server.Print("LISTPINS                           Shows a list of all pins");
                return(true);

            case "CONFIG":
                Server.Print("CONFIG [PIN] [TYPE]                Configures a pin");
                Server.Print("- [PIN]       The name of the pin");
                Server.Print("- [TYPE]      Can be: GPI, GPO, PWM, ADC or None");
                return(true);

            case "READPIN":
                Server.Print("READPIN [PIN]                      Reads a pin value");
                Server.Print("- [PIN]       The name of the pin");
                return(true);

            case "GETPINTYPE":
                Server.Print("GETPINTYPE [PIN]                   Reads a pin type");
                Server.Print("- [PIN]       The name of the pin");
                return(true);

            case "WRITEPIN":
                Server.Print("WRITEPIN [PIN] [VALUE]             Writes a pin value");
                Server.Print("- [PIN]       The name of the pin");
                Server.Print("- [VALUE]     1 for high, 0 for low");
                return(true);

            case "DUTYCYCLE":
                Server.Print("DUTYCYCLE [PIN] [DUTYCYCLE]        Sets the PWM dutycycle");
                Server.Print("- [PIN]       The name of the pin");
                Server.Print("- [DUTYCYCLE] The PWM dutycycle (0 to 100)");
                return(true);

            case "SETPULSE":
                Server.Print("SETPULSE [PIN] [PULSE] [DURATION]  Sets the PWM pulse");
                Server.Print("- [PIN]       The name of the pin");
                Server.Print("- [PULSE]     PWM pulse");
                Server.Print("- [DURATION]  PWM duration");
                return(true);

            default:
                return(false);
            }
        }
Beispiel #12
0
 /// <summary>
 /// Sends the MOTD
 /// </summary>
 private static void _SendMotd(TelnetServer Server)
 {
     Server.Color(TelnetServer.Colors.HighIntensityWhite);
     Server.Print("Welcome to the Netduino Telnet Server, " + Server.RemoteAddress);
     Server.Print("Copyright 2012 by Stefan Thoolen (http://www.netmftoolbox.com/)");
     Server.Print("Type HELP to see a list of all supported commands");
     Server.Print("");
     Server.Color(TelnetServer.Colors.White);
 }
        /// <summary>
        /// Translate structured data from the environment to pure text
        /// </summary>
        /// <param name="message">Message from the environment</param>
        /// <param name="telnetServer"></param>
        /// <param name="telnetClient"></param>
        public void Translate(
            IMessage message,
            TelnetServer telnetServer,
            TelnetClient telnetClient)
        {
            var tickEvent = message.GetMessageAsType <TickEvent>();

            telnetServer.SendMessageToClient(telnetClient, "\r\n"
                                             + $"{AnsiColors.yellow}+{AnsiColors.reset}");
        }
Beispiel #14
0
        /// <summary>
        /// Reads a pin
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Pin">Pin</param>
        private static void _ReadPin(TelnetServer Server, string Pin)
        {
            int PinIndex = _PinToIndex(Pin);

            if (PinIndex == -1)
            {
                throw new ArgumentException("Invalid pin name: " + Pin);
            }
            Server.Print("Pin " + Pin + " has value: " + _Pins[PinIndex].Read().ToString());
        }
Beispiel #15
0
        /// <summary>
        /// Translate structured data from the environment to pure text
        /// </summary>
        /// <param name="message">Message from the environment</param>
        /// <param name="telnetServer"></param>
        /// <param name="telnetClient"></param>
        public void Translate(
            IMessage message,
            TelnetServer telnetServer,
            TelnetClient telnetClient)
        {
            var response = message.GetMessageAsType <CoreReadItemJsonResponse>();

            telnetServer.SendMessageToClient(telnetClient, $"\r\n{AnsiColors.purple}{response.CoreReadItemJsonEvent.ItemsJson.First().Id}{AnsiColors.reset}\r\n");
            telnetServer.SendMessageToClient(telnetClient, $"{AnsiColors.purpleB}{response.CoreReadItemJsonEvent.ItemsJson.First().JSON}{AnsiColors.reset}\r\n");
        }
Beispiel #16
0
 private void button_RestartServer_Click(object sender, EventArgs e)
 {
     if (telnetServer == null)
     {
         telnetServer = new TelnetServer(fSMConfiguration);
     }
     else
     {
         telnetServer.restartServer();
     }
 }
Beispiel #17
0
 /// <summary>
 /// Removes a dir
 /// </summary>
 /// <param name="Server">Reference to the telnet server</param>
 /// <param name="Pathname">Path to remove</param>
 private static void RemoveDir(TelnetServer Server, string Pathname)
 {
     try
     {
         Directory.Delete(Pathname);
     }
     catch (System.IO.IOException)
     {
         DisplayError(Server, "An error occured while trying to remove directory \"" + Pathname + "\"");
     }
 }
Beispiel #18
0
        /// <summary>
        /// Create a file
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Pathname">Filename</param>
        private static void CreateFile(TelnetServer Server, string Pathname)
        {
            if (File.Exists(Pathname))
            {
                return;
            }

            FileStream Stream = File.Create(Pathname);

            Stream.Close();
        }
Beispiel #19
0
        /// <summary>
        /// Translate structured data from the environment to pure text
        /// </summary>
        /// <param name="message">Message from the environment</param>
        /// <param name="telnetServer"></param>
        /// <param name="telnetClient"></param>
        public void Translate(
            IMessage message,
            TelnetServer telnetServer,
            TelnetClient telnetClient)
        {
            var arrivalEvent = message.GetMessageAsType <CoreMoveItemEvent>();
            var visible      = arrivalEvent.Item.GetProperty <VisibleItemProperty>("Visible");

            telnetServer.SendMessageToClient(telnetClient, "\r\n"
                                             + $"{AnsiColors.green}{visible?.Name} has moved{AnsiColors.reset}");
        }
Beispiel #20
0
 /// <summary>
 /// Changes to a directory
 /// </summary>
 /// <param name="Server">Reference to the telnet server</param>
 /// <param name="Pathname">The name of the directory</param>
 private static void ChangeDir(TelnetServer Server, string Pathname)
 {
     try
     {
         string Dir = Path.Combine(Directory.GetCurrentDirectory(), Pathname);
         Directory.SetCurrentDirectory(Dir);
     }
     catch (System.IO.IOException)
     {
         DisplayError(Server, "An error occured while changing directory to \"" + Pathname + "\"");
     }
 }
Beispiel #21
0
        /// <summary>
        /// Shows a specific help page
        /// </summary>
        /// <param name="Server">The telnet server object</param>
        /// <param name="Page">The page</param>
        /// <returns>True when the page exists</returns>
        private static bool DoHelp(TelnetServer Server, string Page)
        {
            switch (Page)
            {
            case "":
                Server.Print("DIR                                Reads out a listing of the current directory");
                Server.Print("CD [PATH]                          Changes the current directory");
                Server.Print("MKDIR [PATH]                       Creates a directory");
                Server.Print("RMDIR [PATH]                       Removes a directory");
                Server.Print("DEL [PATH]                         Removes a file");
                Server.Print("TYPE [PATH]                        Prints out a file");
                Server.Print("TOUCH [PATH]                       Creates an empty file");
                return(true);

            case "CD":
                Server.Print("CD [PATH]                          Changes the current directory");
                Server.Print("- [PATH]  The directory to go into");
                return(true);

            case "TYPE":
                Server.Print("TYPE [PATH]                        Prints out a file");
                Server.Print("- [PATH]  The file to display");
                return(true);

            case "DEL":
                Server.Print("DEL [PATH]                         Removes a file");
                Server.Print("- [PATH]  The file to remove");
                return(true);

            case "TOUCH":
                Server.Print("TOUCH [PATH]                       Creates an empty file");
                Server.Print("- [PATH]  The file to create");
                return(true);

            case "MKDIR":
                Server.Print("MKDIR [PATH]                       Creates a directory");
                Server.Print("- [PATH]  The directory to create");
                return(true);

            case "RMDIR":
                Server.Print("RMDIR [PATH]                       Removes a directory");
                Server.Print("- [PATH]  The directory to remove");
                return(true);

            case "DIR":
                Server.Print("DIR                                Reads out a listing of the current directory");
                return(true);

            default:
                return(false);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Edits a line
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Tempfile">The location of the temp file</param>
        /// <param name="LineNo">Line number to edit</param>
        private static void EditLine(TelnetServer Server, string Tempfile, int LineNo)
        {
            List(Server, Tempfile, LineNo, LineNo);
            Server.Print(Tools.ZeroFill(LineNo, 8, ' ') + ":*", true);
            string NewLine = Server.Input();

            if (NewLine == "\x03")
            {
                return;
            }

            Edlin.UpdateLine(Tempfile, LineNo, NewLine);
        }
Beispiel #23
0
 /// <summary>
 /// Actually starts the demo
 /// </summary>
 /// <param name="Server">Reference to the Telnet Server</param>
 private static void Start(TelnetServer Server)
 {
     for (int f = 0; f < 16; ++f)
     {
         for (int b = 0; b < 8; ++b)
         {
             Server.Color((TelnetServer.Colors)f, (TelnetServer.Colors)b);
             Server.Print(" " + Tools.ZeroFill(f, 2) + "," + Tools.ZeroFill(b, 2) + " ", true, true);
         }
         Server.Color(TelnetServer.Colors.White, TelnetServer.Colors.Black);
         Server.Print("");
     }
 }
Beispiel #24
0
        /// <summary>
        /// Changes the dutycycle
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Pin">Pin</param>
        /// <param name="Dutycycle">Dutycycle</param>
        private static void _DutyCycle(TelnetServer Server, string Pin, string Dutycycle)
        {
            int PinIndex = _PinToIndex(Pin);

            if (PinIndex == -1)
            {
                throw new ArgumentException("Invalid pin name: " + Pin);
            }
            int Value = int.Parse(Dutycycle);

            _Pins[PinIndex].Write((uint)Value);
            Server.Print("Dutycycle for pin " + Pin + " set to " + Dutycycle);
        }
Beispiel #25
0
        /// <summary>
        /// Lists lines from a file
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Tempfile">The location of the temp file</param>
        /// <param name="Start">First line to show</param>
        /// <param name="End">Last line to show</param>
        private static void List(TelnetServer Server, string Tempfile, int Start, int End)
        {
            FileStream Stream = File.OpenRead(Tempfile);

            int    LineNo = 1;
            string Buffer = "";

            while (true)
            {
                // Defines the buffer size (max. 255 bytes)
                long Length = Stream.Length - Stream.Position;
                if (Length == 0)
                {
                    break;
                }
                if (Length > 255)
                {
                    Length = 255;
                }
                // Reads out the buffer
                byte[] ReadBuffer = new byte[(int)Length];
                Stream.Read(ReadBuffer, 0, ReadBuffer.Length);
                Buffer += new string(Tools.Bytes2Chars(ReadBuffer));

                // Is this a line?
                while (true)
                {
                    int Pos = Buffer.IndexOf("\n");
                    if (Pos < 0)
                    {
                        break;
                    }
                    // New line found, lets split it
                    string Line = Buffer.Substring(0, Pos);
                    Buffer = Buffer.Substring(Pos + 1);
                    // Do we need to print this line?
                    if (LineNo >= Start && LineNo <= End)
                    {
                        Server.Print(Tools.ZeroFill(LineNo, 8, ' ') + ": " + Line.TrimEnd());
                    }
                    ++LineNo;
                }
            }
            Stream.Close();

            // If there's no line ending at the end of the file, we need to show this line
            if (Buffer != "" && LineNo >= Start && LineNo <= End)
            {
                Server.Print(Tools.ZeroFill(LineNo, 8, ' ') + ": " + Buffer.TrimEnd());
            }
        }
        /// <summary>
        /// Translate structured data from the environment to pure text
        /// </summary>
        /// <param name="message">Message from the environment</param>
        /// <param name="telnetServer"></param>
        /// <param name="telnetClient"></param>
        public void Translate(
            IMessage message,
            TelnetServer telnetServer,
            TelnetClient telnetClient)
        {
            var emoteEvent = message.GetMessageAsType <WorldEmoteEvent>();
            var emote      = "";
            var itemName   = emoteEvent.Origin.GetProperty <VisibleItemProperty>()?.Name ?? "** Something **";

            emote = emoteEvent.EmoteType == WorldEmoteType.Smile ? $"{itemName} smiles happily" : emote;
            emote = emoteEvent.EmoteType == WorldEmoteType.Frown ? $"{itemName} frowns" : emote;
            telnetServer.SendMessageToClient(telnetClient, "\r\n"
                                             + $"{AnsiColors.whiteB}{emote}{AnsiColors.reset}");
        }
Beispiel #27
0
        /// <summary>
        /// Changes the pwm pulse
        /// </summary>
        /// <param name="Server">Reference to the telnet server</param>
        /// <param name="Pin">Pin</param>
        /// <param name="Pulse">Pulse</param>
        /// <param name="Duration">Duration</param>
        private static void _SetPulse(TelnetServer Server, string Pin, string Pulse, string Duration)
        {
            int PinIndex = _PinToIndex(Pin);

            if (PinIndex == -1)
            {
                throw new ArgumentException("Invalid pin name: " + Pin);
            }
            int iPulse    = int.Parse(Pulse);
            int iDuration = int.Parse(Duration);

            _Pins[PinIndex].Write((uint)iPulse, (uint)iDuration);
            Server.Print("Pulse for pin " + Pin + " set to " + Pulse + "," + Duration);
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start the server!");

            Console.ReadKey();
            Console.WriteLine();

            var appServer = new TelnetServer();

            var serverConfig = new ServerConfig
            {
                Port = 2012 //set the listening port
            };

            //Setup the appServer
            if (!appServer.Setup(serverConfig))
            {
                Console.WriteLine("Failed to setup!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine();

            //Try to start the appServer
            if (!appServer.Start())
            {
                Console.WriteLine("Failed to start!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("The server started successfully, press key 'q' to stop it!");

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();
                continue;
            }

            Console.WriteLine();

            //Stop the appServer
            appServer.Stop();

            Console.WriteLine();
            Console.WriteLine("The server was stopped!");
            Console.ReadKey();
        }
Beispiel #29
0
 /// <summary>
 /// Actually starts the demo
 /// </summary>
 /// <param name="Server">Reference to the Telnet Server</param>
 private static void Start(TelnetServer Server)
 {
     NetworkInterface[] Ips = NetworkInterface.GetAllNetworkInterfaces();
     for (int IpCnt = 0; IpCnt < Ips.Length; ++IpCnt)
     {
         Server.Print("Network interface " + IpCnt.ToString() + ":");
         Server.Print("MAC Address: " + NetworkInfo.MacToString(Ips[IpCnt].PhysicalAddress));
         Server.Print("- IP Address: " + Ips[IpCnt].IPAddress.ToString() + " (" + Ips[IpCnt].SubnetMask.ToString() + ")");
         Server.Print("- Gateway: " + Ips[IpCnt].GatewayAddress.ToString());
         for (int DnsCnt = 0; DnsCnt < Ips[IpCnt].DnsAddresses.Length; ++DnsCnt)
         {
             Server.Print("- DNS-server " + DnsCnt.ToString() + ": " + Ips[IpCnt].DnsAddresses[DnsCnt].ToString());
         }
     }
     Server.Print("Connected to: " + Server.RemoteAddress);
 }
Beispiel #30
0
        /// <summary>
        /// Shows a specific help page
        /// </summary>
        /// <param name="Server">The telnet server object</param>
        /// <param name="Page">The page</param>
        /// <returns>True when the page exists</returns>
        private static bool DoHelp(TelnetServer Server, string Page)
        {
            switch (Page)
            {
            case "":
                Server.Print("CLS                                Clears the screen");
                Server.Print("ECHO [TEXT]                        Prints out the text");
                Server.Print("MOTD                               Shows the message of the day");
                Server.Print("QUIT                               Closes the connection");
                Server.Print("VER                                Shows the version of all loaded assemblies");
                Server.Print("INFO                               Shows some system info");
                Server.Print("REBOOT                             Restarts the device");
                return(true);

            case "VER":
                Server.Print("VER                                Shows the version of all loaded assemblies");
                return(true);

            case "REBOOT":
                Server.Print("REBOOT                             Restarts the device");
                return(true);

            case "MOTD":
                Server.Print("MOTD                               Shows the message of the day");
                return(true);

            case "INFO":
                Server.Print("INFO                               Shows some system info");
                return(true);

            case "CLS":
                Server.Print("CLS                                Clears the screen");
                return(true);

            case "ECHO":
                Server.Print("ECHO [TEXT]                        Prints out the text");
                Server.Print("- [TEXT]  Text to print out");
                return(true);

            case "QUIT":
                Server.Print("QUIT                               Closes the connection");
                return(true);

            default:
                return(false);
            }
        }
Beispiel #31
0
        /// <summary>
        /// Shows a specific help page
        /// </summary>
        /// <param name="Server">The telnet server object</param>
        /// <param name="Page">The page</param>
        /// <returns>True when the page exists</returns>
        private static bool DoHelp(TelnetServer Server, string Page)
        {
            switch (Page)
            {
            case "":
                Server.Print("NTPSYNC [HOSTNAME]                 Synchronizes with a timeserver");
                return(true);

            case "NTPSYNC":
                Server.Print("NTPSYNC [HOSTNAME]                 Synchronizes with a timeserver");
                Server.Print("- [HOSTNAME]  The hostname of an NTP-server (example: pool.ntp.org)");
                return(true);

            default:
                return(false);
            }
        }
 public static void Main(string[] args)
 {
     // TODO: Implement Functionality Here
     TelnetServer service = new TelnetServer(IPAddress.Any, 23);
 }