MCPcopy Index your code
hub / github.com/PasarGuard/node / Start

Method Start

controller/rpc/base.go:12–42  ·  view source on GitHub ↗
(ctx context.Context, data *common.Backend)

Source from the content-addressed store, hash-verified

10)
11
12func (s *Service) Start(ctx context.Context, data *common.Backend) (*common.BaseInfoResponse, error) {
13 clientIP := ""
14 if p, ok := peer.FromContext(ctx); ok {
15 // Extract IP address from peer address
16 if tcpAddr, ok := p.Addr.(*net.TCPAddr); ok {
17 clientIP = tcpAddr.IP.String()
18 } else {
19 // For other address types, extract just the IP without the port
20 addr := p.Addr.String()
21 if host, _, err := net.SplitHostPort(addr); err == nil {
22 clientIP = host
23 } else {
24 // If SplitHostPort fails, use the whole address
25 clientIP = addr
26 }
27 }
28 }
29
30 if s.Backend() != nil {
31 log.Println("New connection from ", clientIP, " core control access was taken away from previous client.")
32 s.Disconnect()
33 }
34
35 if err := s.StartBackend(ctx, data); err != nil {
36 return nil, err
37 }
38
39 s.Connect(clientIP, data.GetKeepAlive())
40
41 return s.BaseInfoResponse(), nil
42}
43
44func (s *Service) Stop(_ context.Context, _ *common.Empty) (*common.Empty, error) {
45 s.Disconnect()

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 7

DisconnectMethod · 0.95
BackendMethod · 0.80
StartBackendMethod · 0.80
ConnectMethod · 0.80
GetKeepAliveMethod · 0.80
BaseInfoResponseMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected