raksh

package module
v0.0.0-...-0f64186 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHttpBadRequest = errors.New("Bad Request")
View Source
var ErrHttpForbiddenRequest = errors.New("Forbidden")

* Errors that the HttpApplication handlers return on failure. * This would then result in appropriate Http Response being * sent to the client

View Source
var ErrHttpUnauthorized = errors.New("Unauthorized")
View Source
var ErrRequestShortWrite = errors.New("Request Short Write")
View Source
var ErrResponseShortWrite = errors.New("Response Short Write")

ErrResponseShortWrite means that a write accepted fewer bytes than requested but failed to return an explicit error.

View Source
var ProxyErrMissingHost = errors.New("proxy: Request with no Host or URL set")

Functions

func BuildErrorResponse

func BuildErrorResponse(outreq *http.Request, err error) *http.Response

func Uuid

func Uuid() string

Types

type HttpApplication

type HttpApplication interface {
	RequestDataHandler(flow *HttpFlow, data []byte) ([]byte, error)
	ResponseDataHandler(flow *HttpFlow, data []byte) ([]byte, error)
	RequestHandler(flow *HttpFlow) error
	ResponseHandler(flow *HttpFlow) error
	StreamedRequestDataHandler(flow *HttpFlow, buf []byte, last_chunk bool) ([]byte, error)
	StreamedResponseDataHandler(flow *HttpFlow, buf []byte, last_chunk bool) ([]byte, error)
	FailureHandler(flow *HttpFlow)
}

HTTP proxy application This interface encapsulates the methods that the HTTP processing application needs to implement to use the mitm proxy service - a handler to process HTTP Requests - a handler to process HTTP Responses

type HttpFlow

type HttpFlow struct {
	Id                string
	Request           *http.Request
	Response          *http.Response
	RequestStreaming  bool
	ResponseStreaming bool
}

type HttpMitmProxy

type HttpMitmProxy struct {
	// The transport used to perform proxy requests.
	// If nil, http.DefaultTransport is used
	Transport StreamingTransport

	// BufferPool specifies a buffer pool to get byte slices for use by
	// io.CopyBuffer when copying HTTP request and response bodies
	BufferPool *bpool.BytePool

	ChunkSize int64
	// contains filtered or unexported fields
}

* HTTP mitm proxy

func NewHttpMitmProxy

func NewHttpMitmProxy(addr string, app HttpApplication, sslCertFile, sslKeyFile string) (*HttpMitmProxy, error)

func (*HttpMitmProxy) ServeHTTP

func (p *HttpMitmProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*HttpMitmProxy) Start

func (p *HttpMitmProxy) Start() error

type PersistConn

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

type ProxyTransport

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

func GetDefaultTransport

func GetDefaultTransport() *ProxyTransport

func (*ProxyTransport) ClientClose

func (t *ProxyTransport) ClientClose(remote string)

Called by the proxy to notify that the frontend client has closed its connection. The transport implemenation can use this to cleanup its state, if any

func (*ProxyTransport) GetConnection

func (t *ProxyTransport) GetConnection(req *http.Request) (*PersistConn, error)

func (*ProxyTransport) NewConnection

func (t *ProxyTransport) NewConnection(req *http.Request, pconn *PersistConn) error

func (*ProxyTransport) PutConnection

func (t *ProxyTransport) PutConnection(pconn *PersistConn) error

return the connection back to the pool.

func (*ProxyTransport) ReadResponse

func (t *ProxyTransport) ReadResponse(pconn *PersistConn, req *http.Request) (resp *http.Response, err error)

func (*ProxyTransport) RoundTrip

func (t *ProxyTransport) RoundTrip(req *http.Request) (*http.Response, error)

func (*ProxyTransport) Write

func (t *ProxyTransport) Write(pconn *PersistConn, req *http.Request, src []byte) (int, error)

func (*ProxyTransport) WriteHeader

func (t *ProxyTransport) WriteHeader(pconn *PersistConn, req *http.Request) error

type StreamingTransport

type StreamingTransport interface {
	// A StreamingTransport provides support to stream HTTP requests
	// and responses to a server, optionally re-using connections
	// to ship multiple http transactions
	//
	// It should not attempt to intrepret the response or modify the
	// request.
	// The Request's URL and Header fields are expected to be initialized
	GetConnection(req *http.Request) (*PersistConn, error)
	PutConnection(pconn *PersistConn) error

	WriteHeader(pconn *PersistConn, req *http.Request) error
	Write(pconn *PersistConn, req *http.Request, src []byte) (int, error)

	ReadResponse(pconn *PersistConn, req *http.Request) (resp *http.Response, err error)
	ClientClose(remote string)
}

A StreamingTransport must be safe for concurrent use by multiple goroutines.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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