api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V0Prefix = "/api/v0/"

	// Peers
	GetKnownPeersPath        = V0Prefix + "peers/get_known"
	GetKnownPeerSettingsPath = V0Prefix + "peers/get_known_peer_settings"
	UpdatePeerSettingsPath   = V0Prefix + "peers/update_settings"
	RemovePeerSettingsPath   = V0Prefix + "peers/remove"

	GetBlockedPeersPath = V0Prefix + "peers/get_blocked"

	SendFriendRequestPath    = V0Prefix + "peers/invite_peer"
	AcceptPeerInvitationPath = V0Prefix + "peers/accept_peer"
	GetAuthRequestsPath      = V0Prefix + "peers/auth_requests"

	// Settings
	GetMyPeerInfoPath      = V0Prefix + "settings/peer_info"
	UpdateMyInfoPath       = V0Prefix + "settings/update"
	ExportServerConfigPath = V0Prefix + "settings/export_server_config"

	// Debug
	GetP2pDebugInfoPath = V0Prefix + "debug/p2p_info"
	GetDebugLogPath     = V0Prefix + "debug/log"
)
View Source
const ErrorPeerAliasIsNotUniq = "peer name is not unique"

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSService

type DNSService interface {
	AwlDNSAddress() string
	IsAwlDNSSetAsSystem() bool
}

type Error

type Error struct {
	Message string `json:"error"`
}

func ErrorMessage

func ErrorMessage(message string) Error

func (Error) Error

func (e Error) Error() string

type Handler

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

func NewHandler

func NewHandler(conf *config.Config, p2p *p2p.P2p, authStatus *service.AuthStatus,
	tunnel *service.Tunnel, logBuffer *ringbuffer.RingBuffer, dns DNSService) *Handler

func (*Handler) AcceptFriend

func (h *Handler) AcceptFriend(c echo.Context) (err error)

@Tags Peers @Summary Accept new peer's invitation @Accept json @Produce json @Param body body entity.FriendRequestReply true "Params" @Success 200 "OK" @Failure 400 {object} api.Error @Failure 500 {object} api.Error @Router /peers/accept_peer [POST]

func (*Handler) Address

func (h *Handler) Address() string

func (*Handler) ExportServerConfiguration

func (h *Handler) ExportServerConfiguration(c echo.Context) (err error)

@Tags Settings @Summary Export server configuration @Accept json @Produce json @Success 200 {object} config.Config @Router /settings/export_server_config [GET]

func (*Handler) GetAuthRequests

func (h *Handler) GetAuthRequests(c echo.Context) (err error)

@Tags Peers @Summary Get ingoing auth requests @Accept json @Produce json @Success 200 {array} entity.AuthRequest @Router /peers/auth_requests [GET]

func (*Handler) GetBlockedPeers

func (h *Handler) GetBlockedPeers(c echo.Context) (err error)

@Tags Peers @Summary Get blocked peers info @Accept json @Produce json @Success 200 {array} config.BlockedPeer @Router /peers/get_blocked [GET]

func (*Handler) GetKnownPeerSettings

func (h *Handler) GetKnownPeerSettings(c echo.Context) (err error)

@Tags Peers @Summary Get known peer settings @Accept json @Produce json @Param body body entity.PeerIDRequest true "Params" @Success 200 {object} config.KnownPeer @Failure 400 {object} api.Error @Failure 404 {object} api.Error @Router /peers/get_known_peer_settings [POST]

func (*Handler) GetKnownPeers

func (h *Handler) GetKnownPeers(c echo.Context) (err error)

@Tags Peers @Summary Get known peers info @Accept json @Produce json @Success 200 {array} entity.KnownPeersResponse @Router /peers/get_known [GET]

func (*Handler) GetLog

func (h *Handler) GetLog(c echo.Context) (err error)

@Tags Debug @Summary Get logs @Param logs query int false "Define number of rows of logs to output. On default and 0 prints all." @Param from_head query bool false "Print logs from the beginning of logs" @Produce plain @Success 200 {string} string "log text" @Router /debug/log [GET]

func (*Handler) GetMyPeerInfo

func (h *Handler) GetMyPeerInfo(c echo.Context) (err error)

@Tags Settings @Summary Get my peer info @Accept json @Produce json @Success 200 {object} entity.PeerInfo @Router /settings/peer_info [GET]

func (*Handler) GetP2pDebugInfo

func (h *Handler) GetP2pDebugInfo(c echo.Context) (err error)

@Tags Debug @Summary Get p2p debug info @Produce json @Success 200 {object} entity.P2pDebugInfo @Router /debug/p2p_info [GET]

func (*Handler) RemovePeer

func (h *Handler) RemovePeer(c echo.Context) (err error)

@Tags Peers @Summary Remove known peer @Accept json @Produce json @Param body body entity.PeerIDRequest true "Params" @Success 200 "OK" @Failure 400 {object} api.Error @Failure 404 {object} api.Error @Router /peers/remove [POST]

func (*Handler) SendFriendRequest

func (h *Handler) SendFriendRequest(c echo.Context) (err error)

@Tags Peers @Summary Invite new peer @Accept json @Produce json @Param body body entity.FriendRequest true "Params" @Success 200 "OK" @Failure 400 {object} api.Error @Failure 500 {object} api.Error @Router /peers/invite_peer [POST]

func (*Handler) SetupAPI

func (h *Handler) SetupAPI() error

func (*Handler) SetupFrontend

func (h *Handler) SetupFrontend(fsys fs.FS)

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context) error

func (*Handler) UpdateMySettings

func (h *Handler) UpdateMySettings(c echo.Context) (err error)

@Tags Settings @Summary Update my peer info @Accept json @Produce json @Param body body entity.UpdateMySettingsRequest true "Params" @Success 200 "OK" @Router /settings/update [POST]

func (*Handler) UpdatePeerSettings

func (h *Handler) UpdatePeerSettings(c echo.Context) (err error)

@Tags Peers @Summary Update peer settings @Accept json @Produce json @Param body body entity.UpdatePeerSettingsRequest true "Params" @Success 200 "OK" @Failure 400 {object} api.Error @Failure 404 {object} api.Error @Router /peers/update_settings [POST]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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