(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func writeMinimalXrayConfig(t *testing.T) string { |
| 121 | t.Helper() |
| 122 | |
| 123 | port := reservePort(t) |
| 124 | dir := t.TempDir() |
| 125 | cfgPath := filepath.Join(dir, "xray.json") |
| 126 | |
| 127 | cfg := fmt.Sprintf(`{ |
| 128 | "log": {"loglevel": "warning"}, |
| 129 | "inbounds": [{ |
| 130 | "listen": "127.0.0.1", |
| 131 | "port": %d, |
| 132 | "protocol": "socks", |
| 133 | "settings": {"auth": "noauth", "udp": false} |
| 134 | }], |
| 135 | "outbounds": [{ |
| 136 | "protocol": "freedom", |
| 137 | "settings": {} |
| 138 | }] |
| 139 | }`, port) |
| 140 | |
| 141 | if err := os.WriteFile(cfgPath, []byte(cfg), 0644); err != nil { |
| 142 | t.Fatalf("failed to write xray config: %v", err) |
| 143 | } |
| 144 | |
| 145 | return cfgPath |
| 146 | } |
| 147 | |
| 148 | func reservePort(t *testing.T) int { |
| 149 | t.Helper() |
no test coverage detected