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

Method Start

controller/rest/base.go:15–42  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

13}
14
15func (s *Service) Start(w http.ResponseWriter, r *http.Request) {
16 data := &common.Backend{}
17
18 if err := common.ReadProtoBody(r.Body, data); err != nil {
19 http.Error(w, err.Error(), http.StatusBadRequest)
20 return
21 }
22
23 ip, _, err := net.SplitHostPort(r.RemoteAddr)
24 if err != nil {
25 http.Error(w, "unknown ip", http.StatusServiceUnavailable)
26 return
27 }
28
29 if s.Backend() != nil {
30 log.Println("New connection from ", ip, " core control access was taken away from previous client.")
31 s.Disconnect()
32 }
33
34 if err = s.StartBackend(r.Context(), data); err != nil {
35 http.Error(w, err.Error(), http.StatusServiceUnavailable)
36 return
37 }
38
39 s.Connect(ip, data.GetKeepAlive())
40
41 common.SendProtoResponse(w, s.BaseInfoResponse())
42}
43
44func (s *Service) Stop(w http.ResponseWriter, _ *http.Request) {
45 s.Disconnect()

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 9

DisconnectMethod · 0.95
GetKeepAliveMethod · 0.95
ReadProtoBodyFunction · 0.92
SendProtoResponseFunction · 0.92
ErrorMethod · 0.80
BackendMethod · 0.80
StartBackendMethod · 0.80
ConnectMethod · 0.80
BaseInfoResponseMethod · 0.80

Tested by

no test coverage detected