Skip to content

Fix private IP address filtering in DNS validation#16

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/check-logic-for-segment-10
Closed

Fix private IP address filtering in DNS validation#16
Copilot wants to merge 4 commits into
mainfrom
copilot/check-logic-for-segment-10

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 19, 2025

Private IP addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) were being incorrectly rejected by primary DNS servers because they're not in the China IP list used for geographic validation.

Changes

  • Added isPrivateIP() helper to detect RFC 1918 IPv4 ranges and fc00::/7 IPv6 ULA
  • Modified IsValidMsg() to skip geographic validation for private IPs - they're always valid regardless of DNS source
  • Added test coverage for private IP detection and DNS message validation with private addresses
// Before: Private IPs from primary DNS would fail validation
// because ipRanger.Contains(10.0.0.1) returns false

// After: Private IPs bypass geographic checks
if isPrivateIP(ip) {
    up.logger.Printf("checkPrimary result %s: %s@%s -> private IP, skipping primary check", up.Address, domain, ip)
    continue
}

Internal network addresses are not subject to geographic routing restrictions and should always be accepted.

Original prompt

检查是否有逻辑丢弃了10.段的解析结果


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 19, 2025
@naiba
Copy link
Copy Markdown
Owner

naiba commented Dec 19, 2025

是解析10.x.x.x IP段 @copilot

Copilot AI and others added 3 commits December 19, 2025 07:00
…s from being dropped

Co-authored-by: naiba <29243953+naiba@users.noreply.github.com>
Co-authored-by: naiba <29243953+naiba@users.noreply.github.com>
Co-authored-by: naiba <29243953+naiba@users.noreply.github.com>
Copilot AI changed the title [WIP] Check for logic missing in segment 10 parsing Fix private IP address filtering in DNS validation Dec 19, 2025
Copilot AI requested a review from naiba December 19, 2025 07:04
Copy link
Copy Markdown
Owner

@naiba naiba left a comment

Choose a reason for hiding this comment

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

我不是希望你过滤掉而是希望你不要过滤

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