Skip to content

Commit

Permalink
Rename Traking proprties
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Dec 10, 2021
1 parent 418ab20 commit fcf76d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions VpnHood.Server.Access/TrackingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace VpnHood.Server
{
public class TrackingOptions
{
public bool LocalPort { get; set; }
public bool ClientIp { get; set; }
public bool LogLocalPort { get; set; }
public bool LogClientIp { get; set; }

public bool IsEnabled() => ClientIp || LocalPort;
public bool IsEnabled() => LogClientIp || LogLocalPort;
}
}
2 changes: 1 addition & 1 deletion VpnHood.Server/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected override UdpClient CreateUdpClient(AddressFamily addressFamily)
var udpClient = _session._socketFactory.CreateUdpClient(addressFamily);

//tracking
if (_trackingOptions.LocalPort)
if (_trackingOptions.LogLocalPort)
{
var log = $"Udp | SessionId: {_session.SessionId}, Port: {((IPEndPoint)udpClient.Client.LocalEndPoint).Port}";
VhLogger.Instance.LogInformation(GeneralEventId.Track, log);
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Server/TcpHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private async Task ProcessHello(TcpClientStream tcpClientStream, CancellationTok
//tracking
if (_sessionManager.TrackingOptions.IsEnabled())
{
var clientIp = _sessionManager.TrackingOptions.ClientIp ? clientEndPoint.Address.ToString() : "*";
var clientIp = _sessionManager.TrackingOptions.LogClientIp ? clientEndPoint.Address.ToString() : "*";
var log = $"New Session | SessionId: {session.SessionId}, TokenId: {request.TokenId}, ClientIp: {clientIp}";
VhLogger.Instance.LogInformation(GeneralEventId.Track, log);
}
Expand Down Expand Up @@ -342,7 +342,7 @@ private async Task ProcessTcpProxyChannel(TcpClientStream tcpClientStream, Cance
Util.TcpClient_SetKeepAlive(tcpClient2, true);

//tracking
if (_sessionManager.TrackingOptions.LocalPort)
if (_sessionManager.TrackingOptions.LogLocalPort)
{
var log = $"Tcp | SessionId: {session.SessionId}, Port: {((IPEndPoint)tcpClient2.Client.LocalEndPoint).Port}";
VhLogger.Instance.LogInformation(GeneralEventId.Track, log);
Expand Down
4 changes: 4 additions & 0 deletions VpnHood.ZTest/Tests/ServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public async Task Reconfigure()
var fileAccessServerOptions = new FileAccessServerOptions { TcpEndPoints = new[] { serverEndPoint } };
using var fileAccessServer = TestHelper.CreateFileAccessServer(fileAccessServerOptions);
fileAccessServer.ServerConfig.UpdateStatusInterval = 1;
fileAccessServer.ServerConfig.TrackingOptions.LogClientIp = true;
fileAccessServer.ServerConfig.TrackingOptions.LogLocalPort = true;
using var testAccessServer = new TestAccessServer(fileAccessServer);

var dateTime = DateTime.Now;
Expand All @@ -37,6 +39,8 @@ public async Task Reconfigure()
await Task.Delay(2500);
Assert.IsNull(testAccessServer.ConfigCode);
Assert.IsTrue(testAccessServer.LastConfigureTime > dateTime);
Assert.IsTrue(server.SessionManager.TrackingOptions.LogClientIp);
Assert.IsTrue(server.SessionManager.TrackingOptions.LogLocalPort);
}

[TestMethod]
Expand Down

0 comments on commit fcf76d2

Please sign in to comment.