proxy

package
v0.0.0-...-4c80c36 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 15 Imported by: 9

Documentation

Overview

Package proxy provides a proxy middleware for engine API requests between Ethereum consensus clients and execution clients via JSON-RPC. Allows for customizing in-flight responses using custom triggers. Useful for performing advanced tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(p *Proxy) error

func WithDestinationAddress

func WithDestinationAddress(addr string) Option

WithDestinationAddress sets the forwarding address requests will be proxied to.

func WithHost

func WithHost(host string) Option

WithHost sets the proxy server host.

func WithJWTSecret

func WithJWTSecret(secret []byte) Option

WithJWTSecret sets a JWT secret

func WithPort

func WithPort(port int) Option

WithPort sets the proxy server port.

func WithSpoofingCallbacks

func WithSpoofingCallbacks(c *SpoofingCallbacks) Option

WithSpoofingCallbacks sets the proxy spoofing callbacks.

func WithSpoofingConfig

func WithSpoofingConfig(c *SpoofingConfig) Option

WithSpoofingConfig sets the proxy spoofing config.

type Proxy

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

Proxy server that sits as a middleware between an Ethereum consensus client and an execution client, allowing us to modify in-flight requests and responses for testing purposes.

func New

func New(opts ...Option) (*Proxy, error)

New creates a proxy server forwarding requests from a consensus client to an execution client.

func (*Proxy) Address

func (p *Proxy) Address() string

Address for the proxy server.

func (*Proxy) ServeHTTP

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

ServeHTTP by proxying requests from an Ethereum consensus client to an execution client.

func (*Proxy) Start

func (p *Proxy) Start(ctx context.Context) error

Start a proxy server.

func (*Proxy) UpdateSpoofingCallbacks

func (p *Proxy) UpdateSpoofingCallbacks(callbacks *SpoofingCallbacks)

UpdateSpoofingConfig for use at runtime.

func (*Proxy) UpdateSpoofingConfig

func (p *Proxy) UpdateSpoofingConfig(config *SpoofingConfig)

UpdateSpoofingConfig for use at runtime.

type Spoof

type Spoof struct {
	Method string                 `yaml:"method"`
	Fields map[string]interface{} `yaml:"fields"`
}

type SpoofingCallbacks

type SpoofingCallbacks struct {
	// Map of method names to callbacks, where the callback will receive the request bytes as only parameter
	RequestCallbacks map[string]func([]byte) *Spoof
	// Map of method names to callbacks, where the callback will receive the response bytes as 1st parameter,
	// and original request bytes as 2nd parameter
	ResponseCallbacks map[string]func([]byte, []byte) *Spoof
}

type SpoofingConfig

type SpoofingConfig struct {
	Requests  []*Spoof `yaml:"requests"`
	Responses []*Spoof `yaml:"responses"`
}

Jump to

Keyboard shortcuts

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