{"record":{"id":"0519ccde2584ffb5","repo":"XTLS/Xray-core","slug":"failed-to-create-nameserver","errorCode":null,"errorMessage":"failed to create nameserver","messagePattern":"failed to create nameserver","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/dns/nameserver.go","lineNumber":105,"sourceCode":"\treturn nil, errors.New(\"No available name server could be created from \", dest).AtWarning()\n}\n\n// NewClient creates a DNS client managing a name server with client IP, domain rules and expected IPs.\nfunc NewClient(\n\tctx context.Context,\n\tns *NameServer,\n\tclientIP net.IP,\n\tdisableCache bool, serveStale bool, serveExpiredTTL uint32,\n\ttag string,\n\tipOption dns.IPOption,\n\tupdateRules func(bool),\n) (*Client, error) {\n\tclient := &Client{}\n\terr := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error {\n\t\t// Create a new server for each client for now\n\t\tserver, err := NewServer(ctx, ns.Address.AsDestination(), dispatcher, disableCache, serveStale, serveExpiredTTL, clientIP)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"failed to create nameserver\").Base(err).AtWarning()\n\t\t}\n\n\t\t_, isLocalDNS := server.(*LocalNameServer)\n\t\tupdateRules(isLocalDNS)\n\n\t\t// Establish expected IPs\n\t\tvar expectedMatcher geodata.IPMatcher\n\t\tif len(ns.ExpectedIp) > 0 {\n\t\t\texpectedMatcher, err = geodata.IPReg.BuildIPMatcher(ns.ExpectedIp)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.New(\"failed to create expected ip matcher\").Base(err).AtWarning()\n\t\t\t}\n\t\t}\n\n\t\t// Establish unexpected IPs\n\t\tvar unexpectedMatcher geodata.IPMatcher\n\t\tif len(ns.UnexpectedIp) > 0 {\n\t\t\tunexpectedMatcher, err = geodata.IPReg.BuildIPMatcher(ns.UnexpectedIp)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/app/dns/nameserver.go#L87-L123","documentation":"On a variants-based turn, readPaddingTurn accepts only total lengths equal to one of the configured variants (paddingTurnAcceptsLength compares against each variant's chunk sum). The peer's turn length matched none of them, so the schedules on the two sides disagree: the sender picked a variant the receiver does not know.","triggerScenarios":"Client and server configured with different variant lists (added/removed/reordered variants); peer using sendVariants indices that reference variants absent on this side; only reachable when len(turn.variants) > 0.","commonSituations":"Deploying a new variant set to one endpoint only; typos when duplicating variant JSON between client and server configs; independent 'obfuscation profile' files drifting apart.","solutions":["Copy the identical variants schedule to both peers (same chunk layouts in the same order)","Version the schedule and negotiate/verify it at startup so mismatches fail loudly before traffic","If variants differ intentionally per direction, ensure each side's receive turns list the variants the other side sends"],"exampleFix":"// before (client sends variant lengths 360/520; server only knows 360)\n// server turn: variants [{100,260}]\n// after (server lists both)\n// server turn: variants [{100,260},{100,420}]","handlingStrategy":"validation","validationCode":"// before connecting, confirm the peer's advertised variant lengths are all known locally\nfunc acceptsAll(peerLengths []int, localTurn paddingTurn) bool {\n    for _, l := range peerLengths {\n        if !paddingTurnAcceptsLength(localTurn, l) {\n            return false\n        }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not an allowed variant\") {\n    // schedule skew between peers: re-sync configs, then reconnect\n}","preventionTips":["Distribute one schedule file to both endpoints and pin its version","Include a schedule hash in handshake metadata and fail fast on mismatch","When changing variants, deploy both sides before enabling new traffic"],"tags":["padding","variants","protocol-mismatch","config","xmc"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}