/// <summary> /// Update method implmentation /// </summary> public override void Load(PSHost host) { ManagementService.Initialize(host, true); MFAConfig cfg = ManagementService.Config; MailProvider mail = cfg.MailProvider; IsDirty = cfg.IsDirty; Enabled = mail.Enabled; EnrollWizard = mail.EnrollWizard; ForceWizard = mail.ForceWizard; From = mail.From; UserName = mail.UserName; Password = mail.Password; Host = mail.Host; Port = mail.Port; UseSSL = mail.UseSSL; Company = mail.Company; PinRequired = mail.PinRequired; Anonymous = mail.Anonymous; DeliveryNotifications = mail.DeliveryNotifications; FullQualifiedImplementation = mail.FullQualifiedImplementation; Parameters = mail.Parameters.Data; AllowedDomains.Clear(); foreach (string itm in mail.AllowedDomains) { AllowedDomains.AddDomain(itm); } BlockedDomains.Clear(); foreach (string itm in mail.BlockedDomains) { BlockedDomains.AddDomain(itm); } MailOTPContent.Clear(); foreach (SendMailFileName itm in mail.MailOTPContent) { MailOTPContent.Add((FlatConfigMailFileName)itm); } MailAdminContent.Clear(); foreach (SendMailFileName itm in mail.MailAdminContent) { MailAdminContent.Add((FlatConfigMailFileName)itm); } MailKeyContent.Clear(); foreach (SendMailFileName itm in mail.MailKeyContent) { MailKeyContent.Add((FlatConfigMailFileName)itm); } MailNotifications.Clear(); foreach (SendMailFileName itm in mail.MailNotifications) { MailNotifications.Add((FlatConfigMailFileName)itm); } }
public static async Task RefreshData(SocketCommandContext context) { string emoji = Constants.EMOJI_THUMBSUP; string title = "Success"; string body = Constants.COMMAND_REFRESH_SUCCESSFUL; try { Sitemap.ReloadData(); BlockedDomains.ReloadData(); HassBotCommands.ReloadData(); } catch { emoji = Constants.EMOJI_FAIL; title = "Failed"; body = Constants.COMMAND_REFRESH_FAILED; } // Send response await Helper.CreateEmbed(context, emoji, title, body, forceremoveoriginalmessage : true); }
public static async Task RefreshData(SocketCommandContext context) { var embed = new EmbedBuilder(); try { Sitemap.ReloadData(); BlockedDomains.ReloadData(); HassBotCommands.ReloadData(); } catch { embed.WithColor(Color.Red); embed.AddInlineField(Constants.EMOJI_FAIL, Constants.COMMAND_REFRESH_FAILED); await context.Channel.SendMessageAsync(string.Empty, false, embed); return; } embed.WithColor(Helper.GetRandomColor()); embed.AddInlineField(Constants.EMOJI_THUMBSUP, Constants.COMMAND_REFRESH_SUCCESSFUL); await context.Channel.SendMessageAsync(string.Empty, false, embed); }
static public bool IsProbablyFakeEmail(string email, int meanness, bool validateMx = false) { if (validateMx && !ReverseDnsComplete) { ReverseDnsCompleteEvent.Wait(); ReverseDnsComplete = true; } if (string.IsNullOrWhiteSpace(email)) { return(true); } //Instead of making all the regex rules case-insensitive email = email.ToLower(); if (!IsValidFormat(email)) { return(true); } var mailAddress = new MailAddress(email); if (meanness >= 0) { if (DomainMinimumPrefix.TryGetValue(mailAddress.Host, out var minimumPrefix) && minimumPrefix > mailAddress.User.Length) { return(true); } if (MistypedDomains.Contains(mailAddress.Host)) { return(true); } if (MistypedTldRegex.IsMatch(mailAddress.Host)) { return(true); } } if (meanness >= 1) { if (BlockedDomains.Contains(mailAddress.Host)) { return(true); } } if (meanness >= 2) { if (ExpressionRegex.IsMatch(mailAddress.User)) { return(true); } } if (meanness >= 4) { if (RepeatedCharsRegex.IsMatch(mailAddress.User) || RepeatedCharsRegex.IsMatch(mailAddress.Host)) { return(true); } } if (meanness >= 5) { if (NumericEmailRegex.IsMatch(mailAddress.User)) { return(true); } if (ExpressionRegex.IsMatch(email)) { return(true); } } if (meanness >= 6) { if (QwertyRegex.IsMatch(mailAddress.User)) { return(true); } if (QwertyDomainRegex.IsMatch(mailAddress.Host)) { return(true); } if (NumericDomainRegex.IsMatch(mailAddress.Host)) { return(true); } } if (meanness >= 7) { //this is including the tld, so 3 is insanely generous //2 letters + period + 3 tld = 6 if (mailAddress.Host.Length < 6) { return(true); } } if (meanness >= 8) { if (mailAddress.User.Length < 3) { return(true); } } if (meanness >= 9) { if (mailAddress.User.Length < 5) { return(true); } } if (meanness >= 10) { if (TldRegex.IsMatch(mailAddress.Host)) { return(true); } } //Do this last because it's the most expensive if (validateMx) { if (!ValidDomainCache.Contains(mailAddress.Host)) { bool mxFound; var mxRecords = DnsLookup.GetMXRecords(mailAddress.Host, out mxFound); if (!mxFound || !mxRecords.Any()) { //no MX record associated with this address or timeout return(true); } //compare against blacklist foreach (var record in mxRecords) { DnsLookup.GetIpAddresses(record, out var addresses); if (addresses != null && addresses.Any(BlockedMxAddresses.Contains)) { //this mx record points to the same IP as a blacklisted MX record or timeout return(true); } } lock (ValidDomainCache) { ValidDomainCache.Add(mailAddress.Host); } } } return(false); }