Skip to content

Commit

Permalink
v1.1.20
Browse files Browse the repository at this point in the history
+Bugfix null var
  • Loading branch information
Meoqan committed Apr 24, 2017
1 parent b11f593 commit 06fb2db
Show file tree
Hide file tree
Showing 88 changed files with 39,497 additions and 19,676 deletions.
1,031 changes: 1,031 additions & 0 deletions Vaser/.vs/config/applicationhost.config

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Vaser/Vaser.Core/IDPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class IDPool
/// <summary>
/// Creates a new pool of IDs
/// </summary>
/// <param name="MaxIDs"></param>
/// <param name="MaxIDs">Maximum amount of IDs.</param>
public IDPool(uint MaxIDs)
{
//if (MaxIDs < 0) throw new Exception("MaxIDs must be an positive integer");
Expand All @@ -35,19 +35,19 @@ public IDPool(uint MaxIDs)
/// <summary>
/// Returns a free ID from the pool
/// </summary>
/// <returns>ID</returns>
/// <returns>A free ID</returns>
public uint GetFreeID()
{
lock(threadlock)
lock (threadlock)
{
if(freeIDList.Count == 0) throw new Exception("free pool is empty");
if (freeIDList.Count == 0) throw new Exception("free pool is empty");

uint id = freeIDList[0];
freeIDList.Remove(id);
usedIDList.Add(id);
return id;
}

}

/// <summary>
Expand All @@ -58,7 +58,7 @@ public uint GetFreeID()
public uint RegisterFreeID(uint id)
{
//if (id < 0) throw new Exception("ID must be an positive integer");

lock (threadlock)
{
if (freeIDList.Contains(id)) freeIDList.Remove(id);
Expand All @@ -78,7 +78,7 @@ public void DisposeID(uint id)

lock (threadlock)
{
if(usedIDList.Contains(id)) usedIDList.Remove(id);
if (usedIDList.Contains(id)) usedIDList.Remove(id);
freeIDList.Add(id);
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public uint AddFreeIDs(uint Quantity)
{
uint _OldMaxIDs = _MaxIDs;
_MaxIDs += Quantity;
for (uint x = _OldMaxIDs+1; x <= Quantity; x++)
for (uint x = _OldMaxIDs + 1; x <= Quantity; x++)
{
freeIDList.Add(x);
}
Expand Down
52 changes: 17 additions & 35 deletions Vaser/Vaser.Core/Net/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ internal class Connection

private byte[] _buff = new byte[65012];

private VaserServer _server;
//private VaserServer _server;

private Link _link;
private IPAddress _IPv4Address;
//private Link _link;
//private IPAddress _IPv4Address;

private object _WorkAtStream_Lock = new object();

Expand Down Expand Up @@ -91,41 +91,23 @@ internal class Connection
/// </summary>
public IPAddress IPv4Address
{
get
{
return _IPv4Address;
}
set
{
_IPv4Address = value;
}
get;
internal set;
}

/// <summary>
/// Link of the connection
/// </summary>
public Link link
{
get
{
return _link;
}
set
{
_link = value;
}
get;
internal set;
}

internal VaserServer server
{
get
{
return _server;
}
set
{
_server = value;
}
get;
set;
}

/// <summary>
Expand Down Expand Up @@ -444,7 +426,7 @@ internal void QueueStreamDecrypt()

internal void QueueSendNotEncrypted()
{
lock (_link.SendData_Lock)
lock (link.SendData_Lock)
{
if (IsInSendQueue == false)
{
Expand All @@ -457,7 +439,7 @@ internal void QueueSendNotEncrypted()

internal void QueueSendKerberos()
{
lock (_link.SendData_Lock)
lock (link.SendData_Lock)
{
if (IsInSendQueue == false)
{
Expand All @@ -470,7 +452,7 @@ internal void QueueSendKerberos()

internal void QueueSendSSL()
{
lock (_link.SendData_Lock)
lock (link.SendData_Lock)
{
if (IsInSendQueue == false)
{
Expand Down Expand Up @@ -774,7 +756,7 @@ internal void Dispose()
if (link != null)
{
link.Dispose();
link = null;
//link = null;
}

Debug.WriteLine("Link.Dispose finished");
Expand Down Expand Up @@ -978,15 +960,15 @@ internal async void SendSSL(Object threadContext)
private bool GetPackets()
{
SendFound = false;
lock (_link.SendData_Lock)
lock (link.SendData_Lock)
{
for (int x = 0; x < _link.SendDataPortalArrayOUTPUT.Length; x++)
for (int x = 0; x < link.SendDataPortalArrayOUTPUT.Length; x++)
{
if (_link.SendDataPortalArrayOUTPUT[x].Count > 0)
if (link.SendDataPortalArrayOUTPUT[x].Count > 0)
{

//Debug.WriteLine("data");
byteData = _link.SendDataPortalArrayOUTPUT[x].Dequeue();
byteData = link.SendDataPortalArrayOUTPUT[x].Dequeue();
SendFound = true;
if (byteData._CallEmpybuffer) _CallEmptyBuffer = true;

Expand Down
47 changes: 25 additions & 22 deletions Vaser/Vaser.Core/Net/VaserClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ namespace Vaser
public class VaserClient
{
/// <summary>
/// Connect to a Vaser server unencrypted.
/// Opens an unencrypted connection to a server.
/// </summary>
/// <param name="IP">hostname or IPAddress</param>
/// <param name="Port">3000</param>
/// <param name="PortalCollection">the Portal Collection</param>
/// <returns>Returns the link to the client</returns>
public static Link ConnectClient(string IP, int Port, PortalCollection PColl)
/// <param name="IP">Hostname or IP-Address.</param>
/// <param name="RemotePort">Target port of the remote server.</param>
/// <param name="PColl">The Portal Collection.</param>
/// <returns>Returns the link of the connection.</returns>
/// <exception cref="System.Net.Sockets.SocketException">Thrown if vaser is unable to create a socket or a connection.</exception>
public static Link ConnectClient(string IP, int RemotePort, PortalCollection PColl)
{
//if (Mode == VaserOptions.ModeSSL) throw new Exception("Missing X509Certificate2");
if (PColl == null) throw new Exception("PortalCollection is needed!");

try
{
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Task t = client.ConnectAsync(IP, Port);
Task t = client.ConnectAsync(IP, RemotePort);
t.Wait();
if (client.Connected)
{
Expand All @@ -52,22 +53,23 @@ public static Link ConnectClient(string IP, int Port, PortalCollection PColl)
}

/// <summary>
/// Connect to a Vaser server via kerberos.
/// Opens an kerberos encrypted connection to a server.
/// </summary>
/// <param name="IP">hostname or IPAddress</param>
/// <param name="Port">3000</param>
/// <param name="PortalCollection">the Portal Collection</param>
/// <param name="Kerberos">the kerberos connection settings</param>
/// <returns>Returns the link to the client</returns>
public static Link ConnectClient(string IP, int Port, PortalCollection PColl, VaserKerberosClient Kerberos)
/// <param name="IP">Hostname or IP-Address.</param>
/// <param name="RemotePort">Target port of the remote server.</param>
/// <param name="PColl">The Portal Collection.</param>
/// <param name="Kerberos">The Kerberos connectionsettings.</param>
/// <returns>Returns the link of the connection.</returns>
/// <exception cref="System.Net.Sockets.SocketException">Thrown if vaser is unable to create a socket or a connection.</exception>
public static Link ConnectClient(string IP, int RemotePort, PortalCollection PColl, VaserKerberosClient Kerberos)
{
//if (Mode == VaserOptions.ModeSSL) throw new Exception("Missing X509Certificate2");
if (PColl == null) throw new Exception("PortalCollection is needed!");

try
{
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Task t = client.ConnectAsync(IP, Port);
Task t = client.ConnectAsync(IP, RemotePort);
t.Wait();
if (client.Connected)
{
Expand Down Expand Up @@ -95,20 +97,21 @@ public static Link ConnectClient(string IP, int Port, PortalCollection PColl, Va
/// <summary>
/// Connect to a Vaser server via SSL.
/// </summary>
/// <param name="ip">hostname or IPAddress</param>
/// <param name="port">3000</param>
/// <param name="PortalCollection">the PortalCollection</param>
/// <param name="SSL">SSL connection settings</param>
/// <returns>Returns the link to the client</returns>
public static Link ConnectClient(string IP, int Port, PortalCollection PColl, VaserSSLClient SSL)
/// <param name="IP">Hostname or IP-Address.</param>
/// <param name="RemotePort">Target port of the remote server.</param>
/// <param name="PColl">The Portal Collection.</param>
/// <param name="SSL">The SSL connectionsettings.</param>
/// <returns>Returns the link of the connection.</returns>
/// <exception cref="System.Net.Sockets.SocketException">Thrown if vaser is unable to create a socket or a connection.</exception>
public static Link ConnectClient(string IP, int RemotePort, PortalCollection PColl, VaserSSLClient SSL)
{
if (SSL == null) throw new Exception("Missing SSL options in ConnectClient(...)");
if (PColl == null) throw new Exception("PortalCollection is needed!");

try
{
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Task t = client.ConnectAsync(IP, Port);
Task t = client.ConnectAsync(IP, RemotePort);
t.Wait();
if (client.Connected)
{
Expand Down
Loading

0 comments on commit 06fb2db

Please sign in to comment.