http

package
v0.0.0-...-9ac8f15 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitrateFormatter

func BitrateFormatter(v float64) string

func EligibleSpeedtestsForChartView

func EligibleSpeedtestsForChartView(speedtests []models.Speedtest) []models.Speedtest

func ExtractHost

func ExtractHost(ectx echo.Context) string

func ExtractPort

func ExtractPort(ectx echo.Context) string

func ExtractReverseProxyIP

func ExtractReverseProxyIP(ectx echo.Context) string

func FromRedirectWithError

func FromRedirectWithError(ectx echo.Context) (error, bool)

Tries to extract an error that may have originated from a self redirect.

func GetEnv

func GetEnv(key string, fallback func() string) string

func GetLastVisitedPath

func GetLastVisitedPath(ectx echo.Context) (string, error)

Tries to get the last visited path that is present inside a cookie.

func InjectServiceContainer

func InjectServiceContainer(
	ctx context.Context,
	container ServiceContainer,
) context.Context

func IsBindToUnspecified

func IsBindToUnspecified(ectx echo.Context) bool

Checks if the server is bind to an unspecified address (e.g., 0.0.0.0)

func IsLocalRequest

func IsLocalRequest(ectx echo.Context) bool

func IsReverseProxyRequest

func IsReverseProxyRequest(ectx echo.Context) bool

func NewCookie

func NewCookie(
	ectx echo.Context,
	name string,
	value string,
	path string,
	expiry time.Time,
) *http.Cookie

func NewWsConn

func NewWsConn(conn *websocket.Conn) *wsConn

func RawURL

func RawURL(ectx echo.Context, host string, path string, query map[string]string) *url.URL

Composes a raw url. Host must be in the address format (<host>:<port>).

func RedirectWithError

func RedirectWithError(ectx echo.Context, err error) error

Self redirects and appends an error uuid to the url.

func RegisterHandlers

func RegisterHandlers(e *echo.Echo)

func RegisterMiddlewares

func RegisterMiddlewares(e *echo.Echo, ctx context.Context)

func RegisterStaticFiles

func RegisterStaticFiles(e *echo.Echo, fs fs.FS) error

func RegisterTemplates

func RegisterTemplates(e *echo.Echo, fs fs.FS) error

func RenderString

func RenderString(ectx echo.Context, tpl string, v any) (string, error)

func ServerAddress

func ServerAddress(ectx echo.Context) string

func SetLastVisitedPathCookie

func SetLastVisitedPathCookie(ectx echo.Context)

Sets a cookie with the current request url path.

func SetVirtualHost

func SetVirtualHost(host string)

func Start

func Start(e *echo.Echo, host string, port string) error

func StartTLS

func StartTLS(e *echo.Echo, host string, port string, certfilepath string, keyfilepath string) error

func StoreHandlerError

func StoreHandlerError(err error) string

func TimeFormatter

func TimeFormatter(v float64) string

func URL

func URL(ectx echo.Context, path string, query map[string]string) *url.URL

Composes an URL relative to the server host.

func UnsetLastVisitedPathCookie

func UnsetLastVisitedPathCookie(ectx echo.Context)

Unsets the last visited path cookie

func WithVirtualHost

func WithVirtualHost(path string) string

Types

type AxisView

type AxisView struct {
	Min    float64
	Max    float64
	Legend string
}

func NewAxisView

func NewAxisView(
	min, max float64,
	legend string,
) AxisView

type Breakpoint

type Breakpoint int
const (
	MobileBreakpoint  Breakpoint = 560
	TabletBreakpoint  Breakpoint = 860
	DesktopBreakpoint Breakpoint = 1440
)

func ExtractBreakpoint

func ExtractBreakpoint(ectx echo.Context) (Breakpoint, bool)

func (Breakpoint) ChartSize

func (bp Breakpoint) ChartSize() (int, int)

func (Breakpoint) Desktop

func (bp Breakpoint) Desktop() bool

func (Breakpoint) Mobile

func (bp Breakpoint) Mobile() bool

func (Breakpoint) Tablet

func (bp Breakpoint) Tablet() bool

type ChartView

type ChartView interface {
	SVG(width, height int) string
}

type ContextView

type ContextView struct {
	echo.Context
}

func NewContextView

