Example #1
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp          = (IPAddress)ArgumentValues["Server IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];
            int       ClCustomerPort    = (int)ArgumentValues["clCustomer Port"];

            log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", ServerIp, ClNonCustomerPort, ClCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool establishHostingOk = await client.EstablishHostingAsync();

                // Step 1 Acceptance
                bool step1Ok = establishHostingOk;
                client.CloseConnection();


                // Step 2
                await client.ConnectAsync(ServerIp, ClCustomerPort, true);

                bool startConversationOk = await client.StartConversationAsync();

                Message requestMessage = mb.CreateUpdateProfileRequest(SemVer.V100, "Test Identity", null, new GpsLocation(0, 0), null);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized;

                bool updateProfileOk = idOk && statusOk;

                // Step 2 Acceptance
                bool step2Ok = startConversationOk && updateProfileOk;


                Passed = step1Ok && step2Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #2
0
        // [FInished] : Connection Complete
        public async Task ConnectAsync()
        {
            try
            {
                // Step 01 : Make connection to socket on Server-Side TCP Listener if URI Schema is valid
                await ProtocolClient.ValidateClientRequestAsync(RtmpRequest);

                // Step 02 : Connect to Host Socket
                await ProtocolClient.ConnectAsync(RtmpRequest.Content.RtmpUri.Host, RtmpRequest.Content.RtmpUri.Port != -1?RtmpRequest.Content.RtmpUri.Port : DefaultPort);

                // Step 03 : Validate Socket Connection
                await ProtocolClient.ValidateClientConnectionAsync(RtmpRequest.ProtocolConfigurations);

                // Step 04 : Set the Resolved Stream
                RtmpStream = await ProtocolClient.ResolveStreamTypeAsync(RtmpRequest);

                // Step 05 : Validate Stream Properties Match with request
                await RtmpStream.ValidateStreamPropertiesAsync(RtmpRequest.StreamConfigurations);

                // Step 06 : Initialize the Handshake Sequence
                await RtmpStream.InitializeHandshakeSequenceAsync(StopToken);
            }
            catch (Exception exception)
            {
                throw new Exception("RMTP Connection was Unsuccessful.", exception);
            }
        }
Example #3
0
        void StartDebugAgent()
        {
            var startInfo = new ProcessStartInfo(Path.Combine(Path.GetDirectoryName(typeof(VSCodeDebuggerSession).Assembly.Location), "CoreClrAdaptor", "OpenDebugAD7"));

            startInfo.RedirectStandardOutput       = true;
            startInfo.RedirectStandardInput        = true;
            startInfo.StandardOutputEncoding       = Encoding.UTF8;
            startInfo.StandardOutputEncoding       = Encoding.UTF8;
            startInfo.UseShellExecute              = false;
            startInfo.EnvironmentVariables["PATH"] = "/usr/local/share/dotnet:" + Environment.GetEnvironmentVariable("PATH");
            debugAgentProcess       = Process.Start(startInfo);
            protocolClient          = new ProtocolClient();
            protocolClient.OnEvent += HandleAction;
            protocolClient.Start(debugAgentProcess.StandardOutput.BaseStream, debugAgentProcess.StandardInput.BaseStream)
            .ContinueWith((task) => {
                if (task.IsFaulted)
                {
                    Console.WriteLine(task.Exception);
                }
            });
            var initRequest = new InitializeRequest(new InitializeRequestArguments()
            {
                adapterID       = "coreclr",
                linesStartAt1   = true,
                columnsStartAt1 = true,
                pathFormat      = "path"
            });

            Capabilities = protocolClient.SendRequestAsync(initRequest).Result;
        }
Example #4
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                bool establishHomeNodeOk = await client.EstablishHomeNodeAsync();

                // Step 1 Acceptance
                bool step1Ok = establishHomeNodeOk;
                client.CloseConnection();


                // Step 2
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                bool verifyIdentityOk = await client.VerifyIdentityAsync();

                Message requestMessage = mb.CreateUpdateProfileRequest(new byte[] { 1, 0, 0 }, "Test Identity", null, 0x12345678, null);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized;

                bool updateProfileOk = idOk && statusOk;

                // Step 2 Acceptance
                bool step2Ok = verifyIdentityOk && updateProfileOk;


                Passed = step1Ok && step2Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #5
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp        = (IPAddress)ArgumentValues["Server IP"];
            int       NonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(ServerIp:'{0}',NonCustomerPort:{1})", ServerIp, NonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, NonCustomerPort, false);

                log.Trace("Entering 180 seconds wait...");
                await Task.Delay(180 * 1000);

                log.Trace("Wait completed.");


                // We should be disconnected by now, so TLS handshake should fail.
                bool      disconnectedOk = false;
                SslStream sslStream      = null;
                try
                {
                    sslStream = new SslStream(client.GetStream(), false, PeerCertificateValidationCallback);
                    await sslStream.AuthenticateAsClientAsync("", null, SslProtocols.Tls12, false);
                }
                catch
                {
                    log.Trace("Expected exception occurred.");
                    disconnectedOk = true;
                }
                if (sslStream != null)
                {
                    sslStream.Dispose();
                }

                // Step 1 Acceptance
                Passed = disconnectedOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #6
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                Message requestMessage  = mb.CreateApplicationServiceReceiveMessageNotificationRequest(new byte[] { 0 });
                Message responseMessage = mb.CreateApplicationServiceReceiveMessageNotificationResponse(requestMessage);
                await client.SendMessageAsync(responseMessage);

                // We should be disconnected by now, so sending or receiving should throw.
                byte[] data    = Encoding.UTF8.GetBytes("Hello");
                byte[] payload = Crypto.Sha256(data);
                requestMessage = mb.CreatePingRequest(payload);

                bool disconnectedOk = false;
                try
                {
                    await client.SendMessageAsync(requestMessage);

                    await client.ReceiveMessageAsync();
                }
                catch
                {
                    log.Trace("Expected exception occurred.");
                    // Step 1 Acceptance
                    disconnectedOk = true;
                }

                Passed = disconnectedOk;


                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #7
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp      = (IPAddress)ArgumentValues["Node IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(NodeIp:'{0}',PrimaryPort:{1})", NodeIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, PrimaryPort, false);

                log.Trace("Entering 500 seconds wait...");
                await Task.Delay(500 * 1000);

                log.Trace("Wait completed.");

                byte[]  payload        = Encoding.UTF8.GetBytes("test");
                Message requestMessage = mb.CreatePingRequest(payload);

                // We should be disconnected by now, so sending or receiving should throw.
                bool disconnectedOk = false;
                try
                {
                    await client.SendMessageAsync(requestMessage);

                    await client.ReceiveMessageAsync();
                }
                catch
                {
                    log.Trace("Expected exception occurred.");
                    disconnectedOk = true;
                }

                // Step 1 Acceptance
                Passed = disconnectedOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #8
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                Message requestMessage = client.CreateStartConversationRequest();
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk                = responseMessage.Id == requestMessage.Id;
                bool statusOk            = responseMessage.Response.Status == Status.Ok;
                bool verifyChallengeOk   = client.VerifyServerChallengeSignature(responseMessage);
                bool startConversationOk = idOk && statusOk && verifyChallengeOk;

                byte[] challenge = responseMessage.Response.ConversationResponse.Start.Challenge.ToByteArray();

                requestMessage = mb.CreateVerifyIdentityRequest(challenge);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.ErrorBadRole;
                bool verifyIdentityOk = idOk && statusOk;

                // Step 1 Acceptance

                Passed = startConversationOk && verifyIdentityOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #9
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp     = (IPAddress)ArgumentValues["Server IP"];
            int       CustomerPort = (int)ArgumentValues["clCustomer Port"];

            log.Trace("(ServerIp:'{0}',CustomerPort:{1})", ServerIp, CustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, CustomerPort, true);

                Message requestMessage = mb.CreateCanStoreDataRequest(null);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk           = responseMessage.Id == requestMessage.Id;
                bool statusOk       = responseMessage.Response.Status == Status.ErrorUnauthorized;
                bool canStoreDataOk = idOk && statusOk;


                requestMessage = mb.CreateCanPublishIpnsRecordRequest(null);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized;
                bool canPublishIpnsRecordOk = idOk && statusOk;

                // Step 1 Acceptance

                Passed = canStoreDataOk && canPublishIpnsRecordOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();


            log.Trace("(-):{0}", res);
            return(res);
        }
