Skip to content

Commit

Permalink
Project restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
NTDLS committed Jun 18, 2024
1 parent dbebfee commit b5d39b0
Show file tree
Hide file tree
Showing 54 changed files with 382 additions and 484 deletions.
18 changes: 0 additions & 18 deletions NetTunnel.Library/Exceptions/NtAPIResponseException.cs

This file was deleted.

20 changes: 0 additions & 20 deletions NetTunnel.Library/Exceptions/NtExceptionBase.cs

This file was deleted.

18 changes: 0 additions & 18 deletions NetTunnel.Library/Exceptions/NtGenericException.cs

This file was deleted.

18 changes: 0 additions & 18 deletions NetTunnel.Library/Exceptions/NtNullException.cs

This file was deleted.

5 changes: 1 addition & 4 deletions NetTunnel.Library/NetTunnel.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NTDLS.NASCCL" Version="1.1.1" />
<PackageReference Include="NTDLS.NullHelpers" Version="1.0.0" />
<PackageReference Include="NTDLS.ReliableMessaging" Version="1.8.2" />
<PackageReference Include="NTDLS.SecureKeyExchange" Version="2.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\NTDLS.ReliableMessaging\NTDLS.ReliableMessaging\NTDLS.ReliableMessaging.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace NetTunnel.Library.ReliableMessages.Notification
{
public class NotificationEndpointExchange : IRmNotification
public class NotificationEndpointDataExchange : IRmNotification
{
public Guid StreamId { get; set; }
public Guid TunnelId { get; set; }
public Guid EndpointId { get; set; }
public byte[] Bytes { get; set; }

public NotificationEndpointExchange(Guid tunnelId, Guid endpointId, Guid streamId, byte[] bytes, int length)
public NotificationEndpointDataExchange(Guid tunnelId, Guid endpointId, Guid streamId, byte[] bytes, int length)
{
StreamId = streamId;
TunnelId = tunnelId;
Expand All @@ -19,7 +19,7 @@ public NotificationEndpointExchange(Guid tunnelId, Guid endpointId, Guid streamI
Array.Copy(bytes, Bytes, length);
}

public NotificationEndpointExchange()
public NotificationEndpointDataExchange()
{
Bytes = Array.Empty<byte>();
}
Expand Down
4 changes: 2 additions & 2 deletions NetTunnel.Library/ReliableMessages/Query/QueryCreateTunnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace NetTunnel.Library.ReliableMessages.Query
{
public class QueryCreateTunnel : IRmQuery<QueryCreateTunnelReply>
{
public NtTunnelConfiguration Configuration { get; set; }
public TunnelConfiguration Configuration { get; set; }

public QueryCreateTunnel(NtTunnelConfiguration configuration)
public QueryCreateTunnel(TunnelConfiguration configuration)
{
Configuration = configuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class QueryGetTunnels : IRmQuery<QueryGetTunnelsReply>

public class QueryGetTunnelsReply : IRmQueryReply
{
public List<NtTunnelConfiguration> Collection { get; set; } = new();
public List<TunnelConfiguration> Collection { get; set; } = new();

public QueryGetTunnelsReply()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace NetTunnel.Library.ReliableMessages.Query
{
public class QueryRegisterTunnel : IRmQuery<QueryRegisterTunnelReply>
{
public NtTunnelConfiguration Configuration { get; set; } = new();
public TunnelConfiguration Configuration { get; set; } = new();

public QueryRegisterTunnel()
{
}

public QueryRegisterTunnel(NtTunnelConfiguration configuration)
public QueryRegisterTunnel(TunnelConfiguration configuration)
{
Configuration = configuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace NetTunnel.Library.ReliableMessages.Query
public class QueryUpsertEndpoint : IRmQuery<QueryUpsertEndpointReply>
{
public Guid TunnelId { get; set; }
public NtEndpointConfiguration Configuration { get; set; }
public EndpointConfiguration Configuration { get; set; }

public QueryUpsertEndpoint(Guid tunnelId, NtEndpointConfiguration configuration)
public QueryUpsertEndpoint(Guid tunnelId, EndpointConfiguration configuration)
{
TunnelId = tunnelId;
Configuration = configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace NetTunnel.Library
/// <summary>
/// Used by both the UI to connect to a service and the service to connect to other services.
/// </summary>
public class NtServiceClient
public class ServiceClient
{
public RmClient Client { get; private set; }

private readonly NtServiceConfiguration _configuration;
private readonly ServiceConfiguration _configuration;
private readonly string _address;
private readonly int _port;
private readonly string _userName;
Expand All @@ -26,7 +26,7 @@ public class NtServiceClient
/// </summary>
public Guid ServiceId { get; private set; }

public NtServiceClient(NtServiceConfiguration configuration, RmClient client, string address, int port, string userName, string passwordHash)
public ServiceClient(ServiceConfiguration configuration, RmClient client, string address, int port, string userName, string passwordHash)
{
_configuration = configuration;
Client = client;
Expand All @@ -38,20 +38,20 @@ public NtServiceClient(NtServiceConfiguration configuration, RmClient client, st

#region Factory.

public static async Task<NtServiceClient> CreateConnectAndLogin(string address, int port, string userName, string passwordHash, object? owner = null)
public static async Task<ServiceClient> CreateConnectAndLogin(string address, int port, string userName, string passwordHash, object? owner = null)
{
return await CreateConnectAndLogin(new NtServiceConfiguration(), address, port, userName, passwordHash, owner);
return await CreateConnectAndLogin(new ServiceConfiguration(), address, port, userName, passwordHash, owner);
}

public static async Task<NtServiceClient> CreateConnectAndLogin(NtServiceConfiguration configuration,
public static async Task<ServiceClient> CreateConnectAndLogin(ServiceConfiguration configuration,
string address, int port, string userName, string passwordHash, object? owner = null)
{
var serviceClient = Create(configuration, address, port, userName, passwordHash, owner);
await serviceClient.ConnectAndLogin();
return serviceClient;
}

public static NtServiceClient Create(NtServiceConfiguration configuration, string address, int port, string userName, string passwordHash, object? owner = null)
public static ServiceClient Create(ServiceConfiguration configuration, string address, int port, string userName, string passwordHash, object? owner = null)
{
var client = new RmClient(new RmConfiguration()
{
Expand All @@ -61,7 +61,7 @@ public static NtServiceClient Create(NtServiceConfiguration configuration, strin
ReceiveBufferGrowthRate = configuration.ReceiveBufferGrowthRate,
});

return new NtServiceClient(configuration, client, address, port, userName, passwordHash);
return new ServiceClient(configuration, client, address, port, userName, passwordHash);
}

#endregion
Expand Down Expand Up @@ -118,22 +118,22 @@ public double Ping()
}).Result;
}

public async Task<QueryCreateTunnelReply> QueryCreateTunnel(NtTunnelConfiguration configuration)
public async Task<QueryCreateTunnelReply> QueryCreateTunnel(TunnelConfiguration configuration)
=> await Client.Query(new QueryCreateTunnel(configuration));

public async Task<QueryGetTunnelsReply> QueryGetTunnels()
=> await Client.Query(new QueryGetTunnels());

public async Task<QueryRegisterTunnelReply> QueryRegisterTunnel(NtTunnelConfiguration Collection)
public async Task<QueryRegisterTunnelReply> QueryRegisterTunnel(TunnelConfiguration Collection)
=> await Client.Query(new QueryRegisterTunnel(Collection));

public async Task<QueryUpsertEndpointReply> QueryUpsertEndpoint(Guid tunnelId, NtEndpointConfiguration configuration)
public async Task<QueryUpsertEndpointReply> QueryUpsertEndpoint(Guid tunnelId, EndpointConfiguration configuration)
=> await Client.Query(new QueryUpsertEndpoint(tunnelId, configuration));

public void NotificationEndpointConnect(Guid tunnelId, Guid endpointId, Guid streamId)
=> Client.Notify(new NotificationEndpointConnect(tunnelId, endpointId, streamId));

public void NotificationEndpointExchange(Guid tunnelId, Guid endpointId, Guid streamId, byte[] bytes, int length)
=> Client.Notify(new NotificationEndpointExchange(tunnelId, endpointId, streamId, bytes, length));
=> Client.Notify(new NotificationEndpointDataExchange(tunnelId, endpointId, streamId, bytes, length));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NetTunnel.Library.Types
/// These are sent to the tunnel service when the tunnel is connected, but once the connection
/// is made - they can be altered at either end by the service UI.
/// </summary>
public class NtEndpointConfiguration
public class EndpointConfiguration
{
public Guid EndpointId { get; set; }
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
Expand All @@ -21,14 +21,14 @@ public class NtEndpointConfiguration

[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
public NtTrafficType TrafficType { get; set; } = NtTrafficType.Raw;
public List<NtHttpHeaderRule> HttpHeaderRules { get; set; } = new();
public List<HttpHeaderRule> HttpHeaderRules { get; set; } = new();

public NtEndpointConfiguration()
public EndpointConfiguration()
{
}

public NtEndpointConfiguration(Guid endpointId, string name,
string outboundAddress, int inboundPort, int outboundPort, List<NtHttpHeaderRule> httpHeaderRules, NtTrafficType trafficType)
public EndpointConfiguration(Guid endpointId, string name,
string outboundAddress, int inboundPort, int outboundPort, List<HttpHeaderRule> httpHeaderRules, NtTrafficType trafficType)
{
EndpointId = endpointId;
Direction = NtDirection.Undefined;
Expand All @@ -40,8 +40,8 @@ public NtEndpointConfiguration(Guid endpointId, string name,
HttpHeaderRules.AddRange(httpHeaderRules);
}

public NtEndpointConfiguration(Guid endpointId, NtDirection direction, string name,
string outboundAddress, int inboundPort, int outboundPort, List<NtHttpHeaderRule> httpHeaderRules, NtTrafficType trafficType)
public EndpointConfiguration(Guid endpointId, NtDirection direction, string name,
string outboundAddress, int inboundPort, int outboundPort, List<HttpHeaderRule> httpHeaderRules, NtTrafficType trafficType)
{
EndpointId = endpointId;
Direction = direction;
Expand All @@ -53,9 +53,9 @@ public NtEndpointConfiguration(Guid endpointId, NtDirection direction, string na
HttpHeaderRules.AddRange(httpHeaderRules);
}

public NtEndpointConfiguration CloneConfiguration()
public EndpointConfiguration CloneConfiguration()
{
var clone = new NtEndpointConfiguration
var clone = new EndpointConfiguration
{
EndpointId = EndpointId,
Direction = Direction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
using Newtonsoft.Json.Converters;
using static NetTunnel.Library.Constants;

namespace NetTunnel.Library.Types
{
public class NtEndpointStatistics
{
/// <summary>
/// Used to determine if anything has changed.
/// </summary>
public int ChangeHash { get; set; }
public ulong CurrentConnections { get; set; }
public ulong TotalConnections { get; set; }
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
public NtDirection Direction { get; set; }
public Guid TunnelId { get; set; }
public Guid EndpointId { get; set; }
public ulong BytesReceived { get; set; }
public ulong BytesSent { get; set; }
public double BytesReceivedKb => BytesReceived / 1024.0;
public double BytesSentKb => BytesSent / 1024.0;
}
}
using Newtonsoft.Json.Converters;
using static NetTunnel.Library.Constants;

namespace NetTunnel.Library.Types
{
public class EndpointStatistics
{
/// <summary>
/// Used to determine if anything has changed.
/// </summary>
public int ChangeHash { get; set; }
public ulong CurrentConnections { get; set; }
public ulong TotalConnections { get; set; }
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
public NtDirection Direction { get; set; }
public Guid TunnelId { get; set; }
public Guid EndpointId { get; set; }
public ulong BytesReceived { get; set; }
public ulong BytesSent { get; set; }
public double BytesReceivedKb => BytesReceived / 1024.0;
public double BytesSentKb => BytesSent / 1024.0;
}
}
6 changes: 3 additions & 3 deletions NetTunnel.Library/Types/EndpointTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
public class EndpointTag
{
public NtTunnelConfiguration Tunnel { get; set; }
public NtEndpointConfiguration Endpoint { get; set; }
public TunnelConfiguration Tunnel { get; set; }
public EndpointConfiguration Endpoint { get; set; }

public EndpointTag(NtTunnelConfiguration tunnel, NtEndpointConfiguration endpoint)
public EndpointTag(TunnelConfiguration tunnel, EndpointConfiguration endpoint)
{
Tunnel = tunnel;
Endpoint = endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NetTunnel.Library
{
public class NtHttpHeaderRule
public class HttpHeaderRule
{
/// <summary>
/// Inbound, outbound, etc.
Expand Down Expand Up @@ -42,21 +42,21 @@ public class NtHttpHeaderRule
/// </summary>
public string Description { get; set; } = string.Empty;

public NtHttpHeaderRule(NtHttpVerb verb, string name, NtHttpHeaderAction action, string value)
public HttpHeaderRule(NtHttpVerb verb, string name, NtHttpHeaderAction action, string value)
{
Verb = verb;
Name = name;
Action = action;
Value = value;
}

public NtHttpHeaderRule()
public HttpHeaderRule()
{
}

public NtHttpHeaderRule CloneConfiguration()
public HttpHeaderRule CloneConfiguration()
{
return new NtHttpHeaderRule
return new HttpHeaderRule
{
Name = Name,
Value = Value,
Expand Down
Loading

0 comments on commit b5d39b0

Please sign in to comment.