namespace

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FILE_DATA_SAFE_SIZE the length of request shall be shorter than 5242880 bytes
	// this equals 3932160 bytes after
	FILE_DATA_SAFE_SIZE = 3500000

	// WAIT_TIMEOUT timeout for waiting result from external source, in seconds
	WAIT_TIMEOUT time.Duration = 10 * time.Second

	// INIT_WAIT_TIMEOUT timeout for waiting the initial request
	INIT_WAIT_TIMEOUT time.Duration = 15 * time.Second

	SIGNATURE_INFO_TTL = 10 * time.Minute
)

Variables

View Source
var (
	// key: fileHash value: file
	FileOffset      = make(map[string]*FileFetchOffset)
	FileOffsetMutex sync.Mutex
)

Functions

func Apis

func Apis() []rpc.API

apis returns the collection of built-in RPC APIs.

func NewHTTPHandlerStack

func NewHTTPHandlerStack(srv http.Handler, cors []string, vhosts []string) http.Handler

NewHTTPHandlerStack returns wrapped http-related handlers

func NewVHostHandler

func NewVHostHandler(vhosts []string, next http.Handler) http.Handler

func RegisterApis

func RegisterApis(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error

RegisterApis checks the given modules' availability, generates an allowlist based on the allowed modules, and then registers all of the APIs exposed by the services.

func ResultHook

func ResultHook(r *rpc_api.Result, fileHash string) *rpc_api.Result

func RpcLogService

func RpcLogService() *rpcLogService

func RpcPrivApi

func RpcPrivApi() *rpcPrivApi

func RpcPubApi

func RpcPubApi() *rpcPubApi

func StartHTTPEndpoint

func StartHTTPEndpoint(endpoint string, timeouts rpc.HTTPTimeouts, handler http.Handler) (*http.Server, net.Addr, error)

StartHTTPEndpoint starts the HTTP RPC endpoint.

Types

type FileFetchOffset

type FileFetchOffset struct {
	RemoteRequested   uint64
	ResourceNodeAsked uint64
}

type HttpConfig

type HttpConfig struct {
	Modules            []string
	CorsAllowedOrigins []string
	Vhosts             []string
	// contains filtered or unexported fields
}

HttpConfig is the JSON-RPC/HTTP configuration.

type HttpServer

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

func NewHTTPServer

func NewHTTPServer(timeouts rpc.HTTPTimeouts) *HttpServer

func (*HttpServer) EnableRPC

func (h *HttpServer) EnableRPC(apis []rpc.API, config HttpConfig) error

EnableRPC turns on JSON-RPC over HTTP on the server.

func (*HttpServer) EnableTLS

func (h *HttpServer) EnableTLS(cert, key string)

func (*HttpServer) EnableWS

func (h *HttpServer) EnableWS(apis []rpc.API, config WsConfig, ctx context.Context) error

EnableWS turns on JSON-RPC over WebSocket on the server.

func (*HttpServer) ListenAddr

func (h *HttpServer) ListenAddr() string

ListenAddr returns the listening address of the server.

func (*HttpServer) ServeHTTP

func (h *HttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HttpServer) SetListenAddr

func (h *HttpServer) SetListenAddr(host string, port int) error

SetListenAddr configures the listening address of the server. The address can only be set while the server isn't running.

func (*HttpServer) Start

func (h *HttpServer) Start(ctx context.Context) error

Start starts the HTTP server if it is enabled and not already running.

func (*HttpServer) Stop

func (h *HttpServer) Stop()

Stop shuts down the HTTP server.

type IpcServer

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

func NewIPCServer

func NewIPCServer(endpoint string) *IpcServer

func (*IpcServer) Start

func (is *IpcServer) Start(apis []rpc.API, ctx context.Context) error

Start starts the HttpServer's http.server

func (*IpcServer) Stop

func (is *IpcServer) Stop() error

type WsConfig

type WsConfig struct {
	Origins []string
	Modules []string
	Prefix  string // path Prefix on which to mount ws handler
}

WsConfig is the JSON-RPC/Websocket configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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