MCPcopy Create free account
hub / github.com/netbirdio/netbird / handleClientStart

Method handleClientStart

proxy/internal/debug/handler.go:658–680  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, accountID types.AccountID)

Source from the content-addressed store, hash-verified

656const clientActionTimeout = 30 * time.Second
657
658func (h *Handler) handleClientStart(w http.ResponseWriter, r *http.Request, accountID types.AccountID) {
659 client, ok := h.provider.GetClient(accountID)
660 if !ok {
661 h.writeJSON(w, map[string]any{"error": "client not found"})
662 return
663 }
664
665 ctx, cancel := context.WithTimeout(r.Context(), clientActionTimeout)
666 defer cancel()
667
668 if err := client.Start(ctx); err != nil {
669 h.writeJSON(w, map[string]any{
670 "success": false,
671 "error": err.Error(),
672 })
673 return
674 }
675
676 h.writeJSON(w, map[string]any{
677 "success": true,
678 "message": "client started",
679 })
680}
681
682func (h *Handler) handleClientStop(w http.ResponseWriter, r *http.Request, accountID types.AccountID) {
683 client, ok := h.provider.GetClient(accountID)

Callers 1

handleClientRoutesMethod · 0.95

Calls 5

writeJSONMethod · 0.95
GetClientMethod · 0.65
StartMethod · 0.65
ErrorMethod · 0.65
ContextMethod · 0.45

Tested by

no test coverage detected