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

Method startHomeSubscriber

sdk/cliproxy/service.go:1549–1594  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1547}
1548
1549func (s *Service) startHomeSubscriber(ctx context.Context) {
1550 if s == nil {
1551 return
1552 }
1553 s.cfgMu.RLock()
1554 cfg := s.cfg
1555 s.cfgMu.RUnlock()
1556 if cfg == nil || !cfg.Home.Enabled {
1557 return
1558 }
1559
1560 if s.homeCancel != nil {
1561 s.homeCancel()
1562 s.homeCancel = nil
1563 }
1564 if s.homeClient != nil {
1565 s.homeClient.Close()
1566 s.homeClient = nil
1567 }
1568 if s.homeLogForwarder != nil {
1569 s.homeLogForwarder.Stop()
1570 s.homeLogForwarder = nil
1571 }
1572
1573 homeCtx := ctx
1574 if homeCtx == nil {
1575 homeCtx = context.Background()
1576 }
1577 homeCtx, cancel := context.WithCancel(homeCtx)
1578 s.homeCancel = cancel
1579
1580 client := home.New(cfg.Home)
1581 s.homeClient = client
1582 home.SetCurrent(client)
1583
1584 go client.StartConfigSubscriber(homeCtx, func(raw []byte) error {
1585 parsed, err := config.ParseConfigBytes(raw)
1586 if err != nil {
1587 log.Warnf("failed to parse home config payload: %v", err)
1588 return err
1589 }
1590 return s.applyHomeOverlayContext(homeCtx, parsed)
1591 })
1592 s.startHomeUsageForwarder(homeCtx, client)
1593 s.homeLogForwarder = logging.StartHomeAppLogForwarder(0)
1594}
1595
1596// Run starts the service and blocks until the context is cancelled or the server stops.
1597// It initializes all components including authentication, file watching, HTTP server,

Callers 2

RunMethod · 0.95

Calls 9

NewFunction · 0.92
SetCurrentFunction · 0.92
ParseConfigBytesFunction · 0.92
StartHomeAppLogForwarderFunction · 0.92
StartConfigSubscriberMethod · 0.80
CloseMethod · 0.65
StopMethod · 0.65