Ejemplo n.º 1
0
        private static void HandleNewClient(TcpClient Client)
        {
            SnooperSocketClient SocketClient = new SnooperSocketClient(Client);

            SocketClient.SetSecurityProtocal(new MutualKeyProtocal()
            {
                IsServer = true, Key = Password
            });
            SocketClient.Start();
            Thread.Sleep(400);
            if (SocketClient.Security.TryValidateConnection())
            {
                Console.WriteLine("[Server] Client Authed!");
                SocketClient.Channels["Message"].Write(new StatusMessage()
                {
                    Message = "Hello!", Status = true
                });
                SocketClient.Disconnect();
                Client.Dispose();
            }
            else
            {
                Console.WriteLine("[Server] Client Denied.");
                SocketClient.Disconnect();
                Client.Dispose();
            }
        }
Ejemplo n.º 2
0
        private static void Client()
        {
            Console.WriteLine("[Client] Connecting to server...");
            TcpClient Client = new TcpClient();

            Console.WriteLine($"[Client] Network Buffer Size: {Client.ReceiveBufferSize}");
            Client.Connect(IPAddress.Parse("127.0.0.1"), 2081);
            Console.WriteLine("[Client] Connected.");
            LocalClient = new SnooperSocketClient()
            {
                Client = Client
            };
            LocalClient.OnDisconnect += LocalClient_OnDisconnect;
            LocalClient.SetSecurityProtocal(new MutualKeyProtocal()
            {
                Key = k, IsServer = false
            });
            LocalClient.Start();
            Console.WriteLine($"[Client] Requesting Auth...");
            Console.WriteLine($"[Client] Authed: {((MutualKeyProtocal)LocalClient.Security).ValidateConnection()}");

            Console.WriteLine("[Client] Sending on open stream");
            LocalClient.Write(new MSGDat()
            {
                Content = "HEYO DERE BOIO!"
            }, null, "$SnooperSec.MutualKeyProtocal.Validate");

            //while(true)
            //{
            //    Console.ReadLine();
            //    LocalClient.Write(new MSGDat() { Content = "HEY!" }, null, "Request");
            //}
            Console.WriteLine("DC...");
            LocalClient.Disconnect();
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            while (true)
            {
                Console.Write("Password: "******"Message"].MessageReceived += Client_MessageReceived;
                SocketClient.Start();
                //if (SocketClient.Security.TryValidateConnection())
                //{
                //    Console.WriteLine($"[Client] Authorised");

                //    Console.WriteLine("Press any to continue...");
                //    Console.ReadKey();

                //} else
                //{
                //    Console.WriteLine($"[Client] Auth Denied.");
                //}


                Console.WriteLine("Press any to continue...");
                Console.ReadKey();

                Console.WriteLine("[Client] Disconnecting...");
                SocketClient.Disconnect();

                Client.Dispose();
                Console.WriteLine("\n");
            }
        }