func NewContextView(
	ctx echo.Context,
) ContextView

func (ContextView) Breakpoint

func (v ContextView) Breakpoint() Breakpoint

func (ContextView) HasAdminRights

func (v ContextView) HasAdminRights() bool

type DashboardNetworkInviteLinkView

type DashboardNetworkInviteLinkView struct {
	Code models.JoinNetworkCode
	URL  string
}

func NewDashNetworkInviteLinkView

func NewDashNetworkInviteLinkView(
	url string,
	code models.JoinNetworkCode,
) DashboardNetworkInviteLinkView

func (DashboardNetworkInviteLinkView) Expiry

func (DashboardNetworkInviteLinkView) String

type DashboardView

type DashboardView struct {
	ContextView
	InviteLink DashboardNetworkInviteLinkView
}

func NewDashboardView

func NewDashboardView() DashboardView
func (v DashboardView) ShowInviteLink() bool

func (DashboardView) WithContext

func (v DashboardView) WithContext(ctx echo.Context) DashboardView
func (v DashboardView) WithInviteLink(
	inviteLink DashboardNetworkInviteLinkView,
) DashboardView

type ElementView

type ElementView struct {
	ID    string
	Value string
}

func NewElementView

func NewElementView(
	id string,
	value string,
) ElementView

func NewSpeedtestDownloadElementView

func NewSpeedtestDownloadElementView(
	download models.BitRate,
) ElementView

func NewSpeedtestLatencyElementView

func NewSpeedtestLatencyElementView(
	latency models.Duration,
) ElementView

func NewSpeedtestStatusElementView

func NewSpeedtestStatusElementView(
	status string,
) ElementView

func NewSpeedtestUploadElementView

func NewSpeedtestUploadElementView(
	upload models.BitRate,
) ElementView

type FormFieldView

type FormFieldView interface {
	ID() string
	Label() string
	Tooltip() string
	Type() string
	IsRanged() bool
}

type FormView

type FormView struct {
	Groups map[string][]FormFieldView
	// contains filtered or unexported fields
}

func NewFormView

func NewFormView(
	groups map[string][]FormFieldView,
) FormView

func (FormView) FieldById

func (v FormView) FieldById(id string) (FormFieldView, error)

func (FormView) Update

func (v FormView) Update(data url.Values) (FormView, error)

type LineChartView

type LineChartView struct {
	Lines []LineView
	X     AxisView
	Y     AxisView
}

func NewLineChartView

func NewLineChartView(
	lines []LineView,
	xaxis AxisView,
	yaxis AxisView,
) LineChartView

func (LineChartView) SVG

func (v LineChartView) SVG(width, height int) string

type LineView

type LineView struct {
	XValues         []float64
	YValues         []float64
	XFormatter      func(float64) string
	YFormatter      func(float64) string
	TooltipProvider func(int) string
	Legend          string
}

func NewLineView

func NewLineView(
	legend string,
	xvalues []float64,
	yvalues []float64,
	xformatter func(float64) string,
	yFormatter func(float64) string,
	tooltipProvider func(int) string,
) LineView

type MetaFormFieldView

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

func (MetaFormFieldView) ID

func (v MetaFormFieldView) ID() string

func (MetaFormFieldView) IsRanged

func (v MetaFormFieldView) IsRanged() bool

func (MetaFormFieldView) Label

func (v MetaFormFieldView) Label() string

func (MetaFormFieldView) Tooltip

func (v MetaFormFieldView) Tooltip() string

func (MetaFormFieldView) Type

func (v MetaFormFieldView) Type() string

type NetworkConnectionEndpointView

type NetworkConnectionEndpointView struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

func NewNetworkConnectionEndpointView

func NewNetworkConnectionEndpointView(
	host string,
	port int,
) NetworkConnectionEndpointView

type NetworkJoinView

type NetworkJoinView struct {
	PublicKeyURL          string `json:"public_key_url"`
	ConnectionEndpointURL string `json:"connection_url"`
}

func NewNetworkJoinView

func NewNetworkJoinView(
	publicKeyUrl string,
	connectionEndpointUrl string,
) NetworkJoinView

type NetworkNodeActionsView

type NetworkNodeActionsView struct {
	NodeView
	Remove bool
	Err    error
}

func NewNetworkNodeActionsView

