/// <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); }
/// <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(); }