MCPcopy
hub / github.com/MHSanaei/3x-ui / AddOutbound

Method AddOutbound

internal/xray/api.go:175–197  ·  view source on GitHub ↗

AddOutbound adds a new outbound configuration to the Xray core via gRPC.

(outbound []byte)

Source from the content-addressed store, hash-verified

173
174// AddOutbound adds a new outbound configuration to the Xray core via gRPC.
175func (x *XrayAPI) AddOutbound(outbound []byte) error {
176 if x.HandlerServiceClient == nil {
177 return common.NewError("xray HandlerServiceClient is not initialized")
178 }
179 client := *x.HandlerServiceClient
180
181 conf := new(conf.OutboundDetourConfig)
182 if err := json.Unmarshal(outbound, conf); err != nil {
183 logger.Debug("Failed to unmarshal outbound:", err)
184 return err
185 }
186 config, err := conf.Build()
187 if err != nil {
188 logger.Debug("Failed to build outbound detour:", err)
189 return err
190 }
191
192 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
193 defer cancel()
194
195 _, err = client.AddOutbound(ctx, &command.AddOutboundRequest{Outbound: config})
196 return err
197}
198
199// DelOutbound removes an outbound configuration from the Xray core by tag.
200func (x *XrayAPI) DelOutbound(tag string) error {

Callers 2

TestXrayAPI_E2EFunction · 0.95
addOutboundReconcilingFunction · 0.80

Calls 2

NewErrorFunction · 0.92
DebugFunction · 0.92

Tested by 1

TestXrayAPI_E2EFunction · 0.76