func NewNetworkNodeActionsView(
	node models.Node,
	remove bool,
	err error,
) NetworkNodeActionsView

type NetworkNodeConnectionsView

type NetworkNodeConnectionsView struct {
	NodeView
	Connections           []models.Connection
	ExposedTCPConnections []models.Connection
	ExposedUDPConnections []models.Connection
	Err                   error
}

func NewNetworkNodeConnectionsView

func NewNetworkNodeConnectionsView(
	node models.Node,
	connections []models.Connection,
	err error,
) NetworkNodeConnectionsView

type NetworkNodeInformationView

type NetworkNodeInformationView struct {
	ContextView
	NodeView
}

func NewNetworkNodeInformationView

func NewNetworkNodeInformationView(
	ctx echo.Context,
	node models.Node,
) NetworkNodeInformationView

type NetworkNodePackagesView

type NetworkNodePackagesView struct {
	NodeView
	Packages []models.Package
	Err      error
}

func NewNetworkNodePackagesView

func NewNetworkNodePackagesView(
	node models.Node,
	packages []models.Package,
	err error,
) NetworkNodePackagesView

type NetworkNodeProcessesView

type NetworkNodeProcessesView struct {
	NodeView
	Processes []models.Process
	Err       error
}

func NewNetworkNodeProcessesView

func NewNetworkNodeProcessesView(
	node models.Node,
	processes []models.Process,
	err error,
) NetworkNodeProcessesView

func (NetworkNodeProcessesView) CPU

func (NetworkNodeProcessesView) Memory

func (v NetworkNodeProcessesView) Memory() string

type NetworkNodeSpeedtestHistoryView

type NetworkNodeSpeedtestHistoryView struct {
	NodeView
	ContextView
	Speedtests []SpeedtestView
	Chart      *SpeedtestHistoryChartView
	Err        error
	Limit      int
}

func NewNetworkNodeSpeedtestHistoryView

func NewNetworkNodeSpeedtestHistoryView(
	ctx echo.Context,
	node models.Node,
	speedtests []models.Speedtest,
	limit int,
	err error,
) NetworkNodeSpeedtestHistoryView

func (NetworkNodeSpeedtestHistoryView) AverageDownloadSpeed

func (v NetworkNodeSpeedtestHistoryView) AverageDownloadSpeed() string

func (NetworkNodeSpeedtestHistoryView) AverageUploadSpeed

func (v NetworkNodeSpeedtestHistoryView) AverageUploadSpeed() string

func (NetworkNodeSpeedtestHistoryView) PeakDownloadSpeedtest

func (v NetworkNodeSpeedtestHistoryView) PeakDownloadSpeedtest() SpeedtestView

type NetworkNodeSpeedtestView

type NetworkNodeSpeedtestView struct {
	NodeView
	Speedtest SpeedtestView
	Err       error
}

func NewNetworkNodeSpeedtestView

func NewNetworkNodeSpeedtestView(
	node models.Node,
	speedtest models.Speedtest,
	err error,
) NetworkNodeSpeedtestView

type NetworkView

type NetworkView struct {
	Online             []NodeView
	Offline            []NodeView
	NodeStatsPollBurst time.Duration
}

func NewNetworkView

func NewNetworkView(
	nodes []models.Node,
	nodeStatsPollBurst time.Duration,
) NetworkView

type NodeView

type NodeView models.Node

func (NodeView) CPU

func (v NodeView) CPU() string

func (NodeView) CPUCount

func (v NodeView) CPUCount() string

func (NodeView) CPUUsage

func (v NodeView) CPUUsage() string

func (NodeView) Disk

func (v NodeView) Disk(idx int) string

func (NodeView) DiskCount

func (v NodeView) DiskCount() int

func (NodeView) DiskUsage

func (v NodeView) DiskUsage() string

func (NodeView) Distribution

func (v NodeView) Distribution() string

func (NodeView) GPU

func (v NodeView) GPU(idx int) string

func (NodeView) GPUCount

func (v NodeView) GPUCount() int

func (NodeView) HasDisk

func (v NodeView) HasDisk() bool

func (NodeView) HasGPU

func (v NodeView) HasGPU() bool

func (NodeView) Hostname

func (v NodeView) Hostname() string

func (NodeView) IsSingleDisk

