public void AddDomain(SIPDomain sipDomain) { if (sipDomain == null) { //throw new ArgumentException("The SIPDomainManager cannot add a null SIPDomain object."); Logger.Logger.Error("The SIPDomainManager cannot add a null SIPDomain object."); } else { if (!m_domains.ContainsKey(sipDomain.Domain.ToLower())) { Logger.Logger.Debug(" SIPDomainManager added domain: " + sipDomain.Domain + "."); sipDomain.Aliases.ForEach(a => Logger.Logger.Debug(" added domain alias " + a + ".")); m_domains.Add(sipDomain.Domain.ToLower(), sipDomain); sipDomain.Aliases.ForEach(aliasItem => { if (aliasItem == WILDCARD_DOMAIN_ALIAS && m_wildCardDomain == null) { m_wildCardDomain = sipDomain; Logger.Logger.Debug(" SIPDomainManager wildcard domain set to " + sipDomain.Domain + "."); } }); } else { Logger.Logger.Warn("SIPDomainManager ignoring duplicate domain entry for " + sipDomain.Domain.ToLower() + "."); } } }
public void AddAlias(string domain, string alias) { try { if (domain.IsNullOrBlank() || alias.IsNullOrBlank()) { logger.Warn("AddAlias was passed a null alias or domain."); } else if (!HasDomain(alias.ToLower(), false) && HasDomain(domain.ToLower(), false)) { SIPDomain sipDomain = GetSIPDomain(domain.ToLower(), false); if (alias == WILDCARD_DOMAIN_ALIAS) { if (m_wildCardDomain != null) { m_wildCardDomain = sipDomain; logger.Debug(" SIPDomainManager wildcard domain set to " + sipDomain.Domain + "."); } } else { sipDomain.Aliases.Add(alias.ToLower()); logger.Debug(" SIPDomainManager added alias to " + sipDomain.Domain + " of " + alias.ToLower() + "."); } } else { logger.Warn("Could not add alias " + alias + " to domain " + domain + "."); } } catch (Exception excp) { logger.Error("Exception SIPDomainManager AddAlias. " + excp.Message); } }
public void RemoveDomain(SIPDomain sipDomain) { if (sipDomain != null) { if (m_domains.ContainsKey(sipDomain.Domain.ToLower())) { m_domains.Remove(sipDomain.Domain.ToLower()); } } }
public void RemoveAlias(string alias) { try { if (alias.IsNullOrBlank()) { Logger.Logger.Warn("RemoveAlias was passed a null alias."); } else if (HasDomain(alias.ToLower(), false)) { SIPDomain sipDomain = GetSIPDomain(alias.ToLower(), false); sipDomain.Aliases.Remove(alias.ToLower()); } else { Logger.Logger.Warn("Could not remove alias " + alias + "."); } } catch (Exception excp) { Logger.Logger.Error("Exception SIPDomainManager RemoveAlias. ->" + excp.Message); } }
/// <summary> /// Checks whether there the supplied hostname represents a serviced domain or alias. /// </summary> /// <param name="host">The hostname to check for a serviced domain for.</param> /// <returns>The canconical domain name for the host if found or null if not.</returns> public string GetDomain(string host, bool wilcardOk) { SIPDomain domain = GetSIPDomain(host, wilcardOk); return(domain?.Domain.ToLower()); }