Exemplo n.º 1
0
        protected void CreateTransport(ConnectorType transportType, ProgramSettings settings)
        {
            if (transportType == ConnectorType.UDP)
            {
                m_Transport = new SipTransportUdp(settings);
            }
            else if (transportType == ConnectorType.TCP)
            {
                m_Transport = new SipTransportTcp(settings);
            }

            m_Transport.PipeDead              += OnPipeDead;
            m_Transport.SipReceivedFromPipe   += OnSipReceivedFromPipe;
            m_Transport.SipReceivedFromClient += OnSipReceivedFromClient;
        }
Exemplo n.º 2
0
        public void SetServer(string sipServerHost, ushort sipServerPort)
        {
            if (m_RemoteHostSet)
            {
                throw new InvalidOperationException();
            }
            if (null == sipServerHost)
            {
                throw new ArgumentNullException("sipServerHost");
            }

            m_RemoteEp = new NET.IPEndPoint(
                ProgramSettings.IpFromHost(sipServerHost),
                sipServerPort
                );
            m_RemoteHostSet = true;
        }
Exemplo n.º 3
0
        public SipProxyServer(SOCK.TcpClient tcpClient, ProgramSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            if (settings.ServerType == ConnectorType.None)
            {
                throw new InvalidOperationException("Server cannot be created because is is disabled.");
            }
            if (null == tcpClient)
            {
                throw new ArgumentNullException("tcpClient");
            }

            CreateTransport(settings.ServerType, settings);
            m_Transport.PrepareClient(settings.ServerIp, 0);
            m_Transport.PreparePipe(tcpClient);
            m_PipeRemoteEp = m_Transport.PipeRemoteEndPoint;
        }
Exemplo n.º 4
0
        public SipProxyClient(ProgramSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            if (null == settings.ClientServerHost || 0 == settings.ClientServerHost.Length)
            {
                throw new SipProxyClientException("SipTunnel server host is not set.");
            }
            if (0 == settings.ClientServerPort)
            {
                throw new SipProxyClientException("SipTunnel server port is not set.");
            }
            if (0 == settings.ClientPort)
            {
                throw new SipProxyClientException("SipTunnel client port is not set.");
            }
            if (settings.ClientType == ConnectorType.None)
            {
                throw new InvalidOperationException("Client cannot be created because is is disabled.");
            }

            CreateTransport(settings.ClientType, settings);

            //ReconnectTcp();
            m_tcpThread = new System.Threading.Thread(TcpChannelProc);
            m_tcpThread.Start();

            m_Transport.PrepareClient(Settings.ClientIp, Settings.ClientPort);

            Settings.WriteMessageToLog(
                LogMessageType.Information,
                string.Format(
                    CultureInfo.CurrentUICulture,
                    "SipTunnel client is started, listening on {0}:{1}.",
                    Settings.ClientIp,
                    Settings.ClientPort
                    )
                );
        }
Exemplo n.º 5
0
        public ServerListener(ProgramSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            if (0 == settings.ServerPort)
            {
                throw new ApplicationException();
            }

            m_Settings = settings;

            m_tcpListener = new SOCK.TcpListener(
                new NET.IPEndPoint(NET.IPAddress.Any, settings.ServerPort)
                );
            m_tcpListener.Start();
            m_tcpListener.BeginAcceptTcpClient(OnConnect, null);

            m_Settings.WriteMessageToLog(
                LogMessageType.Information,
                string.Format(CultureInfo.CurrentUICulture, "SipTunnel server started and is listening on port {0}.", m_Settings.ServerPort)
                );
        }
Exemplo n.º 6
0
 public SipTransportUdp(ProgramSettings settings)
     : base(settings)
 {
     m_udpReceiveThread = new System.Threading.Thread(UdpReceiveProc);
 }
Exemplo n.º 7
0
 public SipTransportTcp(ProgramSettings settings)
     : base(settings)
 {
 }