cfgutil

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: ISC Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(filePath string) (bool, error)

FileExists reports whether the named file or directory exists.

func NormalizeAddress

func NormalizeAddress(addr string, defaultPort string) (hostport string, err error)

NormalizeAddress returns the normalized form of the address, adding a default port if necessary. An error is returned if the address, even without a port, is not valid.

func NormalizeAddresses

func NormalizeAddresses(addrs []string, defaultPort string) ([]string, error)

NormalizeAddresses returns a new slice with all the passed peer addresses normalized with the given default port, and all duplicates removed.

Types

type AddressFlag

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

AddressFlag contains a stdaddr.Address and implements the flags.Marshaler and Unmarshaler interfaces so it can be used as a config struct field.

func NewAddressFlag

func NewAddressFlag() *AddressFlag

NewAddressFlag creates an AddressFlag with a default stdaddr.Address.

func (*AddressFlag) Address

func (a *AddressFlag) Address(params stdaddr.AddressParams) (stdaddr.Address, error)

Address decodes the address flag for the network described by params. If the flag is the empty string, this returns a nil address.

func (*AddressFlag) MarshalFlag

func (a *AddressFlag) MarshalFlag() (string, error)

MarshalFlag satisfies the flags.Marshaler interface.

func (*AddressFlag) StakeAddress

func (a *AddressFlag) StakeAddress(params stdaddr.AddressParams) (stdaddr.StakeAddress, error)

StakeAddress decodes the address flag for the network described by params as a stake address. If the flag is the empty string, this returns a nil address.

func (*AddressFlag) UnmarshalFlag

func (a *AddressFlag) UnmarshalFlag(addr string) error

UnmarshalFlag satisfies the flags.Unmarshaler interface.

type AmountFlag

type AmountFlag struct {
	dcrutil.Amount
}

AmountFlag embeds a dcrutil.Amount and implements the flags.Marshaler and Unmarshaler interfaces so it can be used as a config struct field.

func NewAmountFlag

func NewAmountFlag(defaultValue dcrutil.Amount) *AmountFlag

NewAmountFlag creates an AmountFlag with a default dcrutil.Amount.

func (*AmountFlag) MarshalFlag

func (a *AmountFlag) MarshalFlag() (string, error)

MarshalFlag satisfies the flags.Marshaler interface.

func (*AmountFlag) UnmarshalFlag

func (a *AmountFlag) UnmarshalFlag(value string) error

UnmarshalFlag satisfies the flags.Unmarshaler interface.

type CurveFlag

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

CurveFlag describes a curve and implements the flags.Marshaler and Unmarshaler interfaces so it can be used as a config struct field.

func NewCurveFlag

func NewCurveFlag(defaultValue CurveID) *CurveFlag

NewCurveFlag creates a CurveFlag with a default curve.

func (*CurveFlag) CertGen

func (f *CurveFlag) CertGen(org string, validUntil time.Time, extraHosts []string) (cert, key []byte, err error)

func (*CurveFlag) ECDSACurve

func (f *CurveFlag) ECDSACurve() (elliptic.Curve, bool)

ECDSACurve returns the elliptic curve described by f, or (nil, false) if the curve is not one of the elliptic curves suitable for ECDSA.

func (*CurveFlag) GenerateKeyPair

func (f *CurveFlag) GenerateKeyPair(rand io.Reader) (pub, priv interface{}, err error)

func (*CurveFlag) MarshalFlag

func (f *CurveFlag) MarshalFlag() (name string, err error)

MarshalFlag satisfies the flags.Marshaler interface.

func (*CurveFlag) UnmarshalFlag

func (f *CurveFlag) UnmarshalFlag(value string) error

UnmarshalFlag satisfies the flags.Unmarshaler interface.

type CurveID

type CurveID int

CurveID specifies a recognized curve through a constant value.

const (
	CurveP256 CurveID = iota
	CurveP384
	CurveP521
	Ed25519

	// PreferredCurve is the curve that should be used as the application default.
	PreferredCurve = Ed25519
)

Recognized curve IDs.

type ExplicitString

type ExplicitString struct {
	Value string
	// contains filtered or unexported fields
}

ExplicitString is a string value implementing the flags.Marshaler and flags.Unmarshaler interfaces so it may be used as a config struct field. It records whether the value was explicitly set by the flags package. This is useful when behavior must be modified depending on whether a flag was set by the user or left as a default. Without recording this, it would be impossible to determine whether flag with a default value was unmodified or explicitly set to the default.

func NewExplicitString

func NewExplicitString(defaultValue string) *ExplicitString

NewExplicitString creates a string flag with the provided default value.

func (*ExplicitString) ExplicitlySet

func (e *ExplicitString) ExplicitlySet() bool

ExplicitlySet returns whether the flag was explicitly set through the flags.Unmarshaler interface.

func (*ExplicitString) MarshalFlag

func (e *ExplicitString) MarshalFlag() (string, error)

MarshalFlag implements the flags.Marshaler interface.

func (*ExplicitString) String

func (e *ExplicitString) String() string

String implements the fmt.Stringer interface.

func (*ExplicitString) UnmarshalFlag

func (e *ExplicitString) UnmarshalFlag(value string) error

UnmarshalFlag implements the flags.Unmarshaler interface.

Jump to

Keyboard shortcuts

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