Beispiel #1
0
        public async Task UpdateLogic(string operation, byte[] data, IPEndPoint source)
        {
            byte[] local_data;
            string full_packet_size = string.Empty;

            window.WriteLine("OP is: " + operation);

            switch (operation)
            {
            case "tell":
                full_packet_size = Convert.ToString(version_size + info.self_size);
                local_data       = server.AddOperation(full_packet_size, size_size, info.signature);
                local_data       = server.AddOperation(info.version, version_size, local_data);
                local_data       = server.AddOperation("update|info", UDPServer.operation_size, local_data);
                await server.Send(source, local_data);

                break;

            case "info":
                await CheckVersion(data, source);

                break;

            case "give":
                //window.WriteLine("LocalIP: " + info.ip);
                //IPEndPoint local = new IPEndPoint(IPAddress.Parse(info.ip), info.port);
                IPAddress local_ip = IPAddress.Parse(Encoding.UTF8.GetString(data));

                window.WriteLine("TCP running: " + local_ip + ":" + server.Port);

                IPEndPoint local = new IPEndPoint(0, server.Port);

                local_data = await directory.GetFromFileAsync(info.self_location);

                local_data = AddOperation(info.version, version_size, local_data);
                StartUpdateServer(local, source, local_data);
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public async Task Logic(string[] operations, byte[] data, IPEndPoint source)
        {
            string name;
            string path;

            byte[] some_data = new byte[0];

            switch (operations[1])
            {
            case "new":

                name = Encoding.UTF8.GetString(data);
                window.WriteLine("Got info about new block: " + name);

                path = filesystem.FSConfig.db_blocks_path + @"\" + name;
                if (!File.Exists(name))
                {
                    some_data = Encoding.UTF8.GetBytes(name);
                    some_data = server.AddOperation("block", GetLogic.operation_size, some_data);
                    some_data = server.AddOperation(getlogic.request_template, UDPServer.operation_size, some_data);

                    await server.Send(source, some_data);
                }

                break;

            default:
                break;
            }
        }
Beispiel #3
0
        public async Task Actualize()
        {
            IPAddress senpai = IPAddress.Parse("78.139.208.149");
            int       port   = 6879;

            IPEndPoint sen = new IPEndPoint(senpai, port);

            byte[] message;

            if (!window.admin)
            {
                message = Encoding.UTF8.GetBytes("signature");
                message = server.AddOperation(getlogic.request_template, UDPServer.operation_size, message);

                await server.Send(sen, message);
            }


            await blocks.BlockChainActualize();

            window.WriteLine("Actualization started");
            await info.ActualizeSelfSignature();
        }