{"record":{"id":"855419f923092c07","repo":"XTLS/Xray-core","slug":"failed-to-convert-address-to-net-ip","errorCode":null,"errorMessage":"Failed to convert address to Net IP.","messagePattern":"Failed to convert address to Net IP\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/dns/config.go","lineNumber":31,"sourceCode":"var localTLDsAndDotlessDomainsRules = []*geodata.DomainRule{\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Regex, Value: \"^[^.]+$\"}}}, // This will only match domains without any dot\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"local\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"localdomain\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"localhost\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"lan\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"home.arpa\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"example\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"invalid\"}}},\n\t{Value: &geodata.DomainRule_Custom{Custom: &geodata.Domain{Type: geodata.Domain_Domain, Value: \"test\"}}},\n}\n\nfunc toNetIP(addrs []net.Address) ([]net.IP, error) {\n\tips := make([]net.IP, 0, len(addrs))\n\tfor _, addr := range addrs {\n\t\tif addr.Family().IsIP() {\n\t\t\tips = append(ips, addr.IP())\n\t\t} else {\n\t\t\treturn nil, errors.New(\"Failed to convert address\", addr, \"to Net IP.\").AtWarning()\n\t\t}\n\t}\n\treturn ips, nil\n}\n\nfunc generateRandomTag() string {\n\tid := uuid.New()\n\treturn \"xray.system.\" + id.String()\n}\n","sourceCodeStart":13,"sourceCodeEnd":41,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/app/dns/config.go#L13-L41","documentation":"For turn 0 with variants, validatePaddingSchedule runs trimPaddingPrefix on every variant to prove the first-turn prefix can be consumed exactly. This error wraps a failure: either the prefix splits a chunk ('prefix length %d splits chunk %d') or it consumes all chunks ('prefix length %d leaves no padding record'). The variant's chunk boundaries must align so that whole chunks cover the prefix and at least one chunk remains for the padding record.","triggerScenarios":"Turn 0 has variants, firstTurnPrefixLength > 0, and some variant's cumulative chunk lengths never equal the prefix exactly (prefix falls mid-chunk, or prefix >= total variant length). Detected during schedule validation before I/O.","commonSituations":"Adding early-data prefix support to an existing variant schedule whose chunk sizes were chosen for traffic shaping, not prefix alignment; changing prefix length without re-cutting the variant chunks; variants of different total lengths where only some align.","solutions":["Re-shape variant chunks so a prefix-boundary subset of chunk lengths sums exactly to firstTurnPrefixLength and at least one chunk follows","Or set firstTurnPrefixLength to a value that already equals a partial sum of every variant's chunk lengths","As a last resort use a range-based (non-variant) first turn, which handles arbitrary prefixes via minLength > prefix"],"exampleFix":"// before: prefix 100 splits the 150-byte first chunk\npaddingVariant{chunks: []int{150, 300}}\n// after: 100 + 50 consumed as prefix-aligned chunks\npaddingVariant{chunks: []int{100, 50, 300}}","handlingStrategy":"validation","validationCode":"func variantFitsPrefix(v paddingVariant, prefix int) bool {\n    remaining, i := prefix, 0\n    for i < len(v.chunks) && remaining > 0 {\n        if remaining < v.chunks[i] {\n            return false\n        }\n        remaining -= v.chunks[i]\n        i++\n    }\n    return remaining == 0 && i < len(v.chunks)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start variant chunk layouts with a chunk exactly equal to the expected prefix","Re-validate turn-0 variants whenever the prefix length changes"],"tags":["padding","config","validation","variants","prefix","xmc"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}