コード例 #1
0
ファイル: SipMessageCore.cs プロジェクト: seasky100/Gb28059
 public SipMessageCore(
     SIPTransport sipTransport,
     SIPAssetGetDelegate <SIPAccount> getSIPAccount,
     GetCanonicalDomainDelegate getCanonicalDomain,
     bool mangleUACContact,
     bool strictRealmHandling,
     SIPUserAgentConfigurationManager userAgentConfigs,
     SIPAuthenticateRequestDelegate sipRequestAuthenticator,
     string switchboarduserAgentPrefix,
     List <string> deviceList)
 {
     m_sipTransport                   = sipTransport;
     GetSIPAccount_External           = getSIPAccount;
     GetCanonicalDomain_External      = getCanonicalDomain;
     m_mangleUACContact               = mangleUACContact;
     m_strictRealmHandling            = strictRealmHandling;
     m_userAgentConfigs               = userAgentConfigs;
     SIPRequestAuthenticator_External = sipRequestAuthenticator;
     m_switchboarduserAgentPrefix     = switchboarduserAgentPrefix;
     m_userAgent  = m_userAgentConfigs.DefaultUserAgent ?? SIPConstants.SIP_USER_AGENT;
     MonitorItems = new Dictionary <string, SipMonitorCore>(500);
     foreach (string device in deviceList)
     {
         SipMonitorCore monitor = new SipMonitorCore(this, m_sipTransport, device);
         MonitorItems.Add(device, monitor);
     }
 }
コード例 #2
0
 public SIPRegistrarBindingsManager(
     SIPMonitorLogDelegate sipMonitorEventLog,
     SIPAssetPersistor <SIPRegistrarBinding> bindingsPersistor,
     SendNATKeepAliveDelegate sendNATKeepAlive,
     int maxBindingsPerAccount,
     SIPUserAgentConfigurationManager userAgentConfigs)
 {
     SIPMonitorEventLog_External = sipMonitorEventLog;
     m_bindingsPersistor         = bindingsPersistor;
     SendNATKeepAlive_External   = sendNATKeepAlive;
     m_maxBindingsPerAccount     = (maxBindingsPerAccount != 0) ? maxBindingsPerAccount : DEFAULT_BINDINGS_PER_USER;
     m_userAgentConfigs          = userAgentConfigs;
 }
コード例 #3
0
        public RegistrarCore(
            SIPTransport sipTransport,
            SIPRegistrarBindingsManager registrarBindingsManager,
            SIPAssetGetDelegate <SIPAccountAsset> getSIPAccount,
            GetCanonicalDomainDelegate getCanonicalDomain,
            bool mangleUACContact,
            bool strictRealmHandling,
            SIPMonitorLogDelegate proxyLogDelegate,
            SIPUserAgentConfigurationManager userAgentConfigs,
            SIPAuthenticateRequestDelegate sipRequestAuthenticator,
            string switchboarduserAgentPrefix,
            SIPAssetPersistor <Customer> customerPersistor)
        {
            m_sipTransport                   = sipTransport;
            m_registrarBindingsManager       = registrarBindingsManager;
            GetSIPAccount_External           = getSIPAccount;
            GetCanonicalDomain_External      = getCanonicalDomain;
            m_mangleUACContact               = mangleUACContact;
            m_strictRealmHandling            = strictRealmHandling;
            m_registrarLogEvent              = proxyLogDelegate;
            m_userAgentConfigs               = userAgentConfigs;
            SIPRequestAuthenticator_External = sipRequestAuthenticator;
            m_switchboarduserAgentPrefix     = switchboarduserAgentPrefix;
            CustomerPersistor_External       = customerPersistor;

            //try
            //{
            //    if (!switchboardCertificateName.IsNullOrBlank())
            //    {
            //        X509Certificate2 switchboardCertificate = AppState.LoadCertificate(StoreLocation.LocalMachine, switchboardCertificateName, false);
            //        m_switchbboardRSAProvider = (RSACryptoServiceProvider)switchboardCertificate.PrivateKey;
            //        logger.Debug("Switchboard RSA provider successfully loaded from " + switchboardCertificateName + " certificate.");
            //    }
            //}
            //catch (Exception excp)
            //{
            //    logger.Error("Exception loading switchboard certificate using " + switchboardCertificateName + ". " + excp.Message);
            //}
        }
コード例 #4
0
            public void GetCiscoExpiryUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                string registrarExpiryNode =
                    "<useragentconfigs>" +
                    "  <useragent expiry='3600'>fring</useragent>" +
                    "  <useragent expiry='300'>Cisco-CP7960G/8.0</useragent>" +
                    "  <useragent expiry='113'>*</useragent>" +
                    " </useragentconfigs>";
                XmlDocument regExpiryDom = new XmlDocument();

                regExpiryDom.LoadXml(registrarExpiryNode);

                SIPUserAgentConfigurationManager uaConfigManager = new SIPUserAgentConfigurationManager(regExpiryDom.DocumentElement);
                SIPUserAgentConfiguration        matchingUA      = uaConfigManager.GetUserAgentConfig("Cisco-CP7960G/8.0");

                Assert.IsNotNull(matchingUA, "A matching user agent entry was not found.");
                Assert.IsTrue(matchingUA.MaxAllowedExpiryTime == 300, "The expiry value for the Cisco ua was incorrect.");

                Console.WriteLine("---------------------------------");
            }
コード例 #5
0
 public SIPRegistrarBindingsManager(
     SIPMonitorLogDelegate sipMonitorEventLog,
     SIPAssetPersistor<SIPRegistrarBinding> bindingsPersistor,
     SendNATKeepAliveDelegate sendNATKeepAlive,
     int maxBindingsPerAccount,
     SIPUserAgentConfigurationManager userAgentConfigs)
 {
     SIPMonitorEventLog_External = sipMonitorEventLog;
     m_bindingsPersistor = bindingsPersistor;
     SendNATKeepAlive_External = sendNATKeepAlive;
     m_maxBindingsPerAccount = (maxBindingsPerAccount != 0) ? maxBindingsPerAccount : DEFAULT_BINDINGS_PER_USER;
     m_userAgentConfigs = userAgentConfigs;
 }
コード例 #6
0
        public RegistrarCore(
            SIPTransport sipTransport,
            SIPRegistrarBindingsManager registrarBindingsManager,
            SIPAssetGetDelegate<SIPAccount> getSIPAccount,
            GetCanonicalDomainDelegate getCanonicalDomain,
            bool mangleUACContact,
            bool strictRealmHandling,
            SIPMonitorLogDelegate proxyLogDelegate,
            SIPUserAgentConfigurationManager userAgentConfigs,
            SIPAuthenticateRequestDelegate sipRequestAuthenticator,
            string switchboardCertificateName)
        {
            m_sipTransport = sipTransport;
            m_registrarBindingsManager = registrarBindingsManager;
            GetSIPAccount_External = getSIPAccount;
            GetCanonicalDomain_External = getCanonicalDomain;
            m_mangleUACContact = mangleUACContact;
            m_strictRealmHandling = strictRealmHandling;
            m_registrarLogEvent = proxyLogDelegate;
            m_userAgentConfigs = userAgentConfigs;
            SIPRequestAuthenticator_External = sipRequestAuthenticator;

            try
            {
                if (!switchboardCertificateName.IsNullOrBlank())
                {
                    X509Certificate2 switchboardCertificate = AppState.LoadCertificate(StoreLocation.LocalMachine, switchboardCertificateName, false);
                    m_switchbboardRSAProvider = (RSACryptoServiceProvider)switchboardCertificate.PrivateKey;
                    logger.Debug("Switchboard RSA provider successfully loaded from " + switchboardCertificateName + " certificate.");
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception loading switchboard certificate using " + switchboardCertificateName + ". " + excp.Message);
            }
        }
コード例 #7
0
        public void Start() {
            try {
                logger.Debug("SIP Registrar daemon starting...");

                // Pre-flight checks.
                if (m_sipRegistrarSocketsNode == null || m_sipRegistrarSocketsNode.ChildNodes.Count == 0) {
                    throw new ApplicationException("The SIP Registrar cannot start without at least one socket specified to listen on, please check config file.");
                }

                // Send events from this process to the monitoring socket.
                if (m_monitorLoopbackPort != 0) {
                    // Events will be sent by the monitor channel to the loopback interface and this port.
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorLoopbackPort);
                    logger.Debug("Monitor channel initialised for 127.0.0.1:" + m_monitorLoopbackPort + ".");
                }

                // Configure the SIP transport layer.
                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), false);
                m_sipTransport.PerformanceMonitorPrefix = SIPSorceryPerformanceMonitor.REGISTRAR_PREFIX;
                List<SIPChannel> sipChannels = SIPTransportConfig.ParseSIPChannelsNode(m_sipRegistrarSocketsNode);
                m_sipTransport.AddSIPChannel(sipChannels);

                // Create and configure the SIP Registrar core.
                if (m_natKeepAliveRelaySocket != null) {
                    m_natKeepAliveSender = new UdpClient();
                }

                SIPUserAgentConfigurationManager userAgentConfigManager = new SIPUserAgentConfigurationManager(m_userAgentsConfigNode);
                if (m_userAgentsConfigNode == null) {
                    logger.Warn("The UserAgent config's node was missing.");
                }
                m_registrarBindingsManager = new SIPRegistrarBindingsManager(FireSIPMonitorEvent, m_registrarBindingsPersistor, SendNATKeepAlive, m_maximumAccountBindings, userAgentConfigManager);
                m_registrarBindingsManager.Start();

                m_registrarCore = new RegistrarCore(m_sipTransport, m_registrarBindingsManager, GetSIPAccount_External, GetCanonicalDomain_External, true, true, FireSIPMonitorEvent, userAgentConfigManager, SIPAuthenticateRequest_External, m_switchboardCertificateName);
                m_registrarCore.Start(m_threadCount);
                m_sipTransport.SIPTransportRequestReceived += m_registrarCore.AddRegisterRequest;

                logger.Debug("SIP Registrar successfully started.");
            }
            catch (Exception excp) {
                logger.Error("Exception SIPRegistrarDaemon Start. " + excp.Message);
            }
        }
コード例 #8
0
            public void GetCiscoExpiryUnitTest() {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                string registrarExpiryNode =
                    "<useragentconfigs>" +
                    "  <useragent expiry='3600'>fring</useragent>" +
                    "  <useragent expiry='300'>Cisco-CP7960G/8.0</useragent>" +
                    "  <useragent expiry='113'>*</useragent>" +
                    " </useragentconfigs>";
                XmlDocument regExpiryDom = new XmlDocument();
                regExpiryDom.LoadXml(registrarExpiryNode);

                SIPUserAgentConfigurationManager uaConfigManager = new SIPUserAgentConfigurationManager(regExpiryDom.DocumentElement);
                SIPUserAgentConfiguration matchingUA = uaConfigManager.GetUserAgentConfig("Cisco-CP7960G/8.0");

                Assert.IsNotNull(matchingUA, "A matching user agent entry was not found.");
                Assert.IsTrue(matchingUA.MaxAllowedExpiryTime == 300, "The expiry value for the Cisco ua was incorrect.");

                Console.WriteLine("---------------------------------");
            }