chore: check fake-ip-range and fake-ip-range6 are indeed ipv4 and ipv6 prefixes
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run

This commit is contained in:
wwqgtxx 2025-10-28 16:23:01 +08:00
parent c8af92a01f
commit cfdaebe952

View File

@ -685,6 +685,8 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
}
config.Hosts = hosts
parseIPV6(rawCfg) // must before DNS and Tun
dnsCfg, err := parseDNS(rawCfg, ruleProviders)
if err != nil {
return nil, err
@ -1417,6 +1419,9 @@ func parseDNS(rawCfg *RawConfig, ruleProviders map[string]providerTypes.RuleProv
if err != nil {
return nil, err
}
if !dnsCfg.FakeIPRange.Addr().Is4() {
return nil, errors.New("dns.fake-ip-range must be a IPv4 prefix")
}
}
if cfg.FakeIPRange6 != "" {
@ -1424,6 +1429,9 @@ func parseDNS(rawCfg *RawConfig, ruleProviders map[string]providerTypes.RuleProv
if err != nil {
return nil, err
}
if !dnsCfg.FakeIPRange6.Addr().Is6() {
return nil, errors.New("dns.fake-ip-range6 must be a IPv6 prefix")
}
}
if cfg.EnhancedMode == C.DNSFakeIP {
@ -1538,17 +1546,20 @@ func parseAuthentication(rawRecords []string) []auth.AuthUser {
return users
}
func parseIPV6(rawCfg *RawConfig) {
if !rawCfg.IPv6 || !verifyIP6() {
rawCfg.DNS.FakeIPRange6 = ""
rawCfg.Tun.Inet6Address = nil
}
}
func parseTun(rawTun RawTun, dns *DNS, general *General) error {
tunAddressPrefix := dns.FakeIPRange
if !tunAddressPrefix.IsValid() || !tunAddressPrefix.Addr().Is4() {
if !tunAddressPrefix.IsValid() {
tunAddressPrefix = netip.MustParsePrefix("198.18.0.1/16")
}
tunAddressPrefix = netip.PrefixFrom(tunAddressPrefix.Addr(), 30)
if !general.IPv6 || !verifyIP6() {
rawTun.Inet6Address = nil
}
general.Tun = LC.Tun{
Enable: rawTun.Enable,
Device: rawTun.Device,