Skip to content

Add ad blocking backed by sing-box ruleset#214

Open
atavism wants to merge 11 commits intomainfrom
atavism/adblock-rule
Open

Add ad blocking backed by sing-box ruleset#214
atavism wants to merge 11 commits intomainfrom
atavism/adblock-rule

Conversation

@atavism
Copy link
Contributor

@atavism atavism commented Nov 19, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 19, 2025 20:18
Copy link
Contributor

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 adds ad blocking functionality backed by sing-box rulesets. The implementation uses a logical gate mechanism to enable/disable ad blocking dynamically, with state persisted to disk.

Key Changes:

  • New AdBlocker component manages ad blocking state using logical gates (AND=disabled, OR=enabled)
  • Integration with sing-box routing rules to block ad-related traffic
  • Public API methods added to Radiance for enabling/disabling ad blocking

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
vpn/adblocker.go Core ad blocking logic with state management and persistence
vpn/adblocker_test.go Comprehensive tests for ad blocker initialization, enable/disable, and persistence
vpn/boxoptions.go Integration of ad block rules into sing-box routing configuration
radiance.go Public API for ad blocking control and AdBlocker initialization
go.mod Promoted miekg/dns and sagernet/sing-tun from indirect to direct dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +160 to +163
adBlocker, err := vpn.NewAdBlocker()
if err != nil {
slog.Error("Unable to create ad blocker", "error", err)
}
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

If vpn.NewAdBlocker() fails, the error is logged but execution continues with a nil adBlocker. This means r.adBlocker will be nil, but the Radiance instance is still created and returned successfully. While the public methods AdBlockEnabled() and SetAdBlockEnabled() do handle nil checks, it would be clearer to either:

  1. Return an error from NewRadiance() if ad blocker initialization is critical, or
  2. Document this behavior explicitly that ad blocking is optional and may be unavailable

Copilot uses AI. Check for mistakes.
@atavism atavism force-pushed the atavism/adblock-rule branch from 4da5b07 to 341f39a Compare November 19, 2025 20:46
@atavism atavism marked this pull request as draft November 19, 2025 20:50
@atavism atavism marked this pull request as ready for review December 16, 2025 14:47
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.

1 participant