示例#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();
                }
            }
        }
示例#2
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.StartsWith("version", StringComparison.OrdinalIgnoreCase))
                {
                    string[] keyValueParts = word.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    sender.TerminalOptions.Version = keyValueParts[1].Trim('"');
                }
                else if (word.StartsWith("client", StringComparison.OrdinalIgnoreCase))
                {
                    string[] keyValueParts = word.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    sender.TerminalOptions.Client = keyValueParts[1].Trim('"').ToLower();
                }
            }

            mxpOption.VersionResponseBuffer = string.Empty;

            // TODO: 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.TerminalOptions.Client == "zmud" && sender.TerminalOptions.Version == "6.16")
            {
                sender.TelnetCodeHandler.FindOption <TelnetOptionMCCP>()?.Disable();
            }
        }