Exemplo n.º 1
0
 /// <summary>
 /// Creates a new SSL Server and listen for clients.
 /// </summary>
 /// <param name="LocalAddress">IPAddress.Any</param>
 /// <param name="Port">The local port of the server.</param>
 /// <param name="PColl">The PortalCollection.</param>
 /// <param name="SSL">SSL connection settings.</param>
 public VaserServer(IPAddress LocalAddress, int Port, PortalCollection PColl, VaserSSLServer SSL)
 {
     if (SSL == null)
     {
         throw new Exception("Missing SSL options in VaserServer(...)");
     }
     if (PColl == null)
     {
         throw new Exception("PortalCollection is needed!");
     }
     try
     {
         _vSSL           = SSL;
         ServerOption    = VaserOptions.ModeSSL;
         PColl.Active    = true;
         PCollection     = PColl;
         _socketListener = new StreamSocketListener();
         _socketListener.ConnectionReceived += SocketListener_ConnectionReceived;
         _Port = Port.ToString();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new connection for processing data
        /// </summary>
        public Connection(Socket client, bool _IsServer, VaserOptions Mode, PortalCollection PColl, VaserKerberosServer KerberosS, VaserSSLServer SSLS, VaserKerberosClient KerberosC, VaserSSLClient SSLC, VaserServer srv = null)
        {
            IsServer          = _IsServer;
            StreamIsConnected = true;

            _rms2 = new MemoryStream();
            _rbr2 = new BinaryReader(_rms2);


            _Mode        = Mode;
            _PCollection = PColl;

            _vSSLS      = SSLS;
            _vKerberosS = KerberosS;
            _vSSLC      = SSLC;
            _vKerberosC = KerberosC;

            _SocketTCPClient             = client;
            _SocketTCPClient.LingerState = new LingerOption(true, 0);

            server = srv;

            IPv4Address = ((IPEndPoint)client.RemoteEndPoint).Address;

            link = new Link(PColl)
            {
                Connect = this
            };
            if (Mode == VaserOptions.ModeNotEncrypted)
            {
                mySendNotEncryptedCallback    = new AsyncCallback(SendNotEncryptedCallback);
                myReceiveNotEncryptedCallback = new AsyncCallback(ReceiveNotEncryptedCallback);
            }
            if (Mode == VaserOptions.ModeKerberos)
            {
                mySendKerberosCallback    = new AsyncCallback(SendKerberosCallback);
                myReceiveKerberosCallback = new AsyncCallback(ReceiveKerberosCallback);
            }

            if (Mode == VaserOptions.ModeSSL)
            {
                mySendSSLCallback    = new AsyncCallback(SendSSLCallback);
                myReceiveSSLCallback = new AsyncCallback(ReceiveSSLCallback);
            }
            if (_IsServer)
            {
                ThreadPool.QueueUserWorkItem(HandleClientComm);
            }
            else
            {
                HandleClientComm(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new connection for processing data
        /// </summary>
        public Connection(StreamSocket client, bool _IsServer, VaserOptions Mode, PortalCollection PColl, VaserKerberosServer KerberosS, VaserSSLServer SSLS, VaserKerberosClient KerberosC, VaserSSLClient SSLC, VaserServer srv = null)
        {
            IsServer          = _IsServer;
            StreamIsConnected = true;

            _rms2 = new MemoryStream();
            _rbr2 = new BinaryReader(_rms2);


            _Mode        = Mode;
            _PCollection = PColl;

            _vSSLS      = SSLS;
            _vKerberosS = KerberosS;
            _vSSLC      = SSLC;
            _vKerberosC = KerberosC;

            _SocketTCPClient = client;

            server = srv;
            //Debug.WriteLine("Init Options Done");
            IPv4Address = client.Information.RemoteAddress;

            link = new Link(PColl)
            {
                Connect = this
            };
            //Debug.WriteLine("Create Link Done");

            //Debug.WriteLine("Init Connection class DONE");
            if (_IsServer)
            {
                //Debug.WriteLine("Send to HandleClientComm");
                IAsyncAction asyncAction = ThreadPool.RunAsync(HandleClientComm);
            }
            else
            {
                HandleClientComm(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new connection for processing data
        /// </summary>
        public Connection(Socket client, bool _IsServer, VaserOptions Mode, PortalCollection PColl, VaserKerberosServer KerberosS, VaserSSLServer SSLS, VaserKerberosClient KerberosC, VaserSSLClient SSLC, VaserServer srv = null)
        {
            IsServer          = _IsServer;
            StreamIsConnected = true;


            _rms2 = new MemoryStream();
            _rbr2 = new BinaryReader(_rms2);



            _Mode        = Mode;
            _PCollection = PColl;

            _vSSLS      = SSLS;
            _vKerberosS = KerberosS;
            _vSSLC      = SSLC;
            _vKerberosC = KerberosC;

            client.SendBufferSize = 65007;
            _SocketTCPClient      = client;

            server = srv;

            IPv4Address = ((IPEndPoint)client.RemoteEndPoint).Address;

            link         = new Link(PColl);
            link.Connect = this;

            if (_IsServer)
            {
                ThreadPool.QueueUserWorkItem(HandleClientComm);
            }
            else
            {
                HandleClientComm(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new SSL Server and listen for clients.
 /// </summary>
 /// <param name="LocalAddress">IPAddress.Any</param>
 /// <param name="Port">The local port of the server.</param>
 /// <param name="PColl">The PortalCollection.</param>
 /// <param name="SSL">SSL connection settings.</param>
 public VaserServer(IPAddress LocalAddress, int Port, PortalCollection PColl, VaserSSLServer SSL)
 {
     if (SSL == null)
     {
         throw new Exception("Missing SSL options in VaserServer(...)");
     }
     if (PColl == null)
     {
         throw new Exception("PortalCollection is needed!");
     }
     try
     {
         _vSSL        = SSL;
         ServerOption = VaserOptions.ModeSSL;
         PColl.Active = true;
         PCollection  = PColl;
         _TCPListener = new TcpListener(LocalAddress, Port);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }