-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetworkServer: ----------------------------------------- Bugfixes: Changed the name of the class from NewtworkServer to NetworkServer Changes: Added Basic Functionality. ( Now App can be killed with TooManyConnections :) ) ToDo: Stop() functionality; MaxProcessingThreads value and its functionality; Actual functionality at least for ping and changeip messages. ----------------------------------------- MainWindow: ----------------------------------------- Changes: Added tabs and changed style to orangish. Also added a method to show yes-no dialog - ShowBinaryDialog() ToDo: Add actual *basic* functionality to FileShare tab and Users tab ----------------------------------------- *NEW* NetPacket: ----------------------------------------- Basic skeleton of the class. This class will handle package version detection, package data decryption, encryption, checksum checks and etc. ----------------------------------------- *NEW* UserInfo: ----------------------------------------- This class has some functionality of storing Users' data and state. It is also *probably* able to serialize itself into a string/file. However, this is have been not tested yet. ----------------------------------------- *NEW* SerializableList ----------------------------------------- This class *again, not tested* is able to hold the List of some objects and serialize it at your wish. Maybe it's reinventing the wheel, but who cares? ToDo: Change its behavior, so it will hold not the List<T>, but ICollection<T> ----------------------------------------- And added/changed some little things here and there.
- Loading branch information
1 parent
817806f
commit e3818de
Showing
11 changed files
with
578 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Runtime.Serialization; | ||
using System.Runtime.Serialization.Formatters; | ||
|
||
namespace AutoShare.Engine.IO | ||
{ | ||
|
||
[Serializable()] | ||
public class SerializableList<T>:ISerializable | ||
{ | ||
List<T> lst; | ||
public List<T> List { get { return lst; } set { lst = value; } } | ||
public SerializableList() | ||
{ | ||
lst = new List<T>(); | ||
} | ||
public SerializableList(List<T> List) | ||
{ | ||
lst = List; | ||
} | ||
|
||
public SerializableList( SerializationInfo info, StreamingContext context) | ||
{ | ||
lst = (List<T>)info.GetValue("list" , typeof(List<T>)); | ||
} | ||
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) | ||
{ | ||
|
||
info.AddValue("list", lst, typeof(List<T>)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Security.Cryptography; | ||
|
||
namespace AutoShare.Engine.Network | ||
{ | ||
public class NetPacket | ||
{ | ||
#region Helper Classes | ||
public enum PacketType | ||
{ | ||
PT_PUBLIC_WITH_HASH, //Packet's integrity is secured with MD5 checksum | ||
PT_PUBLIC_WITHOUT_HASH, //Packet's integrity is not guaranteed | ||
//PT_PUBLIC_STREAMING, //Packet's integrity is not checked as it is a public packet. Special structure for continous packets | ||
PT_PRIVATE, //Packet Integrity is | ||
//PT_PRIVATE_STREAMING //Packet's integrity is guaranteed through streaming encryption with ECB mode. Special structure for streaming packets. | ||
} | ||
public abstract class PacketSignatureRule | ||
{ | ||
#region Helper Classes | ||
public enum PacketSignatureAlignement { | ||
PS_ALIGN_BEGIN, | ||
PS_ALIGN_END | ||
} | ||
#endregion | ||
#region Public Static Members | ||
public static int MaxSignatureSize = 80; | ||
#endregion | ||
#region Public Members | ||
public readonly int SignatureSize; | ||
public readonly int SignatureVersion; | ||
public readonly PacketSignatureAlignement Alignement; | ||
public readonly bool DataEncrypted; | ||
public readonly bool MD5HashPresent; | ||
public readonly string SignatureName; | ||
public readonly string SignatureDetectionHelper; | ||
#endregion | ||
#region Constructors | ||
public PacketSignatureRule( | ||
int SignatureSize, int SignatureVersion, PacketSignatureAlignement Alignement, | ||
bool DataEncrypted, bool MD5HashPresent, | ||
string SignatureName, string SignatureDetectionHelper | ||
) | ||
{ | ||
this.SignatureSize = SignatureSize; | ||
if (MaxSignatureSize < this.SignatureSize) | ||
throw new TypeInitializationException("PacketSignatureRule", | ||
new Exception("SignatureSize value is more than MaxSignatureSize. Either change the PacketSignatureRule.MaxSignatureSize or lower the passed SignatureSize value."+System.Environment.NewLine+ | ||
"Ignoring this message may change the behaviour of the application when accepting packets over network using MaxSignatureSize as the buffer size.")); | ||
this.SignatureName = SignatureName; | ||
this.SignatureVersion = SignatureVersion; | ||
this.Alignement = Alignement; | ||
this.DataEncrypted = DataEncrypted; | ||
this.MD5HashPresent = MD5HashPresent; | ||
this.SignatureDetectionHelper = SignatureDetectionHelper; | ||
|
||
} | ||
#endregion | ||
|
||
#region API Calls | ||
public abstract PacketType GetPacketType(); | ||
#endregion | ||
} | ||
|
||
public class PublicNodePacket:PacketSignatureRule | ||
{ | ||
#region Static Members | ||
private static readonly int SizeFieldSize = 8; //Size of the field in the signature, that tells us the size of the actual packet | ||
private static readonly int PacketVersion = 1; | ||
private static readonly string SignatureHelper = "{PUBLIC}"; | ||
|
||
public static readonly PacketType Type = PacketType.PT_PUBLIC_WITH_HASH; | ||
#endregion | ||
public PublicNodePacket(): | ||
base(16+SizeFieldSize+SignatureHelper.Length, PacketVersion, PacketSignatureAlignement.PS_ALIGN_BEGIN, false, true, "PublicNodePacket", SignatureHelper) | ||
{ | ||
|
||
} | ||
|
||
public override PacketType GetPacketType() | ||
{ | ||
return Type; | ||
} | ||
} | ||
public class PublicUnsafePacket : PacketSignatureRule | ||
{ | ||
#region Static Members | ||
private static readonly int SizeFieldSize = 8; //Size of the field in the signature, that tells us the size of the actual packet | ||
private static readonly int PacketVersion = 1; | ||
private static readonly string SignatureHelper = "{UNSAFE}"; | ||
|
||
public static readonly PacketType Type = PacketType.PT_PUBLIC_WITHOUT_HASH; | ||
#endregion | ||
public PublicUnsafePacket() | ||
: base(SizeFieldSize + SignatureHelper.Length, PacketVersion, PacketSignatureAlignement.PS_ALIGN_BEGIN, false, false, "PublicUnsafePacket", SignatureHelper) | ||
{ | ||
|
||
} | ||
|
||
public override PacketType GetPacketType() | ||
{ | ||
return Type; | ||
} | ||
} | ||
#endregion | ||
#region Static Members | ||
public static readonly PacketSignatureRule[] SignatureRules = new PacketSignatureRule[2]{ new PublicNodePacket(), new PublicUnsafePacket() }; | ||
#endregion | ||
#region Static Methods | ||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.