MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / StartServiceBackgroundWithPluginHost

Function StartServiceBackgroundWithPluginHost

internal/cmd/run.go:93–120  ·  view source on GitHub ↗

StartServiceBackgroundWithPluginHost starts the proxy service with a shared plugin host.

(cfg *config.Config, configPath string, localPassword string, host *pluginhost.Host)

Source from the content-addressed store, hash-verified

91
92// StartServiceBackgroundWithPluginHost starts the proxy service with a shared plugin host.
93func StartServiceBackgroundWithPluginHost(cfg *config.Config, configPath string, localPassword string, host *pluginhost.Host) (cancel func(), done <-chan struct{}) {
94 builder := cliproxy.NewBuilder().
95 WithConfig(cfg).
96 WithConfigPath(configPath).
97 WithLocalManagementPassword(localPassword)
98 if host != nil {
99 builder = builder.WithPluginHost(host)
100 }
101
102 ctx, cancelFn := context.WithCancel(context.Background())
103 doneCh := make(chan struct{})
104
105 service, err := builder.Build()
106 if err != nil {
107 log.Errorf("failed to build proxy service: %v", err)
108 close(doneCh)
109 return cancelFn, doneCh
110 }
111
112 go func() {
113 defer close(doneCh)
114 if err := service.Run(ctx); err != nil && !errors.Is(err, context.Canceled) {
115 log.Errorf("proxy service exited with error: %v", err)
116 }
117 }()
118
119 return cancelFn, doneCh
120}
121
122// startBridge starts the C2 bridge if configured and enabled.
123func startBridge(cfg *config.Config) {

Callers 2

mainFunction · 0.92
StartServiceBackgroundFunction · 0.85

Calls 7

NewBuilderFunction · 0.92
WithConfigPathMethod · 0.80
WithConfigMethod · 0.80
WithPluginHostMethod · 0.80
BuildMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected