コード例 #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="proxy">Owner proxy.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>proxy</b> is null reference.</exception>
        internal SIP_Registrar(SIP_Proxy proxy)
        {
            if(proxy == null){
                throw new ArgumentNullException("proxy");
            }

            m_pProxy = proxy;
            m_pStack = m_pProxy.Stack;

            m_pRegistrations = new SIP_RegistrationCollection();

            m_pTimer = new Timer(15000);
            m_pTimer.Elapsed += new ElapsedEventHandler(m_pTimer_Elapsed);
            m_pTimer.Enabled = true;
        }
コード例 #2
0
ファイル: SIP_RequestContext.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="proxy">Owner SIP proxy server.</param>
        /// <param name="request">The request what is represented by this context.</param>
        /// <param name="flow">Data flow what received request.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>proxy</b>, <b>request</b> or <b>flow</b> is null reference.</exception>
        internal SIP_RequestContext(SIP_Proxy proxy,SIP_Request request,SIP_Flow flow)
        {
            if(proxy == null){
                throw new ArgumentNullException("proxy");
            }
            if(request == null){
                throw new ArgumentNullException("request");
            }
            if(flow == null){
                throw new ArgumentNullException("flow");
            }

            m_pProxy   = proxy;
            m_pRequest = request;
            m_pFlow    = flow;

            m_pTargets = new List<SIP_ProxyTarget>();
        }
コード例 #3
0
        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        internal void Dispose()
        {
            if(m_IsDisposed){
                return;
            }
            m_IsDisposed = true;

            this.CanRegister     = null;
            this.AorRegistered   = null;
            this.AorUnregistered = null;
            this.AorUpdated      = null;

            m_pProxy = null;
            m_pStack = null;
            m_pRegistrations = null;
            if(m_pTimer != null){
                m_pTimer.Dispose();
                m_pTimer = null;
            }
        }
コード例 #4
0
ファイル: SIP_B2BUA.cs プロジェクト: CivilPol/LumiSoft.Net
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="owner">Onwer SIP proxy.</param>
 internal SIP_B2BUA(SIP_Proxy owner)
 {
     m_pProxy = owner; 
     m_pCalls = new List<SIP_B2BUA_Call>();
 }
コード例 #5
0
        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        public void Dispose()
        {
            lock(m_pLock){
                if(m_IsDisposed){
                    return;
                }
                m_IsDisposed = true;

                m_pProxy.Stack.Logger.AddText("ProxyContext(id='" + m_ID + "') disposed.");

                m_pProxy.m_pProxyContexts.Remove(this);

                m_pProxy             = null;
                m_pServerTransaction = null;
                m_pTargetsHandlers   = null;
                m_pResponses         = null;
                m_pTargets           = null;
            }
        }
コード例 #6
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="proxy">Owner proxy.</param>
        /// <param name="transaction">Server transaction what is used to send SIP responses back to caller.</param>
        /// <param name="request">Request to forward.</param>
        /// <param name="addRecordRoute">If true, Record-Route header field will be added.</param>
        /// <param name="forkingMode">Specifies how proxy context must handle forking.</param>
        /// <param name="isB2BUA">Specifies if proxy context is in B2BUA or just transaction satefull mode.</param>
        /// <param name="noCancel">Specifies if proxy should not send Cancel to forked requests.</param>
        /// <param name="noRecurse">Specifies what proxy server does when it gets 3xx response. If true proxy will forward
        /// request to new specified address if false, proxy will return 3xx response to caller.</param>
        /// <param name="targets">Possible remote targets. NOTE: These values must be in priority order !</param>
        /// <exception cref="ArgumentNullException">Is raised when any of the reference type prameters is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        internal SIP_ProxyContext(SIP_Proxy proxy,SIP_ServerTransaction transaction,SIP_Request request,bool addRecordRoute,SIP_ForkingMode forkingMode,bool isB2BUA,bool noCancel,bool noRecurse,SIP_ProxyTarget[] targets)
        {
            if(proxy == null){
                throw new ArgumentNullException("proxy");
            }
            if(transaction == null){
                throw new ArgumentNullException("transaction");
            }
            if(request == null){
                throw new ArgumentNullException("request");
            }
            if(targets == null){
                throw new ArgumentNullException("targets");
            }
            if(targets.Length == 0){
                throw new ArgumentException("Argumnet 'targets' must contain at least 1 value.");
            }

            m_pProxy = proxy;

            m_pServerTransaction = transaction;
            m_pServerTransaction.Canceled += new EventHandler(m_pServerTransaction_Canceled);
            m_pServerTransaction.Disposed += new EventHandler(m_pServerTransaction_Disposed);

            m_pRequest       = request;
            m_AddRecordRoute = addRecordRoute;
            m_ForkingMode    = forkingMode;
            m_IsB2BUA        = isB2BUA;
            m_NoCancel       = noCancel;
            m_NoRecurse      = noRecurse;

            m_pTargetsHandlers = new List<TargetHandler>();
            m_pResponses       = new List<SIP_Response>();
            m_ID               = Guid.NewGuid().ToString();
            m_CreateTime       = DateTime.Now;

            // Queue targets up, higest to lowest.
            m_pTargets = new Queue<TargetHandler>();
            foreach(SIP_ProxyTarget target in targets){
                m_pTargets.Enqueue(new TargetHandler(this,target.Flow,target.TargetUri,m_AddRecordRoute,false));
            }

            m_pCredentials = new List<NetworkCredential>();

            /*  RFC 3841 9.1.
                The Request-Disposition header field specifies caller preferences for
                how a server should process a request.
              
                Override SIP proxy default value.
            */
            foreach(SIP_t_Directive directive in request.RequestDisposition.GetAllValues()){
                if(directive.Directive == SIP_t_Directive.DirectiveType.NoFork){
                    m_ForkingMode = SIP_ForkingMode.None;
                }
                else if(directive.Directive == SIP_t_Directive.DirectiveType.Parallel){
                    m_ForkingMode = SIP_ForkingMode.Parallel;
                }
                else if(directive.Directive == SIP_t_Directive.DirectiveType.Sequential){
                    m_ForkingMode = SIP_ForkingMode.Sequential;
                }                    
                else if(directive.Directive == SIP_t_Directive.DirectiveType.NoCancel){
                    m_NoCancel = true;
                }                    
                else if(directive.Directive == SIP_t_Directive.DirectiveType.NoRecurse){
                    m_NoRecurse = true;
                }
            }

            m_pProxy.Stack.Logger.AddText("ProxyContext(id='" + m_ID + "') created.");
        }
コード例 #7
0
ファイル: VirtualServer.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Stops this virtual server.
        /// </summary>
        public void Stop()
        {
            m_Running = false;

            if(m_pDnsClient != null){
                m_pDnsClient.Dispose();
                m_pDnsClient = null;
            }
            if(m_pSmtpServer != null){
                try{
                    m_pSmtpServer.Dispose();
                }
                catch{
                }
                m_pSmtpServer = null;
            }
            if(m_pPop3Server != null){
                try{
                    m_pPop3Server.Dispose();
                }
                catch{
                }
                m_pPop3Server = null;
            }
            if(m_pImapServer != null){
                try{
                    m_pImapServer.Dispose();
                }
                catch{
                }
                m_pImapServer = null;
            }
            if(m_pRelayServer != null){
                try{
                    m_pRelayServer.Dispose();
                }
                catch{
                }
                m_pRelayServer = null;
            }
            if(m_pFetchServer != null){
                try{
                    m_pFetchServer.Dispose();                    
                }
                catch{
                }
                m_pFetchServer = null;
            } 
            if(m_pSipServer != null){
                try{
                    m_pSipServer.Stack.Stop();                    
                }
                catch{
                }
                m_pSipServer = null;
            } 
            if(m_pTimer != null){
                try{
                    m_pTimer.Dispose();
                }
                catch{
                }
                m_pTimer = null;
            }
            if(m_pRecycleBinManager != null){
                try{
                    m_pRecycleBinManager.Dispose();
                }
                catch{
                }
                m_pRecycleBinManager = null;
            }
            if(m_pBadLoginManager != null){
                try{
                    m_pBadLoginManager.Dispose();
                }
                catch{
                }
                m_pBadLoginManager = null;
            }
        }
コード例 #8
0
ファイル: VirtualServer.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Starts this virtual server.
        /// </summary>
        public void Start()
        {
            if(m_Running){
                return;
            }
            m_Running = true;

            m_pDnsClient = new Dns_Client();

            m_pSmtpServer = new SMTP_Server();
            m_pSmtpServer.Error += new LumiSoft.Net.ErrorEventHandler(OnServer_SysError);
            m_pSmtpServer.SessionCreated += new EventHandler<TCP_ServerSessionEventArgs<SMTP_Session>>(m_pSmtpServer_SessionCreated);

            m_pPop3Server = new POP3_Server();            
            m_pPop3Server.Error += new LumiSoft.Net.ErrorEventHandler(OnServer_SysError);            
            m_pPop3Server.SessionCreated += new EventHandler<TCP_ServerSessionEventArgs<POP3_Session>>(m_pPop3Server_SessionCreated);
                        
            m_pImapServer = new IMAP_Server();
            m_pImapServer.Error += new LumiSoft.Net.ErrorEventHandler(OnServer_SysError);
            m_pImapServer.SessionCreated += new EventHandler<TCP_ServerSessionEventArgs<IMAP_Session>>(m_pImapServer_SessionCreated);
            
            m_pRelayServer = new RelayServer(this);
            m_pRelayServer.DnsClient = m_pDnsClient;

            m_pFetchServer = new FetchPop3(this,m_pApi);

            m_pSipServer = new SIP_Proxy(new SIP_Stack());
            m_pSipServer.Authenticate += new SIP_AuthenticateEventHandler(m_pSipServer_Authenticate);
            m_pSipServer.IsLocalUri += new SIP_IsLocalUriEventHandler(m_pSipServer_IsLocalUri);
            m_pSipServer.AddressExists += new SIP_AddressExistsEventHandler(m_pSipServer_AddressExists);
            m_pSipServer.Registrar.CanRegister += new SIP_CanRegisterEventHandler(m_pSipServer_CanRegister);
            m_pSipServer.Stack.Error += new EventHandler<ExceptionEventArgs>(m_pSipServer_Error);
            
            m_pRecycleBinManager = new RecycleBinManager(m_pApi);
 
            m_pBadLoginManager = new BadLoginManager();

            m_pTimer = new System.Timers.Timer();            
            m_pTimer.Interval = 15000;
            m_pTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimer_Elapsed);
            m_pTimer.Enabled = true;

            LoadSettings();
        }