server

package
v1.29.8 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const ExpiredIn = time.Millisecond * 1000 * 60 * 60
View Source
const GET_INSTALL_SCRIPT_API = "/instance/_get_install_script"

Variables

This section is empty.

Functions

func GetRuntimeInstanceByID

func GetRuntimeInstanceByID(instanceID string) (bool, *model.Instance, error)

TODO check permission by user

func IsWebSocketRequest

func IsWebSocketRequest(r *http.Request) bool

IsWebSocketRequest returns a boolean indicating whether the request has the headers of a WebSocket handshake request.

func ProxyAgentRequest

func ProxyAgentRequest(tag, endpoint string, req *util.Request, responseObjectToUnMarshall interface{}) (*util.Result, error)

func RegisterConfigProvider

func RegisterConfigProvider(provider func(instance model.Instance) []*common.ConfigFile)

Types

type APIHandler

type APIHandler struct {
	core.Handler
}

type ReverseProxy

type ReverseProxy struct {
	// Director must be a function which modifies
	// the request into a new request to be sent
	// using Transport. Its response is then copied
	// back to the original client unmodified.
	Director func(*http.Request)

	// Dial specifies the dial function for dialing the proxied
	// server over tcp.
	// If Dial is nil, net.Dial is used.
	Dial func(network, addr string) (net.Conn, error)

	// TLSClientConfig specifies the TLS configuration to use for 'wss'.
	// If nil, the default configuration is used.
	TLSClientConfig *tls.Config

	// ErrorLog specifies an optional logger for errors
	// that occur when attempting to proxy the request.
	// If nil, logging goes to os.Stderr via the log package's
	// standard logger.
	ErrorLog *log.LoggerInterface
}

ReverseProxy is a WebSocket reverse proxy. It will not work with a regular HTTP request, so it is the caller's responsiblity to ensure the incoming request is a WebSocket request.

func NewSingleHostReverseProxy

func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy

NewSingleHostReverseProxy returns a new websocket ReverseProxy. The path rewrites follow the same rules as the httputil.ReverseProxy. If the target url has the path '/foo' and the incoming request '/bar', the request path will be updated to '/foo/bar' before forwarding. Scheme should specify if 'ws' or 'wss' should be used.

func (*ReverseProxy) ServeHTTP

func (p *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

Function to implement the http.Handler interface.

type Token

type Token struct {
	CreatedAt time.Time
	UserID    string
}

Jump to

Keyboard shortcuts

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