Example #10
0
 private void readInbox(ProtocolClient client)
 {
     // Base clases have been sealed, so can't extend a generic 'readInbox' function
     if (client.GetType() == typeof(Pop3Client))
     {
         readInbox((Pop3Client)client);
     }
     else if (client.GetType() == typeof(ImapClient))
     {
         readInbox((ImapClient)client);
     }
 }
Example #11
0
        /// <summary>
        /// Sends data messages to the other client.
        /// </summary>
        /// <param name="Client">Client connected to clAppService port with an initialized relay.</param>
        /// <param name="Builder">Client's message builder.</param>
        /// <param name="Name">Log prefix.</param>
        /// <param name="Token">Client's open relay token.</param>
        /// <param name="WriteLock">Lock object to protect write access to client's stream.</param>
        /// <param name="UnfinishedRequestCounter">Unfinished request counter object.</param>
        /// <returns></returns>
        public static async Task <byte[]> MessageSendingLoop(ProtocolClient Client, MessageBuilder Builder, string Name, byte[] Token, SemaphoreSlim WriteLock, UnfinishedRequestCounter UnfinishedRequestCounter)
        {
            string prefix = string.Format("[{0}] ", Name);

            log.Trace(prefix + "()");

            List <byte[]> chunks    = new List <byte[]>();
            int           totalSize = 0;

            for (int i = 0; i < DataMessageCountPerClient; i++)
            {
                // Generate message data.
                int    dataLength = rng.Next(DataMessageSizeMin, DataMessageSizeMax);
                byte[] msg        = new byte[dataLength];
                Crypto.Rng.GetBytes(msg);
                totalSize += dataLength;
                chunks.Add(msg);


                // Send message.
                await UnfinishedRequestCounter.WaitAndIncrement();

                await WriteLock.WaitAsync();

                Message appServiceMessageRequest = Builder.CreateApplicationServiceSendMessageRequest(Token, msg);
                await Client.SendMessageAsync(appServiceMessageRequest);

                WriteLock.Release();

                int delay = rng.Next(DataMessageDelayMaxMs);
                if (delay != 0)
                {
                    await Task.Delay(delay);
                }
            }


            // Count final hash.
            int offset = 0;

            byte[] data = new byte[totalSize];
            foreach (byte[] chunk in chunks)
            {
                Array.Copy(chunk, 0, data, offset, chunk.Length);
                offset += chunk.Length;
            }

            byte[] finalHash = Crypto.Sha256(data);

            log.Trace(prefix + "(-):{0}", Crypto.ToHex(finalHash));
            return(finalHash);
        }
