XTLS/Xray-core · error

target not specified

Error message

target not specified

What it means

Thrown by the trojan client's Process when the latest outbound in the session context has no valid Target. Every proxied request must carry a destination; the trojan client dials that destination through the trojan server, so an empty target cannot proceed.

Source

Thrown at proxy/trojan/client.go:52

	server, err := protocol.NewServerSpecFromPB(config.Server)
	if err != nil {
		return nil, errors.New("failed to get server spec").Base(err)
	}

	v := core.MustFromContext(ctx)
	client := &Client{
		server:        server,
		policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
	}
	return client, nil
}

// Process implements OutboundHandler.Process().
func (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
	outbounds := session.OutboundsFromContext(ctx)
	ob := outbounds[len(outbounds)-1]
	if !ob.Target.IsValid() {
		return errors.New("target not specified")
	}
	ob.Name = "trojan"
	ob.CanSpliceCopy = 3
	destination := ob.Target
	network := destination.Network

	server := c.server
	var conn stat.Connection

	err := retry.ExponentialBackoff(5, 100).On(func() error {
		rawConn, err := dialer.Dial(ctx, server.Destination)
		if err != nil {
			return err
		}

		conn = rawConn
		return nil
	})

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Ensure the caller (inbound/dispatcher) sets the destination before dispatch: outbound.Target = net.TCPDestination(addr, port).
  2. If embedding, build the session outbound with a valid Target before calling Process.
  3. Update the fork/launcher to the core version whose Process signature expects Target on the last outbound.

Example fix

// embedding, before
ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{{}})

// after
ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{{
	Target: net.TCPDestination(net.ParseAddress("1.2.3.4"), 80),
}})
Defensive patterns

Strategy: validation

Validate before calling

if !ob.Target.IsValid() {
	return errors.New("refusing to dispatch: no destination set on outbound")
}

Prevention

When it happens

Trigger: Process invoked on a link whose session lacks a dispatcher-assigned destination — e.g. an inbound that forgot to set the target, a direct API call to the outbound handler, or internal requests (DNS over the outbound) missing a target.

Common situations: Custom embedding code dispatching to the trojan outbound without setting outbound.Target; a routing chain bug that strips the target; version skew in session plumbing after upgrading core.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/5ac3d97b731e1047. Report an issue: GitHub.