wrapper

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupported = errors.New("not supported")
)

Functions

func WrapHTTPBody

func WrapHTTPBody(body io.ReadCloser) (io.ReadCloser, error)

Types

type BodyReader

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

func NewBodyReader

func NewBodyReader(r io.Reader) (*BodyReader, error)

func (*BodyReader) Close

func (r *BodyReader) Close() error

func (*BodyReader) Read

func (r *BodyReader) Read(b []byte) (int, error)

type DNSRequest added in v1.1.0

type DNSRequest struct {
	Request *dns.Msg
	From    netip.Addr
}

DNSRequest is a wrapper around dns.Msg implementing Entity interface.

func (*DNSRequest) GetBody added in v1.1.0

func (r *DNSRequest) GetBody() ([]byte, error)

func (*DNSRequest) GetCookies added in v1.1.0

func (r *DNSRequest) GetCookies() ([]*http.Cookie, error)

func (*DNSRequest) GetHeaders added in v1.1.0

func (r *DNSRequest) GetHeaders() (map[string][]string, error)

func (*DNSRequest) GetIP added in v1.1.0

func (r *DNSRequest) GetIP() netip.Addr

func (*DNSRequest) GetMethod added in v1.1.0

func (r *DNSRequest) GetMethod() (string, error)

func (*DNSRequest) GetQuestions added in v1.1.0

func (r *DNSRequest) GetQuestions() ([]dns.Question, error)

func (*DNSRequest) GetRaw added in v1.1.0

func (r *DNSRequest) GetRaw() ([]byte, error)

Return all questions in format: REQ_TYPE1 DOMAIN_NAME1 REQ_TYPE2 DOMAIN_NAME2 ...

func (*DNSRequest) GetURL added in v1.1.0

func (r *DNSRequest) GetURL() (*url.URL, error)

type Entity

type Entity interface {
	GetIP() netip.Addr
	GetRaw() ([]byte, error)

	// HTTP
	GetBody() ([]byte, error)
	GetCookies() ([]*http.Cookie, error)
	GetHeaders() (map[string][]string, error)
	GetURL() (*url.URL, error)
	GetMethod() (string, error)

	// DNS
	GetQuestions() ([]dns.Question, error)
}

type HTTPRequest

type HTTPRequest struct {
	Request *http.Request
}

HTTPRequest is a wrapper around http.Request implementing Entity interface. It's expected that Request.Body is already wrapped with BodyReader.

func (*HTTPRequest) GetBody

func (r *HTTPRequest) GetBody() ([]byte, error)

func (*HTTPRequest) GetCookies

func (r *HTTPRequest) GetCookies() ([]*http.Cookie, error)

func (*HTTPRequest) GetHeaders

func (r *HTTPRequest) GetHeaders() (map[string][]string, error)

func (*HTTPRequest) GetIP

func (r *HTTPRequest) GetIP() netip.Addr

TODO: FIX IP may be hijacked if set one of used headers.

func (*HTTPRequest) GetMethod

func (r *HTTPRequest) GetMethod() (string, error)

func (*HTTPRequest) GetQuestions added in v1.1.0

func (r *HTTPRequest) GetQuestions() ([]dns.Question, error)

func (*HTTPRequest) GetRaw

func (r *HTTPRequest) GetRaw() ([]byte, error)

func (*HTTPRequest) GetURL

func (r *HTTPRequest) GetURL() (*url.URL, error)

type RawPacket added in v1.1.0

type RawPacket struct {
	Content []byte
	From    netip.Addr
	MU      sync.Mutex
}

RawPacket is a wrapper around raw data (e.g. tcp packet) implementing Entity interface.

func (*RawPacket) GetBody added in v1.1.0

func (p *RawPacket) GetBody() ([]byte, error)

func (*RawPacket) GetCookies added in v1.1.0

func (p *RawPacket) GetCookies() ([]*http.Cookie, error)

func (*RawPacket) GetHeaders added in v1.1.0

func (p *RawPacket) GetHeaders() (map[string][]string, error)

func (*RawPacket) GetIP added in v1.1.0

func (p *RawPacket) GetIP() netip.Addr

func (*RawPacket) GetMethod added in v1.1.0

func (p *RawPacket) GetMethod() (string, error)

func (*RawPacket) GetQuestions added in v1.1.0

func (p *RawPacket) GetQuestions() ([]dns.Question, error)

func (*RawPacket) GetRaw added in v1.1.0

func (p *RawPacket) GetRaw() ([]byte, error)

func (*RawPacket) GetURL added in v1.1.0

func (p *RawPacket) GetURL() (*url.URL, error)

Jump to

Keyboard shortcuts

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