output

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package output is responsible for writing logs and received response data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Output

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

Output is responsible for all the output, be it logging or writing received data.

func NewOutput

func NewOutput(path string, verbose bool) (o *Output, err error)

NewOutput creates a new instance of Output. path is an optional path to the file where the tool will write the received data. If not specified, this information will be written to stdout. verbose defines whether we need to write extended information.

func (*Output) Debug

func (o *Output) Debug(format string, args ...any)

Debug writes DEBUG-level log to stderr (controlled by the verbose flag).

func (*Output) DebugRequest

func (o *Output) DebugRequest(req *http.Request)

DebugRequest writes information about the HTTP request to the output.

TODO(ameshkov): instead of this, log the actual data sent to tls.Conn.

func (*Output) DebugResponse

func (o *Output) DebugResponse(resp *http.Response)

DebugResponse writes information about the HTTP response to the output.

TODO(ameshkov): instead of this, log the actual data received from tls.Conn.

func (*Output) Info

func (o *Output) Info(format string, args ...any)

Info writes INFO-level log to stderr.

func (*Output) Write

func (o *Output) Write(resp *http.Response, responseBody io.Reader, cfg *config.Config)

Write writes received data to the output path (or stdout if not specified).

type ResponseData

type ResponseData struct {
	StatusCode int                 `json:"status_code"`
	Status     string              `json:"status"`
	Proto      string              `json:"proto"`
	TLS        *TLSState           `json:"tls"`
	Headers    map[string][]string `json:"headers"`
	BodyBase64 string              `json:"body_base64"`
}

ResponseData is a helper object for serializing response data to JSON.

type TLSCertificate added in v1.2.0

type TLSCertificate struct {
	Subject     string    `json:"subject"`
	Issuer      string    `json:"issuer"`
	NotBefore   time.Time `json:"not_before"`
	NotAfter    time.Time `json:"not_after"`
	DNSNames    []string  `json:"dns_names"`
	IPAddresses []string  `json:"ip_addresses"`
	Raw         string    `json:"raw"`
}

TLSCertificate is a helper object for serializing information about x509 certificates.

type TLSState

type TLSState struct {
	ServerName         string           `json:"server_name"`
	Version            string           `json:"version"`
	CipherSuite        string           `json:"cipher_suite"`
	NegotiatedProtocol string           `json:"negotiated_protocol"`
	Certificates       []TLSCertificate `json:"certificates"`
}

TLSState is a helper object for serializing response data to JSON.

Jump to

Keyboard shortcuts

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