Skip to content

Conversation

@BoBiene
Copy link
Owner

@BoBiene BoBiene commented May 8, 2025

  • ITunnelClientManager um neue Eigenschaften und Ereignisse erweitert.
  • Registrierung des TunnelConnectionListenerFactory als Singleton aktualisiert.
  • Konstruktor von TunnelConnectionListener angepasst, um Protokollierung zu unterstützen.
  • Verbesserte Handhabung von Tunnelverbindungen in AcceptAsync.
  • Aktualisierte Logik zur Verwaltung von Tokenquellen in BindAsync.
  • TunnelConnectionListenerFactory akzeptiert jetzt ILoggerFactory.
  • Hinzugefügte IsEnabled-Eigenschaft im TunnelClientManager zur Statusüberprüfung.

- `ITunnelClientManager` um neue Eigenschaften und Ereignisse erweitert.
- Registrierung des `TunnelConnectionListenerFactory` als Singleton aktualisiert.
- Konstruktor von `TunnelConnectionListener` angepasst, um Protokollierung zu unterstützen.
- Verbesserte Handhabung von Tunnelverbindungen in `AcceptAsync`.
- Aktualisierte Logik zur Verwaltung von Tokenquellen in `BindAsync`.
- `TunnelConnectionListenerFactory` akzeptiert jetzt `ILoggerFactory`.
- Hinzugefügte `IsEnabled`-Eigenschaft im `TunnelClientManager` zur Statusüberprüfung.
@BoBiene BoBiene requested a review from Copilot May 8, 2025 05:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the tunnel client management and listener components by adding new properties, integrating logging support, improving asynchronous handling, and updating dependency injection registrations.

  • Added the IsEnabled property to ITunnelClientManager and its implementation.
  • Updated TunnelConnectionListener and TunnelConnectionListenerFactory to support logging and better token management.
  • Refactored dependency injection registration for TunnelConnectionListenerFactory.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/UFX.Relay/Tunnel/TunnelClientManager.cs Added a new IsEnabled property delegating to _optionsStore.Current.isEnabled.
src/UFX.Relay/Tunnel/Listener/TunnelConnectionListenerFactory.cs Injects ILoggerFactory and passes an ILogger to TunnelConnectionListener.
src/UFX.Relay/Tunnel/Listener/TunnelConnectionListener.cs Updated constructor, improved async handling in AcceptAsync, BindAsync, and UnbindAsync with added logging.
src/UFX.Relay/Tunnel/Listener/ListenerBuilderExtensions.cs Simplified DI registration for TunnelConnectionListenerFactory.
src/UFX.Relay/Abstractions/ITunnelClientManager.cs Extended interface to expose the new IsEnabled property.
Comments suppressed due to low confidence (1)

src/UFX.Relay/Tunnel/Listener/ListenerBuilderExtensions.cs:44

  • Ensure that the dependency injection configuration includes a registration for ILoggerFactory, as TunnelConnectionListenerFactory now requires it in its constructor.
services.TryAddSingleton<TunnelConnectionListenerFactory>();

endpoint.TunnelId = await tunnelIdProvider.GetTunnelIdAsync()
?? throw new KeyNotFoundException("TunnelId not found, you need to configure a tunnel-id");

_ = Task.Run(() => ReconnectTunnelAsync(unbindTokenSource.Token)); // fire-and-forget
Copy link

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider capturing and monitoring the Task returned by Task.Run so that any exceptions from the fire-and-forget operation can be properly handled or logged.

Suggested change
_ = Task.Run(() => ReconnectTunnelAsync(unbindTokenSource.Token)); // fire-and-forget
_ = Task.Run(() => ReconnectTunnelAsync(unbindTokenSource.Token))
.ContinueWith(task =>
{
if (task.Exception is not null)
{
logger.LogError(task.Exception, "An error occurred in ReconnectTunnelAsync.");
}
}, TaskContinuationOptions.OnlyOnFaulted); // Log exceptions if the task faults

Copilot uses AI. Check for mistakes.
- Umbenennung von Variablen und Einführung von privaten Feldern in `TunnelConnectionListener.cs` zur Verbesserung der Lesbarkeit und Kapselung.
- Hinzufügen der `TunnelClientManager`-Eigenschaft in `TunnelEndpoint.cs`, um den Zugriff auf Tunnel zu optimieren.
- Neue Eigenschaften `DelayWhenDisabled` und `DelayWhenDisconnected` in `TunnelListenerOptions.cs` zur besseren Steuerung von Verzögerungen.
- Anpassungen der Fehlerbehandlung in `TunnelClientManager.cs`, um die Robustheit und Protokollierung zu verbessern.
@BoBiene BoBiene requested a review from Copilot May 8, 2025 06:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the Tunnel Client Manager interface and improves the handling and logging of tunnel connections. Key changes include:

  • Addition of the IsEnabled property in ITunnelClientManager and its use in connection management.
  • Refactoring of TunnelConnectionListener for improved connection state handling and logging.
  • Updates to dependency injection registrations for TunnelConnectionListenerFactory.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/UFX.Relay/Tunnel/TunnelClientManager.cs Added IsEnabled property and slight updates to connection error-state handling.
src/UFX.Relay/Tunnel/Listener/TunnelListenerOptions.cs Introduced DelayWhenDisabled and DelayWhenDisconnected options with documentation.
src/UFX.Relay/Tunnel/Listener/TunnelEndpoint.cs Modified Tunnel property to retrieve its value via TunnelClientManager and added TunnelClientManager property.
src/UFX.Relay/Tunnel/Listener/TunnelConnectionListenerFactory.cs Updated constructor signature to include ILoggerFactory and changed how the listener is instantiated accordingly.
src/UFX.Relay/Tunnel/Listener/TunnelConnectionListener.cs Refactored connection acceptance, binding, unbinding, and disposal logic with improved logging.
src/UFX.Relay/Tunnel/Listener/ListenerBuilderExtensions.cs Simplified registration of TunnelConnectionListenerFactory in DI.
src/UFX.Relay/Abstractions/ITunnelClientManager.cs Added the IsEnabled property to support status monitoring.
Comments suppressed due to low confidence (1)

src/UFX.Relay/Tunnel/Listener/ListenerBuilderExtensions.cs:44

  • Ensure that all required dependencies for TunnelConnectionListenerFactory (such as ILoggerFactory) are registered in the DI container.
services.TryAddSingleton<TunnelConnectionListenerFactory>();

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BoBiene BoBiene merged commit 81b80f0 into main May 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants