Exemple #1
0
 /// <summary>
 /// Start this RDPEUDP Server
 /// </summary>
 public void Start()
 {
     udpTransport.Start();
     running       = true;
     receiveThread = new Thread(ReceiveLoop);
     receiveThread.Start();
 }
        /// <summary>
        /// Set up the TCP/UDP transport connection with KDC.
        /// </summary>
        /// <param name="localPort">The server port</param>
        /// <param name="transportType">Whether the transport is TCP or UDP transport.</param>
        /// <param name="ipType">Ip Version</param>
        /// <param name="transportSize">The buffer size of transport stack. </param>
        /// <exception cref="System.ArgumentException">Thrown when the transportType is neither TCP nor UDP.</exception>
        public void Start(ushort localPort, KileConnectionType transportType, KileIpType ipType, int transportSize)
        {
            SocketTransportConfig transportConfig = new SocketTransportConfig();

            transportConfig.Role           = Role.Server;
            transportConfig.MaxConnections = ConstValue.MAX_CONNECTIONS;
            transportConfig.BufferSize     = transportSize;

            if (ipType == KileIpType.Ipv4)
            {
                transportConfig.LocalIpAddress = IPAddress.Any;
            }
            else
            {
                transportConfig.LocalIpAddress = IPAddress.IPv6Any;
            }
            transportConfig.LocalIpPort = localPort;

            if (transportType == KileConnectionType.TCP)
            {
                transportConfig.Type = StackTransportType.Tcp;
            }
            else if (transportType == KileConnectionType.UDP)
            {
                transportConfig.Type = StackTransportType.Udp;
            }
            else
            {
                throw new ArgumentException("ConnectionType can only be TCP or UDP.");
            }
            decoder   = new KileDecoder(contextList, transportType);
            transport = new TransportStack(transportConfig, decoder.DecodePacketCallback);
            transport.Start();
        }
        /// <summary>
        /// Start RDPEUDP Client
        /// </summary>
        public void Start()
        {
            if (started)
            {
                return;
            }

            udpTransport.Start();

            receiveThread = new Thread(ReceiveLoop);

            receiveThreadCancellationTokenSource = new CancellationTokenSource();

            receiveThread.Start();

            started = true;
        }
        /// <summary>
        /// Set up the TCP/UDP transport connection with KDC.
        /// </summary>
        /// <param name="kdcAddress">The IP address of the KDC.</param>
        /// <param name="kdcPort">The port of the KDC.</param>
        /// <param name="transportType">Whether the transport is TCP or UDP transport.</param>
        /// <exception cref="System.ArgumentException">Thrown when the connection type is neither TCP nor UDP</exception>
        public void Connect(string kdcAddress, int kdcPort, KileConnectionType transportType)
        {
            SocketTransportConfig transportConfig = new SocketTransportConfig();

            transportConfig.Role            = Role.Client;
            transportConfig.MaxConnections  = 1;
            transportConfig.BufferSize      = transportBufferSize;
            transportConfig.RemoteIpPort    = kdcPort;
            transportConfig.RemoteIpAddress = IPAddress.Parse(kdcAddress);

            // For UDP bind
            if (transportConfig.RemoteIpAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                transportConfig.LocalIpAddress = IPAddress.Any;
            }
            else if (transportConfig.RemoteIpAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
            {
                transportConfig.LocalIpAddress = IPAddress.IPv6Any;
            }

            if (transportType == KileConnectionType.TCP)
            {
                transportConfig.Type = StackTransportType.Tcp;
            }
            else if (transportType == KileConnectionType.UDP)
            {
                transportConfig.Type = StackTransportType.Udp;
            }
            else
            {
                throw new ArgumentException("ConnectionType can only be TCP or UDP.");
            }

            kdcTransport = new TransportStack(transportConfig, decoder.DecodePacketCallback);
            if (transportType == KileConnectionType.TCP)
            {
                kdcTransport.Connect();
            }
            else
            {
                kdcTransport.Start();
            }

            context.TransportType = transportType;
        }
        /// <summary>
        /// Set up the TCP/UDP transport connection with KDC.
        /// </summary>
        /// <exception cref="System.ArgumentException">Thrown when the connection type is neither TCP nor UDP</exception>
        public virtual void Connect()
        {
            SocketTransportConfig transportConfig = new SocketTransportConfig();

            transportConfig.Role            = Role.Client;
            transportConfig.MaxConnections  = 1;
            transportConfig.BufferSize      = KerberosConstValue.TRANSPORT_BUFFER_SIZE;
            transportConfig.RemoteIpPort    = kdcPort;
            transportConfig.RemoteIpAddress = IPAddress.Parse(kdcAddress);

            // For UDP bind
            if (transportConfig.RemoteIpAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                transportConfig.LocalIpAddress = IPAddress.Any;
            }
            else if (transportConfig.RemoteIpAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
            {
                transportConfig.LocalIpAddress = IPAddress.IPv6Any;
            }

            if (transportType == TransportType.TCP)
            {
                transportConfig.Type = StackTransportType.Tcp;
            }
            else if (transportType == TransportType.UDP)
            {
                transportConfig.Type = StackTransportType.Udp;
            }
            else
            {
                throw new ArgumentException("ConnectionType can only be TCP or UDP.");
            }

            kdcTransport = new TransportStack(transportConfig, DecodePacketCallback);
            if (transportType == TransportType.TCP)
            {
                kdcTransport.Connect();
            }
            else
            {
                kdcTransport.Start();
            }
        }