Exemplo n.º 1
0
        /// <summary>Processes the version response and fills their terminal class with info.</summary>
        /// <param name="sender">The connection this relates to.</param>
        /// <param name="mxpOption">The option we are processing.</param>
        private static void ProcessBuffer(IConnection sender, TelnetOptionMXP mxpOption)
        {
            string[] words = mxpOption.VersionResponseBuffer.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string word in words)
            {
                if (word.Trim().StartsWith("version", StringComparison.InvariantCultureIgnoreCase))
                {
                    string[] parts = word.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    sender.Terminal.Version = parts[1].Trim().TrimEnd(new[] { '>' }).Trim(new[] { '"' });
                }
                else if (word.Trim().StartsWith("client", StringComparison.InvariantCultureIgnoreCase))
                {
                    string[] parts = word.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    sender.Terminal.Client = parts[1].Trim().TrimEnd(new[] { '>' }).Trim(new[] { '"' }).ToLower();
                }
            }

            mxpOption.VersionResponseBuffer = string.Empty;

            // @@@ This is a hack. zmud 6.16 doesn't support MCCP correctly but responds that it does.
            // We should disable the option here.
            if (sender.Terminal.Client == "zmud" && sender.Terminal.Version == "6.16")
            {
                ITelnetOption mccpOption =
                    sender.TelnetCodeHandler.TelnetOptions.Find(
                        delegate(ITelnetOption o) { return(o.Name.Equals("compress2")); });
                if (mccpOption != null)
                {
                    mccpOption.Disable();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>Begin the negotiation of telnet options.</summary>
        public void BeginNegotiation()
        {
            lock (lockObject)
            {
                ITelnetOption naws = telnetOptions.Find(delegate(ITelnetOption o) { return(o.Name.Equals("naws")); });
                if (naws != null)
                {
                    naws.Enable();
                }

                ITelnetOption termType = telnetOptions.Find(delegate(ITelnetOption o) { return(o.Name.Equals("termtype")); });
                if (termType != null)
                {
                    termType.Enable();
                }

                ITelnetOption mxp = telnetOptions.Find(delegate(ITelnetOption o) { return(o.Name.Equals("mxp")); });
                if (mxp != null)
                {
                    mxp.Enable();
                }

                ITelnetOption mccp = telnetOptions.Find(delegate(ITelnetOption o) { return(o.Name.Equals("compress2")); });
                if (mccp != null)
                {
                    mccp.Enable();
                }
            }
        }