Compare commits
8 Commits
4503f4bf3f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a14b9b0e15 | |||
| 5b6fd24af4 | |||
| e5b64f600c | |||
| 4d70b98802 | |||
| 3f88804156 | |||
| 80febe4206 | |||
| 99e99fad13 | |||
| bc23b4b4dc |
6
MIT Master Server/App.config
Normal file
6
MIT Master Server/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
17
MIT Master Server/Handlers/ConfigurationHandler.cs
Normal file
17
MIT Master Server/Handlers/ConfigurationHandler.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Master_Server.Handlers
|
||||||
|
{
|
||||||
|
public class ConfigurationHandler
|
||||||
|
{
|
||||||
|
public void SendToClient(TcpClient client)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
MIT Master Server/MIT Master Server.csproj
Normal file
60
MIT Master Server/MIT Master Server.csproj
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{0A8A25AE-69F6-4F10-95E5-20495717FE34}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>MIT_Master_Server</RootNamespace>
|
||||||
|
<AssemblyName>MIT Master Server</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Articulate-Network">
|
||||||
|
<HintPath>..\..\Articulate-Network\bin\Debug\Articulate-Network.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MIT Packets">
|
||||||
|
<HintPath>..\MIT Packets\bin\Debug\MIT Packets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Handlers\ConfigurationHandler.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
97
MIT Master Server/Program.cs
Normal file
97
MIT Master Server/Program.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using Articulate_Network;
|
||||||
|
using Articulate_Network.Events;
|
||||||
|
using Articulate_Network.Managers;
|
||||||
|
using MIT_Packets;
|
||||||
|
using MIT_Packets.Transfer;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Master_Server
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static Server server;
|
||||||
|
static FileInfo file = new FileInfo(@"D:\Bookmark.zip");
|
||||||
|
static int maxConcurrentTransfers = 5;
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
AnnouncePacket.Register();
|
||||||
|
|
||||||
|
server = new Server();
|
||||||
|
|
||||||
|
var watch = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
server.Start("10.136.5.59", 50).ContinueWith(t =>
|
||||||
|
{
|
||||||
|
|
||||||
|
watch.Stop();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine($"Server listening on port 50, took {watch.ElapsedMilliseconds} ms");
|
||||||
|
});
|
||||||
|
|
||||||
|
server.ClientConnected += Server_ClientConnected;
|
||||||
|
server.DataReceived += Server_DataReceived;
|
||||||
|
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async void Server_DataReceived(object sender, Articulate_Network.Events.DataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Packet is AnnouncePacket)
|
||||||
|
{
|
||||||
|
AnnouncePacket p = (AnnouncePacket)e.Packet;
|
||||||
|
Console.WriteLine($"Received client announcement. Requesting config: {p.RequestConfig}");
|
||||||
|
Console.WriteLine(p.MacAddress);
|
||||||
|
|
||||||
|
int packetsSent = 0;
|
||||||
|
|
||||||
|
if (p.RequestConfig)
|
||||||
|
{
|
||||||
|
await server.SendPacket(e.Client, new StartFileTransferPacket()
|
||||||
|
{
|
||||||
|
FileName = file.FullName,
|
||||||
|
ExpectedSize = file.Length
|
||||||
|
});
|
||||||
|
|
||||||
|
byte[] buffer = new byte[10240];
|
||||||
|
|
||||||
|
using (var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = await fs.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
await server.SendPacket(e.Client, new SendFileChunkPacket()
|
||||||
|
{
|
||||||
|
Chunk = buffer,
|
||||||
|
ChunkSize = bytesRead
|
||||||
|
});
|
||||||
|
|
||||||
|
//Console.WriteLine($"Sent: {bytesRead}");
|
||||||
|
|
||||||
|
packetsSent += 1;
|
||||||
|
//Console.WriteLine(packetsSent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Completed file transfer. Sent {packetsSent} packets.");
|
||||||
|
|
||||||
|
await server.SendPacket(e.Client, new EndFileTransferPacket() { Completed = true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async void Server_ClientConnected(object sender, ClientConnectedEventArgs e)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"Client Connected from: {(e.TcpClient.Client.RemoteEndPoint as IPEndPoint).Address}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
MIT Master Server/Properties/AssemblyInfo.cs
Normal file
36
MIT Master Server/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("MIT Master Server")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Queensland Government")]
|
||||||
|
[assembly: AssemblyProduct("MIT Master Server")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Queensland Government 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("0a8a25ae-69f6-4f10-95e5-20495717fe34")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
21
MIT Packets/AnnouncePacket.cs
Normal file
21
MIT Packets/AnnouncePacket.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets
|
||||||
|
{
|
||||||
|
public class AnnouncePacket : Packet
|
||||||
|
{
|
||||||
|
public int Type { get; set; }
|
||||||
|
public bool RequestConfig { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
|
||||||
|
public static void Register()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
MIT Packets/Configuration/ClientConfigPacket.cs
Normal file
14
MIT Packets/Configuration/ClientConfigPacket.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets.Configuration
|
||||||
|
{
|
||||||
|
public class ClientConfigPacket : Packet
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
19
MIT Packets/Enums/ClientStatus.cs
Normal file
19
MIT Packets/Enums/ClientStatus.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets.Enums
|
||||||
|
{
|
||||||
|
public enum ClientStatus
|
||||||
|
{
|
||||||
|
Waiting,
|
||||||
|
Downloading_Image,
|
||||||
|
Applying_Image,
|
||||||
|
Installing_Drivers,
|
||||||
|
Joining,
|
||||||
|
Completed,
|
||||||
|
Idle
|
||||||
|
}
|
||||||
|
}
|
||||||
57
MIT Packets/MIT Packets.csproj
Normal file
57
MIT Packets/MIT Packets.csproj
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>MIT_Packets</RootNamespace>
|
||||||
|
<AssemblyName>MIT Packets</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Articulate-Network">
|
||||||
|
<HintPath>..\..\Articulate-Network\bin\Debug\Articulate-Network.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AnnouncePacket.cs" />
|
||||||
|
<Compile Include="Configuration\ClientConfigPacket.cs" />
|
||||||
|
<Compile Include="Enums\ClientStatus.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TestPacket.cs" />
|
||||||
|
<Compile Include="Transfer\EndFileTransferPacket.cs" />
|
||||||
|
<Compile Include="Transfer\SendFileChunkPacket.cs" />
|
||||||
|
<Compile Include="Transfer\StartFileTransferPacket.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
36
MIT Packets/Properties/AssemblyInfo.cs
Normal file
36
MIT Packets/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("MIT Packets")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Queensland Government")]
|
||||||
|
[assembly: AssemblyProduct("MIT Packets")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Queensland Government 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("ec6cf112-fdfe-4acd-98e2-372e0d9ed908")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
18
MIT Packets/TestPacket.cs
Normal file
18
MIT Packets/TestPacket.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Articulate_Network.Attributes;
|
||||||
|
using Articulate_Network.Interfaces;
|
||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets
|
||||||
|
{
|
||||||
|
public class TestPacket : Packet
|
||||||
|
{
|
||||||
|
public int TestOne { get; set; }
|
||||||
|
public bool TestTwo { get; set; }
|
||||||
|
public string TestThree { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
MIT Packets/Transfer/EndFileTransferPacket.cs
Normal file
14
MIT Packets/Transfer/EndFileTransferPacket.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets.Transfer
|
||||||
|
{
|
||||||
|
public class EndFileTransferPacket : Packet
|
||||||
|
{
|
||||||
|
public bool Completed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
18
MIT Packets/Transfer/SendFileChunkPacket.cs
Normal file
18
MIT Packets/Transfer/SendFileChunkPacket.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Articulate_Network.Attributes;
|
||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets.Transfer
|
||||||
|
{
|
||||||
|
public class SendFileChunkPacket : Packet
|
||||||
|
{
|
||||||
|
[PacketIgnore]
|
||||||
|
public int TransferID { get; set; }
|
||||||
|
public int ChunkSize { get; set; }
|
||||||
|
public byte[] Chunk { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
15
MIT Packets/Transfer/StartFileTransferPacket.cs
Normal file
15
MIT Packets/Transfer/StartFileTransferPacket.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using Articulate_Network.Packets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Packets.Transfer
|
||||||
|
{
|
||||||
|
public class StartFileTransferPacket : Packet
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public long ExpectedSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
6
MOE Builder Client/App.config
Normal file
6
MOE Builder Client/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
15
MOE Builder Client/Configuration.cs
Normal file
15
MOE Builder Client/Configuration.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Builder_Client
|
||||||
|
{
|
||||||
|
public class Configuration
|
||||||
|
{
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public int Drivers { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
72
MOE Builder Client/Handlers/FileTransferHandler.cs
Normal file
72
MOE Builder Client/Handlers/FileTransferHandler.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using Articulate_Network.Packets;
|
||||||
|
using MIT_Packets.Transfer;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Builder_Client.Handlers
|
||||||
|
{
|
||||||
|
public class FileTransferHandler
|
||||||
|
{
|
||||||
|
static string fileName;
|
||||||
|
static long expectedSize;
|
||||||
|
static long currentSize = 0;
|
||||||
|
|
||||||
|
static FileStream fs;
|
||||||
|
|
||||||
|
public static void HandleTransfer(Packet packet)
|
||||||
|
{
|
||||||
|
if (packet is StartFileTransferPacket)
|
||||||
|
StartFileTransfer((StartFileTransferPacket)packet);
|
||||||
|
|
||||||
|
if (packet is SendFileChunkPacket)
|
||||||
|
ReceiveChunk((SendFileChunkPacket)packet);
|
||||||
|
|
||||||
|
if (packet is EndFileTransferPacket)
|
||||||
|
{
|
||||||
|
watch.Stop();
|
||||||
|
Console.WriteLine($"Transfer completed. Received {packetsReceived} packets. Took {watch.Elapsed.Seconds} seconds.");
|
||||||
|
fs.Flush();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int packetsReceived = 0;
|
||||||
|
|
||||||
|
static Stopwatch watch = new Stopwatch();
|
||||||
|
|
||||||
|
static void StartFileTransfer(StartFileTransferPacket packet)
|
||||||
|
{
|
||||||
|
watch.Start();
|
||||||
|
fileName = packet.FileName + "-transferred";
|
||||||
|
expectedSize = packet.ExpectedSize;
|
||||||
|
|
||||||
|
Console.WriteLine($"Preparing to receive {fileName} expected size: {expectedSize}");
|
||||||
|
|
||||||
|
fs = File.Create(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ReceiveChunk(SendFileChunkPacket packet)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("Chunk length: " + packet.Chunk.Length);
|
||||||
|
//Console.WriteLine("Chunk expected size: " + packet.ChunkSize);
|
||||||
|
//if (currentSize > 0)
|
||||||
|
if (packet.ChunkSize < 0 || packet.ChunkSize > packet.Chunk.Length)
|
||||||
|
Console.WriteLine("Invalid chunk.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs.Write(packet.Chunk, 0, packet.ChunkSize);
|
||||||
|
currentSize += packet.ChunkSize;
|
||||||
|
packetsReceived += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (((currentSize / expectedSize) * 100) % 25 == 0)
|
||||||
|
Console.WriteLine("Completed 25%");*/
|
||||||
|
//Console.WriteLine(currentSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
MOE Builder Client/MIT Builder Client.csproj
Normal file
68
MOE Builder Client/MIT Builder Client.csproj
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>MIT_Builder_Client</RootNamespace>
|
||||||
|
<AssemblyName>MIT Builder Client</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Articulate-Network">
|
||||||
|
<HintPath>..\..\Articulate-Network\bin\Debug\Articulate-Network.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Configuration.cs" />
|
||||||
|
<Compile Include="Handlers\FileTransferHandler.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MIT Packets\MIT Packets.csproj">
|
||||||
|
<Project>{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}</Project>
|
||||||
|
<Name>MIT Packets</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
64
MOE Builder Client/Program.cs
Normal file
64
MOE Builder Client/Program.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using Articulate_Network;
|
||||||
|
using Articulate_Network.Managers;
|
||||||
|
using MIT_Builder_Client.Handlers;
|
||||||
|
using MIT_Packets;
|
||||||
|
using MIT_Packets.Enums;
|
||||||
|
using MIT_Packets.Transfer;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MIT_Builder_Client
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static Client client;
|
||||||
|
public static ClientStatus status = ClientStatus.Waiting;
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
AnnouncePacket.Register();
|
||||||
|
|
||||||
|
client = new Client();
|
||||||
|
|
||||||
|
client.Connect("10.136.5.59", 50).ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t.Result.Connected)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Successfully connected to master server.");
|
||||||
|
|
||||||
|
AnnounceClient();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.DataReceived += Client_DataReceived;
|
||||||
|
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AnnounceClient()
|
||||||
|
{
|
||||||
|
string macAddress = NetworkInterface.GetAllNetworkInterfaces().Where(nic => nic.OperationalStatus == OperationalStatus.Up).Select(nic => nic.GetPhysicalAddress().ToString()).FirstOrDefault();
|
||||||
|
|
||||||
|
client.SendPacket(new AnnouncePacket()
|
||||||
|
{
|
||||||
|
Type = 1,
|
||||||
|
RequestConfig = true,
|
||||||
|
MacAddress = macAddress
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Client_DataReceived(object sender, Articulate_Network.Events.DataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"Received Packet: {e.Packet.GetType().Name}");
|
||||||
|
|
||||||
|
if (e.Packet is StartFileTransferPacket || e.Packet is SendFileChunkPacket || e.Packet is EndFileTransferPacket)
|
||||||
|
FileTransferHandler.HandleTransfer(e.Packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
MOE Builder Client/Properties/AssemblyInfo.cs
Normal file
36
MOE Builder Client/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("MOE Builder Client")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Queensland Government")]
|
||||||
|
[assembly: AssemblyProduct("MOE Builder Client")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Queensland Government 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("0df731b9-a08c-4baf-b079-fe88dc7487e5")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
4
MOE Builder Client/packages.config
Normal file
4
MOE Builder Client/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net46" />
|
||||||
|
</packages>
|
||||||
37
Mass Imaging Tool.sln
Normal file
37
Mass Imaging Tool.sln
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.31624.102
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIT Builder Client", "MOE Builder Client\MIT Builder Client.csproj", "{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIT Master Server", "MIT Master Server\MIT Master Server.csproj", "{0A8A25AE-69F6-4F10-95E5-20495717FE34}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIT Packets", "MIT Packets\MIT Packets.csproj", "{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0DF731B9-A08C-4BAF-B079-FE88DC7487E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0A8A25AE-69F6-4F10-95E5-20495717FE34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0A8A25AE-69F6-4F10-95E5-20495717FE34}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0A8A25AE-69F6-4F10-95E5-20495717FE34}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0A8A25AE-69F6-4F10-95E5-20495717FE34}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EC6CF112-FDFE-4ACD-98E2-372E0D9ED908}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {FEBBB8A4-F591-4996-BF6D-FEFA7A4ABFF9}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
14
README.md
14
README.md
@ -1,2 +1,14 @@
|
|||||||
# Mass-Imaging-Tool
|
<p align="center"><img src="https://education.qld.gov.au/style%20library/DET/skins/core/images/qg-logo.svg" width="400"></p>
|
||||||
|
<p align="center"><img src="https://education.qld.gov.au/style%20library/DET/skins/core/images/departmentname.svg" width="300"></p>
|
||||||
|
|
||||||
|
|
||||||
|
# Mass Imaging Tool
|
||||||
|
|
||||||
|
The purpose of this project is to develop a tool that streamlines the existing process used to deploy WIM images via PXE Boot in the DoE environment.
|
||||||
|
|
||||||
|
The MIT contains 4 projects.
|
||||||
|
|
||||||
|
- The Master Server, connecting all the services together.
|
||||||
|
- The Web UI, built powered by ASP.NET with ReactJS.
|
||||||
|
- The Builder Client, which provides remote control & progress reporting on the build status
|
||||||
|
- The Joiner Client, which provides remote control & progress reporting on the EQ joiner status
|
||||||
274
build-failed.xml
Normal file
274
build-failed.xml
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user