config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config is responsible for parsing and validating cmd arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// RequestURL is the URL where the target request will be sent.
	RequestURL *url.URL

	// Method is the HTTP method of the request.
	Method string

	// Head signals that the tool should only fetch headers. If specified,
	// headers will be written to the output.
	Head bool

	// Data specifies the data to be sent to the HTTP server.
	Data string

	// Headers is the HTTP headers that will be added to the request.
	Headers http.Header

	// ProxyURL is a URL of a proxy to use with this connection.
	ProxyURL *url.URL

	// ConnectTo is a mapping of "host1:port1" to "host2:port2" pairs that
	// allows retargeting the connection.
	ConnectTo map[string]string

	// Insecure disables TLS verification of the connection.
	Insecure bool

	// TLSMinVersion is a minimum supported TLS version.
	TLSMinVersion uint16

	// TLSMaxVersion is a maximum supported TLS version.
	TLSMaxVersion uint16

	// ForceHTTP11 forces using HTTP/1.1.
	ForceHTTP11 bool

	// ForceHTTP2 forces using HTTP/2.
	ForceHTTP2 bool

	// ForceHTTP2 forces using HTTP/3.
	ForceHTTP3 bool

	// TLSSplitChunkSize is a size of the first chunk of ClientHello that is
	// sent to the server.
	TLSSplitChunkSize int

	// TLSSplitDelay is a delay in milliseconds before sending the second
	// chunk of ClientHello.
	TLSSplitDelay int

	// OutputJSON enables writing output in JSON format.
	OutputJSON bool

	// OutputPath defines where to write the received data. If not set, the
	// received data will be written to stdout.
	OutputPath string

	// Verbose defines whether we should write the DEBUG-level log or not.
	Verbose bool

	// RawOptions is the raw command-line arguments struct (for logging only).
	RawOptions *Options
}

Config is a strictly-typed and validated configuration structure which is created from Options (command-line arguments).

func ParseConfig

func ParseConfig() (cfg *Config, err error)

ParseConfig parses and validates os.Args and returns the final *Config object.

type Options

type Options struct {
	// URL represents the address the request will be made to. It is always the
	// last argument.
	URL string `long:"url" description:"URL the request will be made to. Can be specified without any flags." value-name:"<URL>"`

	// Method is the HTTP method to be used.
	Method string `short:"X" long:"request" description:"HTTP method. GET by default." value-name:"<method>"`

	// Data specifies the data to be sent to the HTTP server.
	Data string `` /* 153-byte string literal not displayed */

	// Headers is an array of HTTP headers (format is "header: value") to
	// include in the request.
	Headers []string `short:"H" long:"header" description:"Extra header to include in the request. Can be specified multiple times."`

	// ProxyURL is a URL of a proxy to use with this connection.
	ProxyURL string `` /* 178-byte string literal not displayed */

	// ConnectTo allows to override the connection target, i.e. for a request
	// to the given HOST1:PORT1 pair, connect to HOST2:PORT2 instead.
	ConnectTo []string `` /* 147-byte string literal not displayed */

	// Head signals that the tool should only fetch headers. If specified,
	// headers will be written to the output.
	Head bool `short:"I" long:"head" description:"Fetch the headers only." optional:"yes" optional-value:"true"`

	// Insecure disables TLS verification of the connection.
	Insecure bool `short:"k" long:"insecure" description:"Disables TLS verification of the connection." optional:"yes" optional-value:"true"`

	// TLSv13 forces to use TLS v1.3.
	TLSv13 bool `long:"tlsv1.3" description:"Forces gocurl to use TLS v1.3." optional:"yes" optional-value:"true"`

	// TLSv13 forces to use TLS v1.2.
	TLSv12 bool `long:"tlsv1.2" description:"Forces gocurl to use TLS v1.2." optional:"yes" optional-value:"true"`

	// HTTPv11 forces to use HTTP v1.1.
	HTTPv11 bool `long:"http1.1" description:"Forces gocurl to use HTTP v1.1." optional:"yes" optional-value:"true"`

	// HTTPv2 forces to use HTTP v2.
	HTTPv2 bool `long:"http2" description:"Forces gocurl to use HTTP v2." optional:"yes" optional-value:"true"`

	// HTTPv3 forces to use HTTP v3.
	HTTPv3 bool `long:"http3" description:"Forces gocurl to use HTTP v2." optional:"yes" optional-value:"true"`

	// TLSSplitHello is an option that allows splitting TLS ClientHello in two
	// parts in order to avoid common DPI systems detecting TLS. CHUNKSIZE is
	// the size of the first bytes before ClientHello is split, DELAY is delay
	// in milliseconds before sending the second part.
	TLSSplitHello string `` /* 313-byte string literal not displayed */

	// OutputJSON enables writing output in JSON format.
	OutputJSON bool `` /* 128-byte string literal not displayed */

	// OutputPath defines where to write the received data. If not set, gocurl
	// will write everything to stdout.
	OutputPath string `` /* 151-byte string literal not displayed */

	// Verbose defines whether we should write the DEBUG-level log or not.
	Verbose bool `short:"v" long:"verbose" description:"Verbose output (optional)." optional:"yes" optional-value:"true"`
}

Options represents command-line arguments.

func (*Options) String

func (o *Options) String() (s string)

String implements fmt.Stringer interface for Options.

Jump to

Keyboard shortcuts

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