{"record":{"id":"3e620b429551384f","repo":"XTLS/Xray-core","slug":"target-not-specified","errorCode":null,"errorMessage":"target not specified.","messagePattern":"target not specified\\.","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"proxy/freedom/freedom.go","lineNumber":254,"sourceCode":"\t}\n\treturn time.Duration(min+uint64(dice.Roll(int(span+1)))) * time.Second\n}\n\nfunc isValidAddress(addr *net.IPOrDomain) bool {\n\tif addr == nil {\n\t\treturn false\n\t}\n\n\ta := addr.AsAddress()\n\treturn a != net.AnyIP && a != net.AnyIPv6\n}\n\n// Process implements proxy.Outbound.\nfunc (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {\n\toutbounds := session.OutboundsFromContext(ctx)\n\tob := outbounds[len(outbounds)-1]\n\tif !ob.Target.IsValid() {\n\t\treturn errors.New(\"target not specified.\")\n\t}\n\tob.Name = \"freedom\"\n\tob.CanSpliceCopy = 1\n\tinbound := session.InboundFromContext(ctx)\n\tdefaultRule := getDefaultFinalRule(inbound)\n\n\tdestination := ob.Target\n\torigTargetAddr := ob.OriginalTarget.Address\n\tif origTargetAddr == nil {\n\t\torigTargetAddr = ob.Target.Address\n\t}\n\tdialer.SetOutboundGateway(ctx, ob)\n\toutGateway := ob.Gateway\n\tUDPOverride := net.UDPDestination(nil, 0)\n\tif h.config.DestinationOverride != nil {\n\t\tserver := h.config.DestinationOverride.Server\n\t\tif isValidAddress(server.Address) {\n\t\t\tdestination.Address = server.Address.AsAddress()","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/freedom/freedom.go#L236-L272","documentation":"The freedom outbound's Process found the last outbound object in the session context has an invalid Target (no address, no port, or zero network). Freedom is a direct-dial outbound: it must know exactly where to connect, so it refuses to proceed without a valid destination.","triggerScenarios":"Routing/dispatcher hands freedom a session whose outbound.Target was never set — e.g. an inbound produced a connection with no parsed destination, or a custom dispatcher/chain created an Outbound without calling SetTarget. Calling freedom via a chain where the preceding hop failed to propagate the target also triggers it.","commonSituations":"Misconfigured routing rule that forwards opaque/internal traffic to freedom; a dokodemo/transparent inbound where the original destination could not be recovered (SO_ORIGINAL_DST missing); third-party outbound handlers that skip ob.Target assignment.","solutions":["Verify the inbound actually resolves the destination (e.g. transparent proxy iptables/nftables rules are correct so original dst is available)","Check routing rules: do not route traffic without a valid target (e.g. internal/broadcast destinations) to freedom","If you build outbounds programmatically, set ob.Target via outbound.SetTarget(destination) before dispatching to freedom"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"```go\nob := session.OutboundsFromContext(ctx)\ntail := ob[len(ob)-1]\nif !tail.Target.IsValid() {\n    // route elsewhere / return 4xx before reaching freedom\n}\n```","typeGuard":"```go\nfunc hasValidTarget(ctx context.Context) bool {\n    obs := session.OutboundsFromContext(ctx)\n    return len(obs) > 0 && obs[len(obs)-1].Target.IsValid()\n}\n```","tryCatchPattern":null,"preventionTips":["Do not route target-less internal traffic to freedom","Verify transparent-proxy original-dst recovery works","Always SetTarget on programmatic outbounds"],"tags":["freedom","session","target","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}