예제 #1
0
 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);
     }
 }
예제 #2
0
        public void AddDomain(SIPDomain sipDomain)
        {
            if (sipDomain == null)
            {
                //throw new ArgumentException("The SIPDomainManager cannot add a null SIPDomain object.");
                logger.Error("The SIPDomainManager cannot add a null SIPDomain object.");
            }
            else
            {
                if (!m_domains.ContainsKey(sipDomain.Domain.ToLower()))
                {
                    logger.Debug(" SIPDomainManager added domain: " + sipDomain.Domain + ".");
                    sipDomain.Aliases.ForEach(a => 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.Debug(" SIPDomainManager wildcard domain set to " + sipDomain.Domain + ".");
                        }
                    });
                }
                else
                {
                    logger.Warn("SIPDomainManager ignoring duplicate domain entry for " + sipDomain.Domain.ToLower() + ".");
                }
            }
        }
예제 #3
0
 public void RemoveDomain(SIPDomain sipDomain)
 {
     if (sipDomain != null)
     {
         if (m_domains.ContainsKey(sipDomain.Domain.ToLower()))
         {
             m_domains.Remove(sipDomain.Domain.ToLower());
         }
     }
 }
예제 #4
0
 public void RemoveAlias(string alias)
 {
     try
     {
         if (alias.IsNullOrBlank())
         {
             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.Warn("Could not remove alias " + alias + ".");
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception SIPDomainManager RemoveAlias. " + excp.Message);
     }
 }
예제 #5
0
        /// <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());
        }