handler

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnableToPair         = errors.New("unable to pair")
	ErrMissingSupporterInfo = errors.New("missing supporter info")
)

Functions

func Register added in v0.0.5

func Register(r *mux.Router, opt *Options)

Types

type AuthChecker added in v0.0.5

type AuthChecker func(rw http.ResponseWriter, r *http.Request) bool

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) CreateSession

func (h *Handler) CreateSession(rw http.ResponseWriter, r *http.Request)

CreateSession godoc @Summary Create a session. @Description Create a plexus session where meshagents can connect to. @Tags session @Accept application/x-www-form-urlencoded @Produce application/json @Param id formData string true "session id" @Param ttl formData int true "the time to live for the session" @Param username formData string true "the credentials to open the remote control interface & delete the session" @Param password formData string true "the credentials to open the remote control interface & delete the session" @Param supporter_name formData string true "the supporter name" @Param supporter_avatar formData string true "the supporter avatar" @Success 200 {object} api.Session @Failure 400 {object} api.Error @Failure 500 {object} api.Error @Failure 502 {object} api.Error @Router /session [post]

func (*Handler) DeleteSession

func (h *Handler) DeleteSession(rw http.ResponseWriter, r *http.Request)

DeleteSession godoc @Summary Delete a session. @Tags session @Produce application/json @Param id path string true "session id" @Security BasicAuth @Success 200 {object} api.Result @Failure 400 {object} api.Error @Failure 500 {object} api.Error @Failure 502 {object} api.Error @Router /session/{id} [delete]

func (*Handler) GetAgentMsh

func (h *Handler) GetAgentMsh(rw http.ResponseWriter, r *http.Request)

GetAgentMsh godoc @Summary Gets the meshagent.msh for the given session. @Tags session @Produce text/plain @Param id path string true "session id" @Param token path string true "auth token" @Success 200 {object} string @Failure 400 {object} string @Failure 401 {object} string @Failure 404 {object} string @Failure 500 {object} string @Router /config/{id}:{token} [get]

func (*Handler) Home added in v0.0.6

func (h *Handler) Home(rw http.ResponseWriter, r *http.Request)

func (*Handler) ListSessions added in v0.0.5

func (h *Handler) ListSessions(rw http.ResponseWriter, r *http.Request)

ListSessions godoc @Summary Lists all active session. @Tags session @Produce application/json @Success 200 {array} api.Session @Failure 400 {object} api.Error @Failure 401 {object} api.Error @Failure 500 {object} api.Error @Router /session [get]

func (*Handler) Pair added in v0.0.6

func (h *Handler) Pair(rw http.ResponseWriter, r *http.Request)

Pair godoc @Summary Gets the pairing code info. @Tags session @Produce application/json @Param code path string true "code" @Security BasicAuth @Success 200 {object} api.URLResponse @Failure 401 {object} api.Error @Failure 404 {object} api.Error @Router /pairing/{code} [get]

func (*Handler) ProxyAgent

func (h *Handler) ProxyAgent(rw http.ResponseWriter, r *http.Request)

ProxyAgent godoc @Summary Forwards the agent control requests to the meshcentral server @Tags websocket @Param id path string true "session id" @Param token path string true "the authentication token" @Success 200 {object} string @Router /agent/{id}:{token} [get]

func (*Handler) ProxyMeshCentral added in v0.0.3

func (h *Handler) ProxyMeshCentral() http.Handler

func (*Handler) ProxyMeshCentralURL added in v0.0.3

func (h *Handler) ProxyMeshCentralURL() string

func (*Handler) ProxyRelay

func (h *Handler) ProxyRelay(rw http.ResponseWriter, r *http.Request)

ProxyRelay godoc @Summary Forwards meshagent relay requests to the meshcentral server. @Tags websocket @Success 200 {object} string @Router /meshrelay.ashx [get]

func (*Handler) ShareSession

func (h *Handler) ShareSession(rw http.ResponseWriter, r *http.Request)

ShareSession godoc @Summary Start the remote control on the session via a browser. @Tags session @Produce text/html @Param id path string true "session id" @Security BasicAuth @Success 200 {object} string @Failure 400 {object} api.Error @Failure 401 {object} api.Error @Failure 500 {object} api.Error @Router /session/{id} [get]

func (*Handler) ShareSessionURL

func (h *Handler) ShareSessionURL(rw http.ResponseWriter, r *http.Request)

ShareSessionURL godoc @Summary Gets the meshcentral share session for the session id. @Tags session @Produce application/json @Param id path string true "session id" @Security BasicAuth @Success 200 {object} api.URLResponse @Failure 400 {object} api.Error @Failure 401 {object} api.Error @Failure 500 {object} api.Error @Failure 502 {object} api.Error @Router /session/{id}/url [get]

type Options added in v0.0.5

type Options struct {
	ControlConfig           *control.Config
	PairingConfig           *config.PairingConfig
	Log                     logger.Logger
	Auth                    AuthChecker
	Prefix                  string
	AllowSessionCredentials bool
}

type Request added in v0.0.6

type Request struct {
	URL string `json:"url"`
}

type Response added in v0.0.6

type Response struct {
	Success     bool   `json:"success"`
	Code        string `json:"code"`
	PairingURL  string `json:"pairing_url"`
	RedirectURL string `json:"redirect_url"`
}

type Session

type Session struct {
	ID                 string
	Username, Password string
	ExpiresAt          time.Time
	Token              string
	AgentConfig        api.AgentConfig
	ShareURL           string
	SupporterName      string
	SupporterAvatar    string
	PairingCode        string
	PairingURL         string
	ProxyClose         func()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL