Skip to content

feat: Add loopback connection interception control #1304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ghost
Copy link

@ghost ghost commented Apr 3, 2025

Summary:
This commit introduces a new feature to allow users to control whether OpenSnitch intercepts loopback (localhost) connections. Key changes include:

  1. Configuration Addition:

    • Added InterceptLoopback boolean field in the configuration.
    • Updated default config to include InterceptLoopback: false.
  2. Core Logic Enhancements:

    • Introduced isLoopback helper function to check IP addresses.
    • Modified Parse method in connection.go to respect interceptLoopback flag.
    • Added logic in NewConnection and NewConnection6 to skip loopback connections when interception is disabled.
  3. UI and Client Updates:

    • Added InterceptLoopback checkbox in preferences dialog.
    • Updated client API with InterceptLoopback() method.
    • Adjusted packet handling in main.go to bypass loopback processing when needed.
  4. Testing and Documentation:

    • Updated test configurations to include new setting.
    • Added UI tests for loopback interception preference.

This change enhances network monitoring flexibility, allowing users to focus on external traffic while optionally ignoring local communications.

Summary:
This commit introduces a new feature to allow users to control whether OpenSnitch intercepts loopback (localhost) connections. Key changes include:

1. Configuration Addition:
   - Added `InterceptLoopback` boolean field in the configuration.
   - Updated default config to include `InterceptLoopback: false`.

2. Core Logic Enhancements:
   - Introduced `isLoopback` helper function to check IP addresses.
   - Modified `Parse` method in `connection.go` to respect `interceptLoopback` flag.
   - Added logic in `NewConnection` and `NewConnection6` to skip loopback connections when interception is disabled.

3. UI and Client Updates:
   - Added `InterceptLoopback` checkbox in preferences dialog.
   - Updated client API with `InterceptLoopback()` method.
   - Adjusted packet handling in `main.go` to bypass loopback processing when needed.

4. Testing and Documentation:
   - Updated test configurations to include new setting.
   - Added UI tests for loopback interception preference.

This change enhances network monitoring flexibility, allowing users to focus on external traffic while optionally ignoring local communications.
@ghost
Copy link
Author

ghost commented Apr 3, 2025

Resolves #965

Self Denial added 2 commits April 7, 2025 23:37
…t-in IsLoopback() method directly

This commit removes the unnecessary `isLoopback` helper function since the net.IP type already provides an `IsLoopback()` method. The functionality remains the same but is now more concise and uses
the standard library's built-in functionality instead of a custom implementation.
…dling

This change replaces the `IsLoopback()` method calls with direct comparisons:
- For IPv4 connections, it checks if the first byte of IP address is 127
- For IPv6 connections, it compares the string representation of IP addresses to the standard IPv6 loopback address

These changes make the code more efficient by avoiding method calls and using simple value comparisons instead.
@ghost ghost closed this Apr 25, 2025
@ghost ghost deleted the 1.7.0-loopback-interception branch April 25, 2025 00:21
This pull request was closed.
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.

0 participants