mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 13:27:21 +00:00
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using AIStudio.Tools.PluginSystem;
|
|
|
|
namespace AIStudio.Settings.DataModel;
|
|
|
|
public static class MailboxTransportSecurityExtensions
|
|
{
|
|
/// <summary>
|
|
/// The port IMAP with TLS from the start usually listens on.
|
|
/// </summary>
|
|
public const int SSL_ON_CONNECT_PORT = 993;
|
|
|
|
/// <summary>
|
|
/// The port IMAP with STARTTLS usually listens on.
|
|
/// </summary>
|
|
public const int STARTTLS_PORT = 143;
|
|
|
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(MailboxTransportSecurityExtensions).Namespace, nameof(MailboxTransportSecurityExtensions));
|
|
|
|
extension(MailboxTransportSecurity transportSecurity)
|
|
{
|
|
public string GetName() => transportSecurity switch
|
|
{
|
|
MailboxTransportSecurity.SSL_ON_CONNECT => TB("TLS from the start (usually port 993)"),
|
|
MailboxTransportSecurity.STARTTLS => TB("STARTTLS (usually port 143)"),
|
|
|
|
_ => TB("Unknown encryption"),
|
|
};
|
|
|
|
/// <summary>
|
|
/// The port the encryption usually comes with.
|
|
/// </summary>
|
|
/// <returns>The port, or null when there is no usual one.</returns>
|
|
public int? GetUsualPort() => transportSecurity switch
|
|
{
|
|
MailboxTransportSecurity.SSL_ON_CONNECT => SSL_ON_CONNECT_PORT,
|
|
MailboxTransportSecurity.STARTTLS => STARTTLS_PORT,
|
|
|
|
_ => null,
|
|
};
|
|
}
|
|
} |