<commit_before>﻿using ExoMail.Smtp.Enums;
using ExoMail.Smtp.Utilities;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ExoMail.Smtp.Protocol
{
    public class SmtpStartTlsCommand : SmtpCommandBase
    {
        public SmtpStartTlsCommand(string command, List<string> arguments)
        {
            Command = command;
            Arguments = arguments;
        }

        public override bool ArgumentsValid
        {
            get
            {
                return this.Arguments.Count == 0;
            }
        }

        private string GetResponse()
        {
            string response;

            if (this.ArgumentsValid)
            {
                switch (this.SmtpSession.SessionState)
                {
                    case SessionState.EhloNeeded:
                        response = SmtpResponse.SendHelloFirst;
                        break;

                    case SessionState.StartTlsNeeded:
                        this.IsValid = true;
                        response = SmtpResponse.StartTls;
                        break;

                    default:
                        response = SmtpResponse.BadCommand;
                        break;
                }
            }
            else
            {
                response = SmtpResponse.ArgumentUnrecognized;
            }
            return response;
        }

        public override async Task<string> GetResponseAsync()
        {
            return await Task.Run(() => GetResponse());
        }

        public override async Task ProcessCommandAction()
        {
            if (this.IsValid)
            {
                await this.SmtpSession.StartTlsAsync();
                this.SmtpSession.SessionState = SessionState.EhloNeeded;
                this.SmtpSession.SmtpCommands.Add(this);
            }
        }
    }
}<commit_msg>StartTls allowed even if it is not required.<commit_after>﻿using ExoMail.Smtp.Enums;
using ExoMail.Smtp.Utilities;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ExoMail.Smtp.Protocol
{
    public class SmtpStartTlsCommand : SmtpCommandBase
    {
        public SmtpStartTlsCommand(string command, List<string> arguments)
        {
            Command = command;
            Arguments = arguments;
        }

        public override bool ArgumentsValid
        {
            get
            {
                return this.Arguments.Count == 0;
            }
        }

        private string GetResponse()
        {
            string response;

            if (this.ArgumentsValid)
            {
                switch (this.SmtpSession.SessionState)
                {
                    case SessionState.EhloNeeded:
                        response = SmtpResponse.SendHelloFirst;
                        break;
                    case SessionState.MailNeeded:
                    case SessionState.StartTlsNeeded:
                        this.IsValid = true;
                        response = SmtpResponse.StartTls;
                        break;

                    default:
                        response = SmtpResponse.BadCommand;
                        break;
                }
            }
            else
            {
                response = SmtpResponse.ArgumentUnrecognized;
            }
            return response;
        }

        public override async Task<string> GetResponseAsync()
        {
            return await Task.Run(() => GetResponse());
        }

        public override async Task ProcessCommandAction()
        {
            if (this.IsValid)
            {
                await this.SmtpSession.StartTlsAsync();
                this.SmtpSession.SessionState = SessionState.EhloNeeded;
                this.SmtpSession.SmtpCommands.Add(this);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06682389937106918, 'fraction_numerical': 0.0005241090146750524, 'mean_word_length': 1.2101910828025477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4032243', 'n_tokens_mistral': 962, 'n_tokens_neox': 894, 'n_words': 173}