proxy

package
v4.2.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Overview

Package proxy provides a proxy middleware for engine API requests between Ethereum consensus clients and execution clients accordingly. Allows for customizing in-flight requests or responses using custom triggers. Useful for end-to-end testing.

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 string) Option

WithJwtSecret adds in support for jwt authenticated connections for our proxy.

func WithLogFile

func WithLogFile(f *os.File) Option

WithLogFile specifies a log file to write the proxies output to.

func WithLogger

func WithLogger(l *logrus.Logger) Option

WithLogger sets a custom logger for the proxy.

func WithPort

func WithPort(port int) Option

WithPort sets the proxy server port.

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) AddRequestInterceptor

func (p *Proxy) AddRequestInterceptor(rpcMethodName string, response func() interface{}, trigger func() bool)

AddRequestInterceptor for a desired json-rpc method by specifying a custom response and a function that checks if the interceptor should be triggered.

func (*Proxy) Address

func (p *Proxy) Address() string

Address for the proxy server.

func (*Proxy) ReleaseBackedUpRequests

func (p *Proxy) ReleaseBackedUpRequests(rpcMethodName string)

ReleaseBackedUpRequests releases backed up http requests which were previously ignored due to our interceptors.

func (*Proxy) RemoveRequestInterceptor

func (p *Proxy) RemoveRequestInterceptor(rpcMethodName string)

RemoveRequestInterceptor removes the request interceptor for the provided method.

func (*Proxy) ServeHTTP

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

ServeHTTP requests from a consensus client to an execution client, modifying in-flight requests and/or responses as desired. It also processes any backed-up requests.

func (*Proxy) Start

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

Start a proxy server.

Jump to

Keyboard shortcuts

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