Example #12
0
        private bool connect(ProtocolClient client)
        {
            if (client.GetType() == typeof(Pop3Client))
            {
                return(connect((Pop3Client)client));
            }
            else if (client.GetType() == typeof(ImapClient))
            {
                return(connect((ImapClient)client));
            }

            return(false);
        }
Example #13
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                bool startConversationOk = await client.StartConversationAsync();

                // Invalidate challenge.
                byte[] challenge = new byte[client.Challenge.Length];
                Array.Copy(client.Challenge, challenge, challenge.Length);
                challenge[0] ^= 0x12;

                Message requestMessage = mb.CreateVerifyIdentityRequest(challenge);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk             = responseMessage.Id == requestMessage.Id;
                bool statusOk         = responseMessage.Response.Status == Status.ErrorInvalidValue;
                bool detailsOk        = responseMessage.Response.Details == "challenge";
                bool verifyIdentityOk = idOk && statusOk && detailsOk;

                // Step 1 Acceptance
                Passed = startConversationOk && verifyIdentityOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #14
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                Message    requestMessage = client.CreateStartConversationRequest();
                ByteString myKey          = requestMessage.Request.ConversationRequest.Start.PublicKey;
                byte[]     badChallenge   = new byte[4];
                Crypto.Rng.GetBytes(badChallenge);
                requestMessage.Request.ConversationRequest.Start                 = new StartConversationRequest();
                requestMessage.Request.ConversationRequest.Start.PublicKey       = myKey;
                requestMessage.Request.ConversationRequest.Start.ClientChallenge = ProtocolHelper.ByteArrayToByteString(badChallenge);
                requestMessage.Request.ConversationRequest.Start.SupportedVersions.Add(ProtocolHelper.ByteArrayToByteString(new byte[] { 1, 0, 0 }));

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                // Step 1 Acceptance
                bool idOk      = responseMessage.Id == requestMessage.Id;
                bool statusOk  = responseMessage.Response.Status == Status.ErrorInvalidValue;
                bool detailsOk = responseMessage.Response.Details == "clientChallenge";

                Passed = idOk && statusOk && detailsOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #15
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp          = (IPAddress)ArgumentValues["Server IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool startConversationOk = await client.StartConversationAsync();

                Message requestMessage = mb.CreateVerifyIdentityRequest(client.Challenge);

                // Invalidate signature.
                byte[] signature = requestMessage.Request.ConversationRequest.Signature.ToByteArray();
                signature[0] ^= 0x12;
                requestMessage.Request.ConversationRequest.Signature = ProtocolHelper.ByteArrayToByteString(signature);

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk             = responseMessage.Id == requestMessage.Id;
                bool statusOk         = responseMessage.Response.Status == Status.ErrorInvalidSignature;
                bool verifyIdentityOk = idOk && statusOk;

                // Step 1 Acceptance
                Passed = startConversationOk && verifyIdentityOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #16
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                byte[]  payload        = Encoding.UTF8.GetBytes("Hello");
                Message requestMessage = mb.CreatePingRequest(payload);
                requestMessage.Id = 1234;

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                // Step 1 Acceptance
                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.Ok;

                byte[] payloadReceived = responseMessage.Response.SingleResponse.Ping.Payload.ToByteArray();
                bool   payloadOk       = StructuralComparisons.StructuralComparer.Compare(payload, payloadReceived) == 0;

                DateTime clock   = ProtocolHelper.UnixTimestampMsToDateTime(responseMessage.Response.SingleResponse.Ping.Clock);
                bool     clockOk = Math.Abs((DateTime.UtcNow - clock).TotalMinutes) <= 10;

                Passed = idOk && statusOk && payloadOk && clockOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #17
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp          = (IPAddress)ArgumentValues["Server IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                Message    requestMessage = client.CreateStartConversationRequest();
                ByteString myKey          = requestMessage.Request.ConversationRequest.Start.PublicKey;
                ByteString myChallenge    = requestMessage.Request.ConversationRequest.Start.ClientChallenge;
                requestMessage.Request.ConversationRequest.Start                 = new StartConversationRequest();
                requestMessage.Request.ConversationRequest.Start.PublicKey       = myKey;
                requestMessage.Request.ConversationRequest.Start.ClientChallenge = myChallenge;
                requestMessage.Request.ConversationRequest.Start.SupportedVersions.Add(new SemVer(255, 255, 255).ToByteString());
                requestMessage.Request.ConversationRequest.Start.SupportedVersions.Add(new SemVer(255, 255, 254).ToByteString());

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                // Step 1 Acceptance
                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorUnsupported;

                Passed = idOk && statusOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #18
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp          = (IPAddress)ArgumentValues["Server IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                log.Trace("Step 1");

                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                Message requestMessage = mb.CreateProfileStatsRequest();
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.Ok;
                bool countOk  = responseMessage.Response.SingleResponse.ProfileStats.Stats.Count == 0;

                // Step 1 Acceptance
                bool step1Ok = idOk && statusOk && countOk;

                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");

                Passed = step1Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #19
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                Message requestMessage = client.CreateStartConversationRequest();
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                // Step 1 Acceptance
                bool idOk              = responseMessage.Id == requestMessage.Id;
                bool statusOk          = responseMessage.Response.Status == Status.Ok;
                bool verifyChallengeOk = client.VerifyNodeChallengeSignature(responseMessage);

                byte[] receivedVersion = responseMessage.Response.ConversationResponse.Start.Version.ToByteArray();
                byte[] expectedVersion = new byte[] { 1, 0, 0 };
                bool   versionOk       = StructuralComparisons.StructuralComparer.Compare(receivedVersion, expectedVersion) == 0;

                bool pubKeyLenOk = responseMessage.Response.ConversationResponse.Start.PublicKey.Length == 32;
                bool challengeOk = responseMessage.Response.ConversationResponse.Start.Challenge.Length == 32;

                Passed = idOk && statusOk && verifyChallengeOk && versionOk && pubKeyLenOk && challengeOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #20
0
        // [FInished] : Connection Complete
        public async Task ConnectAsync(RtmpConnectionRequest Request)
        {
            RtmpRequest                        = Request;
            ProtocolClient.NoDelay             = Request.ProtocolConfigurations.NoDelay;
            ProtocolClient.ExclusiveAddressUse = Request.ProtocolConfigurations.ExclusiveAddressUse;

            if (Request.ProtocolConfigurations.ReceiveTimeout != -1)
            {
                ProtocolClient.ReceiveTimeout = Request.ProtocolConfigurations.ReceiveTimeout;
            }

            if (Request.ProtocolConfigurations.SendTimeout != -1)
            {
                ProtocolClient.SendTimeout = Request.ProtocolConfigurations.SendTimeout;
            }

            if (Request.ProtocolConfigurations.RecieveBufferSize != -1)
            {
                ProtocolClient.ReceiveBufferSize = Request.ProtocolConfigurations.RecieveBufferSize;
            }

            if (Request.ProtocolConfigurations.SendBufferSize != -1)
            {
                try
                {
                    // Step 01: Make connection to socket on Server-Side TCP Listener if URI Schema is valid
                    await ProtocolClient.ValidateClientRequestAsync(RtmpRequest);

                    // Step 02: Connect to Host Socket
                    await ProtocolClient.ConnectAsync(RtmpRequest.Content.RtmpUri.Host, RtmpRequest.Content.RtmpUri.Port != -1?RtmpRequest.Content.RtmpUri.Port : DefaultPort);

                    // Step 03: Validate Socket Connection
                    await ProtocolClient.ValidateClientConnectionAsync(RtmpRequest.ProtocolConfigurations);

                    // Step 04: Set the Resolved Stream
                    RtmpStream = await ProtocolClient.ResolveStreamTypeAsync(RtmpRequest);

                    // Step 05: Validate Stream Properties Match with request
                    await RtmpStream.ValidateStreamPropertiesAsync(RtmpRequest.StreamConfigurations);

                    // Step 06: Initialize the Handshake Sequence
                    await RtmpStream.InitializeHandshakeSequenceAsync(StopToken);
                }
                catch (Exception exception)
                {
                    throw new Exception("Connection was unsuccessful.", exception);
                }
            }
        }
Example #21
0
 //visszatér a requester-en kívüli eszközök targetjei által blokkolt node-okkal
 public HashSet<Node> getOtherTargetRepels(ProtocolClient requester)
 {
     HashSet<Node> ret = new HashSet<Node>();
     foreach (ProtocolClient client in clients)
     {
         if (client != requester && client.target!=null)
         {
             foreach (Node n in grid.nodesInRadius(client.target.worldPosition, targetRepelRadius))
             {
                 ret.Add(n);
             }
         }
     }
     return ret;
 }
Example #22
0
 //visszatér azokkal a node-okkal amiket a requester-en kívül a többi eszköz lefed
 public HashSet<Node> getDynamicUnwalkable(ProtocolClient requester, float rangeMultiplier)
 {
     HashSet<Node> ret = new HashSet<Node>();
     foreach(ProtocolClient client in clients)
     {
         if (client != requester)
         {
             foreach(Node n in grid.nodesInRadius(client.transform.position, client.bodyRadius*rangeMultiplier))
             {
                 ret.Add(n);
             }
         }
     }
     return ret;
 }
Example #23
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                VerifyIdentityRequest verifyIdentityRequest = new VerifyIdentityRequest();

                Message requestMessage = mb.CreateConversationRequest();
                requestMessage.Request.ConversationRequest.VerifyIdentity = verifyIdentityRequest;

                mb.SignConversationRequestBody(requestMessage, verifyIdentityRequest);

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorBadConversationStatus;

                // Step 1 Acceptance
                Passed = idOk && statusOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #24
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                bool verifyIdentityOk = await client.VerifyIdentityAsync();

                byte[]  data           = Encoding.UTF8.GetBytes("test");
                byte[]  fakeId         = Crypto.Sha1(data);
                Message requestMessage = mb.CreateCallIdentityApplicationServiceRequest(fakeId, "Test Service");

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk      = responseMessage.Id == requestMessage.Id;
                bool statusOk  = responseMessage.Response.Status == Status.ErrorInvalidValue;
                bool detailsOk = responseMessage.Response.Details == "identityNetworkId";

                // Step 1 Acceptance
                Passed = verifyIdentityOk && idOk && statusOk && detailsOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #25
0
    //visszatér azokkal a node-okkal amiket a requester-en kívül a többi eszköz lefed
    public HashSet <Node> getDynamicUnwalkable(ProtocolClient requester, float rangeMultiplier)
    {
        HashSet <Node> ret = new HashSet <Node>();

        foreach (ProtocolClient client in clients)
        {
            if (client != requester)
            {
                foreach (Node n in grid.nodesInRadius(client.transform.position, client.bodyRadius * rangeMultiplier))
                {
                    ret.Add(n);
                }
            }
        }
        return(ret);
    }
Example #26
0
    //visszatér a requester-en kívüli eszközök targetjei által blokkolt node-okkal
    public HashSet <Node> getOtherTargetRepels(ProtocolClient requester)
    {
        HashSet <Node> ret = new HashSet <Node>();

        foreach (ProtocolClient client in clients)
        {
            if (client != requester && client.target != null)
            {
                foreach (Node n in grid.nodesInRadius(client.target.worldPosition, targetRepelRadius))
                {
                    ret.Add(n);
                }
            }
        }
        return(ret);
    }
Example #27
0
    public void uploadSensorData(List <Node> walkable, List <Node> unwalkable, ProtocolClient client)
    {
        HashSet <Node> dynamicBlocked = getDynamicUnwalkable(client, 1.6f);

        //járhatatlanok és környezetük blokkolása
        foreach (Node n in unwalkable)
        {
            n.seen = true;
            //ha nem egy másik eszköztlát
            if (!dynamicBlocked.Contains(n))
            {
                n.walkable = false;
                n.danger   = 1;
                realBorder.Add(n);
                foreach (Node node in grid.nodesInRadius(n.worldPosition, client.bodyRadius))
                {
                    node.danger = 1;
                    node.seen   = true;
                }
            }
        }
        //járhatóak megjelölése
        foreach (Node n in walkable)
        {
            n.seen = true;
            realBorder.Remove(n);
            if (isVirtualBorder(n))
            {
                virtualBorder.Add(n);
            }
        }

        //az eszköz által lefedett területet látottnak feltételezzük
        if (selfAwareness)
        {
            foreach (Node n in grid.nodesInRadius(client.transform.position, client.bodyRadius))
            {
                n.seen = true;
                realBorder.Remove(n);
                if (isVirtualBorder(n))
                {
                    virtualBorder.Add(n);
                }
            }
        }
    }
Example #28
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                byte[]  data           = Encoding.UTF8.GetBytes("test");
                byte[]  token          = Crypto.Sha256(data);
                byte[]  messageData    = Encoding.UTF8.GetBytes("Test message");
                Message requestMessage = mb.CreateApplicationServiceSendMessageRequest(token, messageData);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorBadRole;

                // Step 1 Acceptance

                Passed = idOk && statusOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #29
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp          = (IPAddress)ArgumentValues["Server IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];
            int       ClCustomerPort    = ClNonCustomerPort;

            log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool establishHostingOk = await client.EstablishHostingAsync();

                Message requestMessage = mb.CreateCheckInRequest(client.Challenge);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk      = responseMessage.Id == requestMessage.Id;
                bool statusOk  = responseMessage.Response.Status == Status.Ok;
                bool checkInOk = idOk && statusOk;

                // Step 1 Acceptance
                Passed = establishHostingOk && checkInOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #30
0
    public void uploadSensorData(List<Node> walkable,List<Node> unwalkable,ProtocolClient client)
    {
        HashSet<Node> dynamicBlocked = getDynamicUnwalkable(client,1.6f);

        //járhatatlanok és környezetük blokkolása
        foreach (Node n in unwalkable)
        {
            n.seen = true;
            //ha nem egy másik eszköztlát
            if (!dynamicBlocked.Contains(n))
            {
                n.walkable = false;
                n.danger = 1;
                realBorder.Add(n);
                foreach (Node node in grid.nodesInRadius(n.worldPosition, client.bodyRadius))
                {
                    node.danger = 1;
                    node.seen = true;
                }
            }
        }
        //járhatóak megjelölése
        foreach (Node n in walkable)
        {
            n.seen = true;
            realBorder.Remove(n);
            if (isVirtualBorder(n)){
                virtualBorder.Add(n);
            }

        }

        //az eszköz által lefedett területet látottnak feltételezzük
        if (selfAwareness){
            foreach (Node n in grid.nodesInRadius(client.transform.position, client.bodyRadius))
            {
                n.seen = true;
                realBorder.Remove(n);
                if (isVirtualBorder(n))
                {
                    virtualBorder.Add(n);
                }
            }
        }
    }
Example #31
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress NodeIp            = (IPAddress)ArgumentValues["Node IP"];
            int       ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"];

            log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(NodeIp, ClNonCustomerPort, true);

                bool homeNodeRequestOk = await client.EstablishHomeNodeAsync();

                Message requestMessage = mb.CreateGetIdentityInformationRequest(client.GetIdentityId());
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk              = responseMessage.Id == requestMessage.Id;
                bool statusOk          = responseMessage.Response.Status == Status.ErrorUninitialized;
                bool getIdentityInfoOk = idOk && statusOk;

                // Step 1 Acceptance
                Passed = homeNodeRequestOk && getIdentityInfoOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #32
0
    public void requestNewTarget(ProtocolClient client, Action<Node, bool> callback)
    {
        available = new List<Node>();
        //virtualborder frissítése
        clearVirtualBorder();

        //a dinamikusan tiltott elemek kiszedése a virtualborder-ből
        HashSet<Node> dynamicBlocked = getDynamicUnwalkable(client,2);
        HashSet<Node> targetRepels = getOtherTargetRepels(client);
        foreach (Node n in virtualBorder)
        {
            if (!(dynamicBlocked.Contains(n) || targetRepels.Contains(n))) {
                available.Add(n);
            }
        }

        NewTargetManager.RequestTarget(client.transform.position, available, dynamicBlocked, callback);
    }
Example #33
0
        /// <summary>
        /// Retrieves a list of clients that should be found within specific area.
        /// </summary>
        /// <param name="Location">GPS location of the centre of the target area.</param>
        /// <param name="Radius">Radius of the target area in metres.</param>
        /// <returns>List of matchin profile names.</returns>
        public static Dictionary <string, ProtocolClient> GetClientsInLocation(GpsLocation Location, uint Radius)
        {
            Dictionary <string, ProtocolClient> res = new Dictionary <string, ProtocolClient>(StringComparer.Ordinal);

            for (int i = 0; i < ProfileNames.Count; i++)
            {
                string         name            = ProfileNames[i];
                ProtocolClient client          = TestProfiles[name];
                GpsLocation    profileLocation = ProfileLocations[i];

                double distance = GpsLocation.DistanceBetween(Location, profileLocation);
                if (distance < (double)Radius)
                {
                    res.Add(name, client);
                }
            }

            return(res);
        }
Example #34
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort);

            bool res = false;

            Passed = false;

            ProtocolClient client = new ProtocolClient();

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                Message requestMessage = mb.CreateProfileSearchPartRequest(0, 10);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorBadRole;

                // Step 1 Acceptance

                Passed = idOk && statusOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Example #35
0
 public void requestNewPath(ProtocolClient client, Node pathEnd, Action<List<Node>, bool> callback)
 {
     NodePathRequestManager.RequestPath(client.transform.position, pathEnd.worldPosition,getDynamicUnwalkable(client,2), callback);
 }