config

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

	// TLSCiphers is a list of ciphers that the client will send in the TLS
	// ClientHello.
	TLSCiphers []uint16

	// ForceHTTP11 forces using HTTP/1.1.
	ForceHTTP11 bool

	// ForceHTTP2 forces using HTTP/2.
	ForceHTTP2 bool

	// ForceHTTP2 forces using HTTP/3.
	ForceHTTP3 bool

	// ECH forces usage of Encrypted Client Hello for the request.  If other
	// ECH-related fields are not specified, the ECH configuration will be
	// received from the DNS settings.
	ECH bool

	// ECHConfigs is a set of ECH configurations that will be used when opening
	// an encrypted connection.
	ECHConfigs []ctls.ECHConfig

	// Resolve is a map of host:ips pairs.  It allows specifying custom IP
	// addresses for a specific host or all hosts (if '*' is used instead of
	// the host name).
	Resolve map[string][]net.IP

	// IPv4 if configured forces usage of IP4 addresses only when doing DNS
	// resolution.
	IPv4 bool

	// IPv6 if configured forces usage of IP4 addresses only when doing DNS
	// resolution.
	IPv6 bool

	// DNSServers is a list of upstream DNS servers that will be used for
	// resolving hostnames.
	DNSServers []upstream.Upstream

	// 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

	// Experiments is a map where the key is Experiment and value is its
	// optional configuration.
	Experiments map[Experiment]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.

Disable gocyclo for ParseConfig as it's supposed to be a large function with if conditions.

nolint:gocyclo

type Experiment added in v1.3.0

type Experiment string

Experiment is an enumeration of experimental features available for us via the --experiment flag.

const (
	// ExpNone is just an empty value, not an experiment.
	ExpNone Experiment = ""

	// ExpPostQuantum stands for post-quantum cryptography.  See the website for
	// more details: https://pq.cloudflareresearch.com/.
	ExpPostQuantum Experiment = "pq"
)

func NewExperiment added in v1.3.0

func NewExperiment(str string) (e Experiment, err error)

NewExperiment tries to create an Experiment from string. Returns error if the string is not a valid member of the enumeration.

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 `` /* 180-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 or newer." 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 or newer." optional:"yes" optional-value:"true"`

	// TLSMax specifies the maximum supported TLS version.
	TLSMax string `` /* 184-byte string literal not displayed */

	// TLSCiphers specifies which ciphers to use in the connection, see
	// https://go.dev/src/crypto/tls/cipher_suites.go for the full list of
	// available ciphers.
	TLSCiphers string `` /* 216-byte string literal not displayed */

	// 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 v3." optional:"yes" optional-value:"true"`

	// ECH forces usage of Encrypted Client Hello for the request.  If other
	// ECH-related fields are not specified, the ECH configuration will be
	// received from the DNS settings.
	ECH bool `long:"ech" description:"Enables ECH support for the request." optional:"yes" optional-value:"true"`

	// ECHConfig is a custom ECH configuration to use for this request.  If this
	// option is specified, there will be no attempt to discover the ECH
	// configuration using DNS.
	ECHConfig string `` /* 149-byte string literal not displayed */

	// IPv4 if configured forces usage of IP4 addresses only when doing DNS
	// resolution.
	IPv4 bool `` /* 151-byte string literal not displayed */

	// IPv6 if configured forces usage of IP4 addresses only when doing DNS
	// resolution.
	IPv6 bool `` /* 151-byte string literal not displayed */

	// DNSServers is a list of DNS servers that will be used to resolve
	// hostnames when making a request.  Encrypted DNS addresses or DNS stamps
	// can be used here.
	DNSServers string `` /* 168-byte string literal not displayed */

	// Resolve allows to provide a custom address for a specific host and port
	// pair. Supports '*' instead of the host name to cover all hosts.
	Resolve []string `` /* 219-byte string literal not displayed */

	// 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 */

	// Experiments allows to enable experimental configuration options.
	Experiments []string `` /* 175-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