diff --git a/internal/xrayconfig/generator.go b/internal/xrayconfig/generator.go index ef5b17f..fccb71a 100644 --- a/internal/xrayconfig/generator.go +++ b/internal/xrayconfig/generator.go @@ -136,6 +136,19 @@ func replaceClients(root map[string]interface{}, clients []Client) error { return errors.New("template missing inbound entry") } + inbound, ok := inboundsSlice[0].(map[string]interface{}) + if !ok { + return fmt.Errorf("template inbound 0 has unexpected type %T", inboundsSlice[0]) + } + + // Determine if we should include flow based on network + includeFlow := true + if streamSettings, ok := inbound["streamSettings"].(map[string]interface{}); ok { + if network, _ := streamSettings["network"].(string); network == "xhttp" { + includeFlow = false + } + } + clientObjects := make([]interface{}, 0, len(clients)) for idx, client := range clients { id := strings.TrimSpace(client.ID) @@ -148,17 +161,15 @@ func replaceClients(root map[string]interface{}, clients []Client) error { if email := strings.TrimSpace(client.Email); email != "" { entry["email"] = email } - flow := strings.TrimSpace(client.Flow) - if flow == "" { - flow = DefaultFlow - } - entry["flow"] = flow - clientObjects = append(clientObjects, entry) - } - inbound, ok := inboundsSlice[0].(map[string]interface{}) - if !ok { - return fmt.Errorf("template inbound 0 has unexpected type %T", inboundsSlice[0]) + if includeFlow { + flow := strings.TrimSpace(client.Flow) + if flow == "" { + flow = DefaultFlow + } + entry["flow"] = flow + } + clientObjects = append(clientObjects, entry) } settingsValue, ok := inbound["settings"] diff --git a/internal/xrayconfig/template_tcp.json b/internal/xrayconfig/template_tcp.json index 89f4445..881110d 100644 --- a/internal/xrayconfig/template_tcp.json +++ b/internal/xrayconfig/template_tcp.json @@ -20,7 +20,12 @@ "port": 1443, "protocol": "vless", "settings": { - "clients": [], + "clients": [ + { + "id": "{{ UUID }}", + "flow": "xtls-rprx-vision" + } + ], "decryption": "none", "fallbacks": [ { diff --git a/internal/xrayconfig/template_xhttp.json b/internal/xrayconfig/template_xhttp.json index a46f063..762f1bc 100644 --- a/internal/xrayconfig/template_xhttp.json +++ b/internal/xrayconfig/template_xhttp.json @@ -19,7 +19,11 @@ "listen": "/dev/shm/xray.sock,0666", "protocol": "vless", "settings": { - "clients": [], + "clients": [ + { + "id": "{{ UUID }}" + } + ], "decryption": "none" }, "streamSettings": {