func (v NodeView) IsSingleDisk() bool

func (NodeView) Kernel

func (v NodeView) Kernel() string

func (NodeView) LastSeenOn

func (v NodeView) LastSeenOn() string

func (NodeView) LocalIP

func (v NodeView) LocalIP() string

func (NodeView) OS

func (v NodeView) OS() string

func (NodeView) OSType

func (v NodeView) OSType() string

func (NodeView) Product

func (v NodeView) Product() string

func (NodeView) PublicIP

func (v NodeView) PublicIP() string

func (NodeView) RAM

func (v NodeView) RAM() string

func (NodeView) RAMUsage

func (v NodeView) RAMUsage() string

func (NodeView) Rx

func (v NodeView) Rx() string

func (NodeView) TotalDisk

func (v NodeView) TotalDisk() string

func (NodeView) TotalRAM

func (v NodeView) TotalRAM() string

func (NodeView) TotalRx

func (v NodeView) TotalRx() string

func (NodeView) TotalTx

func (v NodeView) TotalTx() string

func (NodeView) Tx

func (v NodeView) Tx() string

func (NodeView) Uptime

func (v NodeView) Uptime() string

type RangeFormFieldView

type RangeFormFieldView struct {
	FormFieldView
	Value   int
	Default int
	Min     int
	Max     int
}

func NewRangeFormFieldView

func NewRangeFormFieldView(
	id string,
	label string,
	tooltip string,
	value int,
	defaultValue int,
	min int,
	max int,
) RangeFormFieldView

func (RangeFormFieldView) Accepts

func (v RangeFormFieldView) Accepts(d int) bool

type ServiceContainer

type ServiceContainer struct {
	NodeManager         *service.NodeManagerService
	NodeScheduler       *service.NodeSchedulerService
	NodeCommander       *service.NodeCommanderService
	NodeSpeedtest       *service.NodeSpeedtestService
	MasterConfiguration *service.MasterConfigurationService
	Network             *service.NetworkService
	Networking          *service.NetworkingService
	Authentication      *service.AuthenticationService
	Authorization       *service.AuthorizationService
}

Container for all dependencies required in service context.

func ExtractServiceContainer

func ExtractServiceContainer(
	ctx context.Context,
) *ServiceContainer

type SettingsView

type SettingsView struct {
	Form  FormView
	Error error
}

func NewSettingsView

func NewSettingsView(
	form FormView,
	error error,
) SettingsView

type SpeedtestHistoryChartView

type SpeedtestHistoryChartView struct {
	ChartView
	Breakpoint
}

func NewSpeedtestHistoryChartView

func NewSpeedtestHistoryChartView(
	speedtests []models.Speedtest,
	breakpoint Breakpoint,
) SpeedtestHistoryChartView

func (SpeedtestHistoryChartView) SVG

type SpeedtestPhaseView

type SpeedtestPhaseView models.SpeedtestPhase

func (SpeedtestPhaseView) IsDownloadPhase

func (v SpeedtestPhaseView) IsDownloadPhase() bool

func (SpeedtestPhaseView) IsLatencyPhase

func (v SpeedtestPhaseView) IsLatencyPhase() bool

func (SpeedtestPhaseView) IsUploadPhase

func (v SpeedtestPhaseView) IsUploadPhase() bool

type SpeedtestView

type SpeedtestView struct {
	models.Speedtest
	NodeID string
}

func NewSpeedtestView

func NewSpeedtestView(
	nodeid string,
	speedtest models.Speedtest,
) SpeedtestView

func (SpeedtestView) Status

func (v SpeedtestView) Status() SpeedtestPhaseView

func (SpeedtestView) TakenAt

func (v SpeedtestView) TakenAt() string

type StartNetworkNodeSpeedtestView

type StartNetworkNodeSpeedtestView struct {
	NodeView
	Err error
}

func NewStartNetworkNodeSpeedtestView

func NewStartNetworkNodeSpeedtestView(
	node models.Node,
	err error,
) StartNetworkNodeSpeedtestView

type Template

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

func (*Template) Render

func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error

type UserAgent

type UserAgent useragent.UserAgent

func (UserAgent) Breakpoint

func (ua UserAgent) Breakpoint() Breakpoint

Jump to

Keyboard shortcuts

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