Beispiel #1
0
        public void Run()
        {
            connection = new MySqlConnection("Server = " + BlindNetConst.DatabaseIP + "; Port = 3306; Database = document_center; Uid = root; Pwd = kit2020");
            mainSocket = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.OPENNERPORT);
            mainSocket.BindListen();
            while (true)
            {
                BlindSocket client = mainSocket.AcceptWithECDH();
                IPEndPoint  iep    = (IPEndPoint)(client.socket.RemoteEndPoint);
                Console.WriteLine("Accepted {0} : {1}", iep.Address, iep.Port);
                if (client == null)
                {
                    continue;
                }

                byte[] data = BlindNetUtil.ByteTrimEndNull(client.CryptoReceiveMsg());
                byte[] tmp  = new byte[4];
                Array.Copy(data, 0, tmp, 0, data.Length);
                string ext = GetExt(BitConverter.ToUInt32(tmp, 0));
                if (ext == null)
                {
                    client.CryptoSend(null, PacketType.Disconnect);
                    continue;
                }
                client.CryptoSend(Encoding.UTF8.GetBytes(ext), PacketType.Info);

                data = BlindNetUtil.ByteTrimEndNull(client.CryptoReceiveMsg());
                tmp  = new byte[4];
                Array.Copy(data, 0, tmp, 0, data.Length);
                int    encryptDate = BitConverter.ToInt32(tmp, 0);
                byte[] key, iv;
                if (!GetSpecifyKeyPair(out key, out iv, encryptDate))
                {
                    client.CryptoSend(null, PacketType.Disconnect);
                    continue;
                }
                client.CryptoSend(key, PacketType.Info);
                client.CryptoSend(iv, PacketType.Info);

                byte[] latestKey, latestIv;
                if (!GetLatestKeyPair(out latestKey, out latestIv))
                {
                    client.CryptoSend(null, PacketType.Disconnect);
                    continue;
                }
                client.CryptoSend(latestKey, PacketType.Info);
                client.CryptoSend(latestIv, PacketType.Info);

                client.Close();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var handl = GetConsoleWindow();

            BlindOpenner openner = new BlindOpenner();

            Task.Run(() => openner.Run());

            connection = DataBaseConnection();

            //ShowWindow(handl, SW_HIDE); //Console 창 숨기기
            socket_docCenter = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.DocCenterPort);
            socket_docCenter.BindListen();

            chatRecvSock = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.CHATPORT);
            chatRecvSock.BindListen();

            chatSendSock = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.CHATPORT + 1);
            chatSendSock.BindListen();

            lockPortSock = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.LOCKPORT);
            lockPortSock.BindListen();

            mainSocket = new BlindServerScoket();
            mainSocket.BindListen();

            WebDeviceSocket = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.WebDevicePort);
            WebDeviceSocket.BindListen();



            while (true)
            {
                BlindSocket client = mainSocket.AcceptWithECDH();
                AddConnectedUser(client);
            }
        }
Beispiel #3
0
 static _Main()
 {
     MainWebSocket = new BlindServerScoket(BlindNetConst.ServerIP, BlindNetConst.WebInterlockPort);
 }