MCPcopy Create free account
hub / github.com/PasarGuard/node / writeMinimalXrayConfig

Function writeMinimalXrayConfig

backend/xray/process_unix_test.go:120–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func 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
148func reservePort(t *testing.T) int {
149 t.Helper()

Callers 1

startXrayProcessFunction · 0.85

Calls 1

reservePortFunction · 0.85

Tested by

no test coverage detected