rpc

package
v0.31.1-arabica Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructModule

func ConstructModule(tp node.Type, cfg *Config) fx.Option

func Flags

func Flags() *flag.FlagSet

Flags gives a set of hardcoded node/rpc package flags.

func ParseFlags

func ParseFlags(cmd *cobra.Command, cfg *Config) error

ParseFlags parses RPC flags from the given cmd and saves them to the passed config.

Types

type CORSConfig added in v0.25.3

type CORSConfig struct {
	Enabled        bool
	AllowedOrigins []string
	AllowedHeaders []string
	AllowedMethods []string
}

func DefaultCORSConfig added in v0.25.3

func DefaultCORSConfig() CORSConfig

type Config added in v0.5.0

type Config struct {
	Address     string
	Port        string
	SkipAuth    bool
	CORS        CORSConfig
	TLSEnabled  bool
	TLSCertPath string
	TLSKeyPath  string
	RateLimit   RateLimitConfig
}

func DefaultConfig added in v0.5.0

func DefaultConfig() Config

func (*Config) RequestURL added in v0.14.0

func (cfg *Config) RequestURL() string

func (*Config) Validate added in v0.5.0

func (cfg *Config) Validate() error

type RateLimitConfig

type RateLimitConfig struct {
	Enabled bool
	// RequestsPerSec is the sustained per-IP request rate; requests above
	// this rate (after burst is drained) get 429 Too Many Requests.
	RequestsPerSec int
	// Burst is the per-IP burst allowance — the bucket size that absorbs
	// short spikes before sustained rate kicks in.
	Burst int
	// CacheSize is the max number of per-IP buckets retained.
	// When exceeded, the least-recently-seen IP is evicted (and gets a fresh
	// burst on its next request). Bounds memory under unique-IP floods.
	CacheSize int
}

RateLimitConfig configures per-IP rate limiting on the RPC server. The limit is keyed by the connection's remote address, so behind a reverse proxy all clients share a single bucket — keep this disabled in that setup and apply rate limiting at the proxy instead.

func DefaultRateLimitConfig

func DefaultRateLimitConfig() RateLimitConfig

DefaultRateLimitConfig disables rate limiting by default; production deployments typically run behind a reverse proxy that handles rate limiting correctly (with the real client IP).

Jump to

Keyboard shortcuts

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