Ejemplo n.º 1
0
        /// <summary>
        /// Listens on the give <paramref name="Port"/> with the given keys.
        /// </summary>
        /// <param name="Port">Local listening port.</param>
        /// <param name="NEKey">Non-encryption key. Used for fast filtering incoming connections.</param>
        /// <param name="EKey">Encryption key.</param>
        public void CreateListener(int Port, string NEKey, byte[] EKey)
        {
            Key      = EKey;
            Endpoint = new NetLibEndpoint(Log);
            Endpoint.RegisterCallback(0, NSReply0);
            ControlChannel = new EncryptWrapper(Endpoint, EKey, IV0);
            ControlChannel.RegisterCallback(1, ControlReply);

            Endpoint.Listen(Port, NEKey);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new channel.
        /// </summary>
        /// <returns>The new channel's number.</returns>
        /// <param name="Endpoint">The new channel.</param>
        public int CreateNewChannel(out INetworkEndpoint Endpoint)
        {
            int ChNum;

            lock (this)
                ChNum = ChannelCounter++;

            Endpoint = CreateChannel(ChNum);
            return(ChNum);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Connects to the remote <paramref name="Host"/> on the given <paramref name="Port"/>, using the given keys.
        /// </summary>
        /// <param name="Host">Remote host.</param>
        /// <param name="Port">Remote port.</param>
        /// <param name="NEKey">Non-encryption key. Used for fast filtering on the remote host.</param>
        /// <param name="EKey">Encryption key.</param>
        public void EstablishConnection(string Host, int Port, string NEKey, byte[] EKey)
        {
            Key      = (byte[])EKey.Clone();
            Endpoint = new NetLibEndpoint(Log);
            Endpoint.Connect(Host, Port, NEKey);
            string Message = SendReceiveText(Endpoint, 0, "WNS-C");

            if (Message != "WNS-S")
            {
                throw new System.Net.ProtocolViolationException("Remote host does not follow Webrella Network Stack");
            }
            ControlChannel = new EncryptWrapper(Endpoint, EKey, IV0);
            ControlChannel.RegisterCallback(1, ControlReply);

            SendHandshake();
        }