addrstrparam

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0, Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressStringFormatParams

type AddressStringFormatParams interface {
	// AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'.
	// If so, then you can write addresses like "*.*" or "*:*".
	AllowsWildcardedSeparator() bool

	// AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::".
	// For IPV4, this option overrides inet_aton octal.
	//
	// Single segment addresses that must have the requisite length to be parsed are not affected by this flag.
	AllowsLeadingZeros() bool

	// AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments
	// beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6.
	// However, this only takes effect if leading zeros are allowed, which is when
	// AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.
	//
	// For example, this determines whether you allow "0001.0002.0003.0004".
	AllowsUnlimitedLeadingZeros() bool

	// GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.
	GetRangeParams() RangeParams
}

type AddressStringFormatParamsBuilder

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

AddressStringFormatParamsBuilder creates parameters for parsing a specific address type or address version.

func (*AddressStringFormatParamsBuilder) AllowsLeadingZeros

func (params *AddressStringFormatParamsBuilder) AllowsLeadingZeros() bool

AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*AddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros

func (params *AddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros() bool

AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004".

func (*AddressStringFormatParamsBuilder) AllowsWildcardedSeparator

func (params *AddressStringFormatParamsBuilder) AllowsWildcardedSeparator() bool

AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*AddressStringFormatParamsBuilder) GetRangeParams

func (params *AddressStringFormatParamsBuilder) GetRangeParams() RangeParams

GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.

func (*AddressStringFormatParamsBuilder) GetRangeParamsBuilder

func (builder *AddressStringFormatParamsBuilder) GetRangeParamsBuilder() RangeParams

GetRangeParamsBuilder returns a builder that builds the range parameters for these address string format parameters.

func (*AddressStringFormatParamsBuilder) ToParams

ToParams returns an immutable AddressStringFormatParams instance built by this builder.

type AddressStringParams

type AddressStringParams interface {
	// AllowsEmpty indicates whether it allows zero-length address strings: ""
	AllowsEmpty() bool

	// AllowsSingleSegment allows an address to be specified as a single value, eg ffffffff, without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8"
	AllowsSingleSegment() bool

	// AllowsAll indicates if we allow the string of just the wildcard "*" to denote all addresses of all version.
	// If false, then for IP addresses we check the preferred version with GetPreferredVersion(), and then check AllowsWildcardedSeparator,
	// to determine if the string represents all addresses of that version.
	AllowsAll() bool
}

type AddressStringParamsBuilder

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

AddressStringParamsBuilder builds an AddressStringParams.

func (*AddressStringParamsBuilder) AllowsAll

func (params *AddressStringParamsBuilder) AllowsAll() bool

AllowsAll indicates if we allow the string of just the wildcard "*" to denote all addresses of all version. If false, then for IP addresses we check the preferred version with GetPreferredVersion(), and then check AllowsWildcardedSeparator(), to determine if the string represents all addresses of that version.

func (*AddressStringParamsBuilder) AllowsEmpty

func (params *AddressStringParamsBuilder) AllowsEmpty() bool

AllowsEmpty indicates whether it allows zero-length address strings: "".

func (*AddressStringParamsBuilder) AllowsSingleSegment

func (params *AddressStringParamsBuilder) AllowsSingleSegment() bool

AllowsSingleSegment allows an address to be specified as a single value, eg ffffffff, without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8".

func (*AddressStringParamsBuilder) ToParams

func (builder *AddressStringParamsBuilder) ToParams() AddressStringParams

ToParams returns an immutable AddressStringParams instance built by this builder.

type AllStrOption

type AllStrOption string

AllStrOption is an option indicating how to translate an all address string, such as "*", to an address.

const (
	// AllAddresses is the default, indicating the all address string refers to all addresses of all IP versions.
	AllAddresses AllStrOption = "" // the default

	// AllPreferredIPVersion indicates the all address string refers to all addresses of the preferred IP version.
	AllPreferredIPVersion AllStrOption = "preferred"
)

type EmptyStrOption

type EmptyStrOption string

EmptyStrOption is an option indicating how to translate an empty address string to an address.

const (
	// NoAddressOption indicates that empty strings are not translated to addresses.
	NoAddressOption EmptyStrOption = "none"

	// ZeroAddressOption is the default, which means empty strings are translated to zero addresses.
	ZeroAddressOption EmptyStrOption = ""

	// LoopbackOption indicates empty strings are translated to loopback addresses.
	LoopbackOption EmptyStrOption = "loopback"
)

type HostNameParams

type HostNameParams interface {
	// AllowsEmpty determines if an empty host string is considered valid.
	// The parser will first parse as an empty address, if allowed by the nested IPAddressStringParams.
	// Otherwise, it will be considered an empty host if this returns true, or an invalid host if it returns false.
	AllowsEmpty() bool

	// GetPreferredVersion indicates the version to prefer when resolving host names.
	GetPreferredVersion() IPVersion

	// AllowsBracketedIPv4 allows bracketed IPv4 addresses like "[1.2.3.4]".
	AllowsBracketedIPv4() bool

	// AllowsBracketedIPv6 allows bracketed IPv6 addresses like "[1::2]".
	AllowsBracketedIPv6() bool

	// NormalizesToLowercase indicates whether to normalize the host name to lowercase characters when parsing.
	NormalizesToLowercase() bool

	// AllowsIPAddress allows a host name to specify an IP address or subnet.
	AllowsIPAddress() bool

	// AllowsPort allows a host name to specify a port.
	AllowsPort() bool

	// AllowsService allows a host name to specify a service, which typically maps to a port.
	AllowsService() bool

	// ExpectsPort indicates whether a port should be inferred from a host like 1:2:3:4::80 that is ambiguous if a port might have been appended.
	// The final segment would normally be considered part of the address, but can be interpreted as a port instead.
	ExpectsPort() bool

	// GetIPAddressParams returns the parameters that apply specifically to IP addresses and subnets, whenever a host name specifies an IP addresses or subnet.
	GetIPAddressParams() IPAddressStringParams
}

HostNameParams provides parameters for parsing host name strings.

This allows you to control the validation performed by HostName.

HostName uses a default permissive HostNameParams object when you do not specify one.

If you wish to use parameters different from the default, then use this interface. Immutable instances can be constructed with HostNameParamsBuilder.

func CopyHostNameParams

func CopyHostNameParams(orig HostNameParams) HostNameParams

CopyHostNameParams produces an immutable copy of the original HostNameParams. Copying a HostNameParams created by a HostNameParamsBuilder is unnecessary since it is already immutable.

type HostNameParamsBuilder

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

HostNameParamsBuilder builds an immutable HostNameParams for controlling parsing of host names.

func (*HostNameParamsBuilder) AllowBracketedIPv4

func (builder *HostNameParamsBuilder) AllowBracketedIPv4(allow bool) *HostNameParamsBuilder

AllowBracketedIPv4 dictates whether to allow bracketed IPv4 addresses like "[1.2.3.4]".

func (*HostNameParamsBuilder) AllowBracketedIPv6

func (builder *HostNameParamsBuilder) AllowBracketedIPv6(allow bool) *HostNameParamsBuilder

AllowBracketedIPv6 dictates whether to allow bracketed IPv6 addresses like "[1::2]".

func (*HostNameParamsBuilder) AllowEmpty

func (builder *HostNameParamsBuilder) AllowEmpty(allow bool) *HostNameParamsBuilder

AllowEmpty dictates whether an empty host string is considered valid. The parser will first parse as an empty address, if allowed by the nested IPAddressStringParams. Otherwise, this setting dictates whether it will be considered an invalid host.

func (*HostNameParamsBuilder) AllowIPAddress

func (builder *HostNameParamsBuilder) AllowIPAddress(allow bool) *HostNameParamsBuilder

AllowIPAddress dictates whether to allow a host name to specify an IP address or subnet.

func (*HostNameParamsBuilder) AllowPort

func (builder *HostNameParamsBuilder) AllowPort(allow bool) *HostNameParamsBuilder

AllowPort dictates whether to allow a host name to specify a port.

func (*HostNameParamsBuilder) AllowService

func (builder *HostNameParamsBuilder) AllowService(allow bool) *HostNameParamsBuilder

AllowService dictates whether to allow a host name to specify a service, which typically maps to a port.

func (*HostNameParamsBuilder) AllowsBracketedIPv4

func (params *HostNameParamsBuilder) AllowsBracketedIPv4() bool

AllowsBracketedIPv4 allows bracketed IPv4 addresses like "[1.2.3.4]".

func (*HostNameParamsBuilder) AllowsBracketedIPv6

func (params *HostNameParamsBuilder) AllowsBracketedIPv6() bool

AllowsBracketedIPv6 allows bracketed IPv6 addresses like "[1::2]".

func (*HostNameParamsBuilder) AllowsEmpty

func (params *HostNameParamsBuilder) AllowsEmpty() bool

AllowsEmpty determines if an empty host string is considered valid. The parser will first parse as an empty address, if allowed by the nested IPAddressStringParams. Otherwise, it will be considered an empty host if this returns true, or an invalid host if it returns false.

func (*HostNameParamsBuilder) AllowsIPAddress

func (params *HostNameParamsBuilder) AllowsIPAddress() bool

AllowsIPAddress allows a host name to specify an IP address or subnet.

func (*HostNameParamsBuilder) AllowsPort

func (params *HostNameParamsBuilder) AllowsPort() bool

AllowsPort allows a host name to specify a port.

func (*HostNameParamsBuilder) AllowsService

func (params *HostNameParamsBuilder) AllowsService() bool

AllowsService allows a host name to specify a service, which typically maps to a port.

func (*HostNameParamsBuilder) ExpectPort

func (builder *HostNameParamsBuilder) ExpectPort(expect bool) *HostNameParamsBuilder

ExpectPort dictates whether a port should be inferred from a host like 1:2:3:4::80 that is ambiguous if a port might have been appended. The final segment would normally be considered part of the address, but can be interpreted as a port instead.

func (*HostNameParamsBuilder) ExpectsPort

func (params *HostNameParamsBuilder) ExpectsPort() bool

ExpectsPort indicates whether a port should be inferred from a host like 1:2:3:4::80 that is ambiguous if a port might have been appended. The final segment would normally be considered part of the address, but can be interpreted as a port instead.

func (*HostNameParamsBuilder) GetIPAddressParams

func (params *HostNameParamsBuilder) GetIPAddressParams() IPAddressStringParams

GetIPAddressParams returns the parameters that apply specifically to IP addresses and subnets, whenever a host name specifies an IP addresses or subnet.

func (*HostNameParamsBuilder) GetIPAddressParamsBuilder

func (builder *HostNameParamsBuilder) GetIPAddressParamsBuilder() (result *IPAddressStringParamsBuilder)

GetIPAddressParamsBuilder returns a builder that builds the IPAddressStringParams for the HostNameParams being built by this builder.

func (*HostNameParamsBuilder) GetPreferredVersion

func (params *HostNameParamsBuilder) GetPreferredVersion() IPVersion

GetPreferredVersion indicates the version to prefer when resolving host names.

func (*HostNameParamsBuilder) NormalizeToLowercase

func (builder *HostNameParamsBuilder) NormalizeToLowercase(allow bool) *HostNameParamsBuilder

NormalizeToLowercase dictates whether to normalize the host name to lowercase characters when parsing.

func (*HostNameParamsBuilder) NormalizesToLowercase

func (params *HostNameParamsBuilder) NormalizesToLowercase() bool

NormalizesToLowercase indicates whether to normalize the host name to lowercase characters when parsing.

func (*HostNameParamsBuilder) Set

Set populates this builder with the values from the given HostNameParams.

func (*HostNameParamsBuilder) SetIPAddressParams

func (builder *HostNameParamsBuilder) SetIPAddressParams(params IPAddressStringParams) *HostNameParamsBuilder

SetIPAddressParams populates this builder with the values from the given IPAddressStringParams.

func (*HostNameParamsBuilder) SetPreferredVersion

func (builder *HostNameParamsBuilder) SetPreferredVersion(version IPVersion) *HostNameParamsBuilder

SetPreferredVersion dictates the version to prefer when resolving host names.

func (*HostNameParamsBuilder) ToParams

func (builder *HostNameParamsBuilder) ToParams() HostNameParams

ToParams returns an immutable HostNameParams instance built by this builder.

type IPAddressStringFormatParams

type IPAddressStringFormatParams interface {
	AddressStringFormatParams

	// AllowsPrefixesBeyondAddressSize allows prefix length values greater than 32 for IPv4 or greater than 128 for IPv6.
	AllowsPrefixesBeyondAddressSize() bool

	// AllowsPrefixLenLeadingZeros allows leading zeros in the prefix length like "1.2.3.4/016".
	AllowsPrefixLenLeadingZeros() bool

	// AllowsBinary allows binary addresses like "11111111.0.1.0" or "1111111111111111::".
	AllowsBinary() bool
}

IPAddressStringFormatParams provides format parameters that apply to all IP addresses, but can be different for IPv4 or IPv6, allowing for cases where you may wish to allow something for one version but not the same for the other version.

type IPAddressStringFormatParamsBuilder

type IPAddressStringFormatParamsBuilder struct {
	AddressStringFormatParamsBuilder
	// contains filtered or unexported fields
}

IPAddressStringFormatParamsBuilder builds an immutable IPAddressStringFormatParams for controlling parsing of IP address strings.

func (*IPAddressStringFormatParamsBuilder) AllowsBinary

func (builder *IPAddressStringFormatParamsBuilder) AllowsBinary() bool

AllowsBinary allows binary addresses like 11111111.0.1.0 or 1111111111111111::

func (*IPAddressStringFormatParamsBuilder) AllowsLeadingZeros

func (params *IPAddressStringFormatParamsBuilder) AllowsLeadingZeros() bool

AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*IPAddressStringFormatParamsBuilder) AllowsPrefixLenLeadingZeros

func (builder *IPAddressStringFormatParamsBuilder) AllowsPrefixLenLeadingZeros() bool

AllowsPrefixLenLeadingZeros allows leading zeros in the prefix length like "1.2.3.4/016".

func (*IPAddressStringFormatParamsBuilder) AllowsPrefixesBeyondAddressSize

func (builder *IPAddressStringFormatParamsBuilder) AllowsPrefixesBeyondAddressSize() bool

AllowsPrefixesBeyondAddressSize allows prefix length values greater than 32 for IPv4 or greater than 128 for IPv6.

func (*IPAddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros

func (params *IPAddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros() bool

AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004".

func (*IPAddressStringFormatParamsBuilder) AllowsWildcardedSeparator

func (params *IPAddressStringFormatParamsBuilder) AllowsWildcardedSeparator() bool

AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPAddressStringFormatParamsBuilder) GetParentBuilder

GetParentBuilder returns the original IPAddressStringParamsBuilder builder that this was obtained from, if this builder was obtained from a IPAddressStringParamsBuilder.

func (*IPAddressStringFormatParamsBuilder) GetRangeParams

func (params *IPAddressStringFormatParamsBuilder) GetRangeParams() RangeParams

GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.

func (*IPAddressStringFormatParamsBuilder) ToParams

ToParams returns an immutable IPAddressStringFormatParams instance built by this builder

type IPAddressStringParams

type IPAddressStringParams interface {
	AddressStringParams

	// AllowsPrefix indicates whether addresses with prefix length like 1.2.0.0/16 are allowed.
	AllowsPrefix() bool

	// EmptyStrParsedAs determines how a zero-length empty string is translated to an address.
	// If the option is ZeroAddressOption or LoopbackOption, then if defers to GetPreferredVersion() for the version.
	EmptyStrParsedAs() EmptyStrOption

	// AllStrParsedAs determines how the "all" string "*" is translated to addresses.
	// If the option is AllPreferredIPVersion, then it defers to GetPreferredVersion() for the version.
	AllStrParsedAs() AllStrOption

	// AllowsMask allows masks to follow valid addresses, such as 1.2.3.4/255.255.0.0 which has the mask 255.255.0.0
	// If the mask is the mask for a network prefix length, this is interpreted as the subnet for that network prefix length.
	// Otherwise the address is simply masked by the mask.
	// For instance, 1.2.3.4/255.0.255.0 is 1.0.3.0, while 1.2.3.4/255.255.0.0 is 1.2.0.0/16.
	AllowsMask() bool

	// GetPreferredVersion indicates the version to use for ambiguous addresses strings,
	// like prefix lengths less than 32 bits which are translated to masks,
	// the "all" address or the "empty" address.
	// The default is IPv6.
	//
	// If either of AllowsIPv4() or AllowsIPv6() returns false, then those settings take precedence over this setting.
	GetPreferredVersion() IPVersion

	// AllowsIPv4 allows IPv4 addresses and subnets.
	AllowsIPv4() bool

	// AllowsIPv6 allows IPv6 addresses and subnets.
	AllowsIPv6() bool

	// GetIPv4Params returns the parameters that apply specifically to IPv4 addresses and subnets.
	GetIPv4Params() IPv4AddressStringParams

	// GetIPv6Params returns the parameters that apply specifically to IPv6 addresses and subnets.
	GetIPv6Params() IPv6AddressStringParams
}

IPAddressStringParams provides parameters for parsing IP address strings, indicating what to allow, what to disallow, and other options.

This allows you to control the validation performed by IPAddressString.

IPAddressString uses a default permissive IPAddressStringParams instance when you do not specify one.

If you wish to use parameters different from the default, then use this interface. Immutable instances can be constructed with IPAddressStringParamsBuilder.

func CopyIPAddressStringParams

func CopyIPAddressStringParams(orig IPAddressStringParams) IPAddressStringParams

CopyIPAddressStringParams produces an immutable copy of the original IPAddressStringParams. Copying an IPAddressStringParams created by an IPAddressStringParamsBuilder is unnecessary since it is already immutable.

type IPAddressStringParamsBuilder

type IPAddressStringParamsBuilder struct {
	AddressStringParamsBuilder
	// contains filtered or unexported fields
}

IPAddressStringParamsBuilder builds an immutable IPAddressStringParameters for controlling parsing of IP address strings.

func (*IPAddressStringParamsBuilder) AllowAll

AllowAll dictates whether to alloww the string of just the wildcard "*" to denote all addresses of all version. If false, then for IP addresses we check the preferred version with GetPreferredVersion, and then check AllowsWildcardedSeparator, to determine if the string represents all addresses of that version.

func (*IPAddressStringParamsBuilder) AllowEmpty

AllowEmpty dictates whether to allow empty zero-length address strings.

func (*IPAddressStringParamsBuilder) AllowIPv4

AllowIPv4 dictates whether to allow IPv4 addresses and subnets

func (*IPAddressStringParamsBuilder) AllowIPv6

AllowIPv6 dictates whether to allow IPv6 addresses and subnets

func (*IPAddressStringParamsBuilder) AllowMask

AllowMask dictates whether to allow masks to follow valid addresses, such as "1.2.3.4/255.255.0.0" which has the mask "255.255.0.0". If the mask is the mask for a network prefix length, this is interpreted as the subnet for that network prefix length. Otherwise the address is simply masked by the mask. For instance, "1.2.3.4/255.0.255.0" is "1.0.3.0", while "1.2.3.4/255.255.0.0" is "1.2.0.0/16".

func (*IPAddressStringParamsBuilder) AllowPrefix

func (builder *IPAddressStringParamsBuilder) AllowPrefix(allow bool) *IPAddressStringParamsBuilder

AllowPrefix dictates whether to allow addresses with prefix length like "1.2.0.0/16" are allowed.

func (*IPAddressStringParamsBuilder) AllowSingleSegment

func (builder *IPAddressStringParamsBuilder) AllowSingleSegment(allow bool) *IPAddressStringParamsBuilder

AllowSingleSegment dictates whether to allow an address to be specified as a single value, eg "ffffffff", without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8".

func (*IPAddressStringParamsBuilder) AllowWildcardedSeparator

func (builder *IPAddressStringParamsBuilder) AllowWildcardedSeparator(allow bool) *IPAddressStringParamsBuilder

AllowWildcardedSeparator dictates whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPAddressStringParamsBuilder) Allow_inet_aton

func (builder *IPAddressStringParamsBuilder) Allow_inet_aton(allow bool) *IPAddressStringParamsBuilder

Allow_inet_aton dictates whether to allow any IPv4 inet_aton format, whether hex, octal, or joined segments.

func (*IPAddressStringParamsBuilder) AllowsAll

func (params *IPAddressStringParamsBuilder) AllowsAll() bool

AllowsAll indicates if we allow the string of just the wildcard "*" to denote all addresses of all version. If false, then for IP addresses we check the preferred version with GetPreferredVersion(), and then check AllowsWildcardedSeparator(), to determine if the string represents all addresses of that version.

func (*IPAddressStringParamsBuilder) AllowsEmpty

func (params *IPAddressStringParamsBuilder) AllowsEmpty() bool

AllowsEmpty indicates whether it allows zero-length address strings: "".

func (*IPAddressStringParamsBuilder) AllowsSingleSegment

func (params *IPAddressStringParamsBuilder) AllowsSingleSegment() bool

AllowsSingleSegment allows an address to be specified as a single value, eg ffffffff, without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8".

func (*IPAddressStringParamsBuilder) GetIPv4AddressParamsBuilder

func (builder *IPAddressStringParamsBuilder) GetIPv4AddressParamsBuilder() (result *IPv4AddressStringParamsBuilder)

GetIPv4AddressParamsBuilder returns a builder that builds the IPv4AddressStringParams for the IPAddressStringParams being built by this builder.

func (*IPAddressStringParamsBuilder) GetIPv6AddressParamsBuilder

func (builder *IPAddressStringParamsBuilder) GetIPv6AddressParamsBuilder() (result *IPv6AddressStringParamsBuilder)

GetIPv6AddressParamsBuilder returns a builder that builds the IPv6AddressStringParams for the IPAddressStringParams being built by this builder.

func (*IPAddressStringParamsBuilder) GetParentBuilder

func (builder *IPAddressStringParamsBuilder) GetParentBuilder() *HostNameParamsBuilder

GetParentBuilder returns the original HostNameParamsBuilder builder that this was obtained from, if this builder was obtained from a HostNameParamsBuilder.

func (*IPAddressStringParamsBuilder) ParseAllStrAs

ParseAllStrAs dictates how the "all" string "*" is translated to addresses. If the option is AllPreferredIPVersion, then it defers to GetPreferredVersion for the version.

func (*IPAddressStringParamsBuilder) ParseEmptyStrAs

ParseEmptyStrAs dictates how a zero-length empty string is translated to an address. If the option is ZeroAddressOption or LoopbackOption, then if defers to GetPreferredVersion for the version.

func (*IPAddressStringParamsBuilder) Set

Set populates this builder with the values from the given IPAddressStringParams.

func (*IPAddressStringParamsBuilder) SetPreferredVersion

func (builder *IPAddressStringParamsBuilder) SetPreferredVersion(version IPVersion) *IPAddressStringParamsBuilder

SetPreferredVersion dictates the version to use for ambiguous addresses strings, like prefix lengths less than 32 bits which are translated to masks, the "all" address or the "empty" address. The default is IPv6.

If either of AllowsIPv4 or AllowsIPv6 returns false, then those settings take precedence over this setting.

func (*IPAddressStringParamsBuilder) SetRangeParams

func (builder *IPAddressStringParamsBuilder) SetRangeParams(rangeParams RangeParams) *IPAddressStringParamsBuilder

SetRangeParams populates this builder with the values from the given RangeParams.

func (*IPAddressStringParamsBuilder) ToParams

ToParams returns an immutable IPAddressStringParams instance built by this builder.

type IPVersion

type IPVersion int

IPVersion is the version type used by IP string parameters. It is interchangeable with the ipaddr.Version, the more generic version type used by the library as a whole.

const (
	// IndeterminateIPVersion represents an unspecified IP address version.
	IndeterminateIPVersion IPVersion = 0

	// IPv4 represents Internet Protocol version 4.
	IPv4 IPVersion = 4

	// IPv6 represents Internet Protocol version 6.
	IPv6 IPVersion = 6
)

func (IPVersion) IsIPv4

func (version IPVersion) IsIPv4() bool

IsIPv4 returns true if this represents version 4

func (IPVersion) IsIPv6

func (version IPVersion) IsIPv6() bool

IsIPv6 returns true if this represents version 6

func (IPVersion) IsIndeterminate

func (version IPVersion) IsIndeterminate() bool

IsIndeterminate returns true if this represents an unspecified IP address version

func (IPVersion) String

func (version IPVersion) String() string

String returns "IPv4", "IPv6", or the zero-value "" representing an indeterminate version

type IPv4AddressStringParams

type IPv4AddressStringParams interface {
	IPAddressStringFormatParams

	// Allows_inet_aton_hex allows IPv4 inet_aton hexadecimal format "0xa.0xb.0xc.0cd".
	Allows_inet_aton_hex() bool

	// Allows_inet_aton_octal allows IPv4 inet_aton octal format, "04.05.06.07" being an example.
	// Can be overridden by allowLeadingZeros
	Allows_inet_aton_octal() bool

	// Allows_inet_aton_joinedSegments allows IPv4 joined segments like "1.2.3", "1.2", or just "1".
	//
	// For the case of just 1 segment, the behaviour is controlled by allowSingleSegment.
	Allows_inet_aton_joinedSegments() bool

	// Allows_inet_aton_single_segment_mask indicates whether you allow a mask that looks like a prefix length when you allow IPv4 joined segments: "1.2.3.5/255".
	Allows_inet_aton_single_segment_mask() bool

	// Allows_inet_aton_leading_zeros allows IPv4 inet_aton hexadecimal or octal to have leading zeros, such as in the first two segments of "0x0a.00b.c.d".
	// The first 0 is not considered a leading zero, it either denotes octal or hex depending on whether it is followed by an 'x'.
	// Zeros that appear afterwards are inet_aton leading zeros.
	Allows_inet_aton_leading_zeros() bool
}

IPv4AddressStringParams provides parameters specific to IPv4 addresses and subnets

type IPv4AddressStringParamsBuilder

type IPv4AddressStringParamsBuilder struct {
	IPAddressStringFormatParamsBuilder
	// contains filtered or unexported fields
}

IPv4AddressStringParamsBuilder builds an immutable IPv4AddressStringParams for controlling parsing of IPv4 address strings.

func (*IPv4AddressStringParamsBuilder) AllowBinary

AllowBinary dictates whether to allow binary addresses like "11111111.0.1.0" or "1111111111111111::".

func (*IPv4AddressStringParamsBuilder) AllowLeadingZeros

func (builder *IPv4AddressStringParamsBuilder) AllowLeadingZeros(allow bool) *IPv4AddressStringParamsBuilder

AllowLeadingZeros dictates whether to allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*IPv4AddressStringParamsBuilder) AllowPrefixLenLeadingZeros

func (builder *IPv4AddressStringParamsBuilder) AllowPrefixLenLeadingZeros(allow bool) *IPv4AddressStringParamsBuilder

AllowPrefixLenLeadingZeros dictates whether to allow leading zeros in the prefix length like "1.2.3.4/016".

func (*IPv4AddressStringParamsBuilder) AllowPrefixesBeyondAddressSize

func (builder *IPv4AddressStringParamsBuilder) AllowPrefixesBeyondAddressSize(allow bool) *IPv4AddressStringParamsBuilder

AllowPrefixesBeyondAddressSize dictates whether to allow prefix length values greater than 32 for IPv4 or greater than 128 for IPv6.

func (*IPv4AddressStringParamsBuilder) AllowUnlimitedLeadingZeros

func (builder *IPv4AddressStringParamsBuilder) AllowUnlimitedLeadingZeros(allow bool) *IPv4AddressStringParamsBuilder

AllowUnlimitedLeadingZeros dictates whether to allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004">

func (*IPv4AddressStringParamsBuilder) AllowWildcardedSeparator

func (builder *IPv4AddressStringParamsBuilder) AllowWildcardedSeparator(allow bool) *IPv4AddressStringParamsBuilder

AllowWildcardedSeparator dictates whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton dictates whether to allow any IPv4 inet_aton format, whether hex, octal, or joined segments.

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton_hex

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton_hex(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton_hex dictates whether to allow IPv4 inet_aton hexadecimal format "0xa.0xb.0xc.0cd".

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton_joinedSegments

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton_joinedSegments(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton_joinedSegments dictates whether to allow IPv4 joined segments like "1.2.3", "1.2", or just "1".

For the case of just 1 segment, the behaviour is controlled by AllowSingleSegment.

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton_leading_zeros

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton_leading_zeros(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton_leading_zeros dictates whether to allow IPv4 inet_aton hexadecimal or octal to have leading zeros, such as in the first two segments of "0x0a.00b.c.d".

The first 0 is not considered a leading zero, it either denotes octal or hex depending on whether it is followed by an 'x'.
Zeros that appear afterwards are inet_aton leading zeros.

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton_octal

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton_octal(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton_octal dictates whether to allow IPv4 inet_aton octal format, "04.05.06.07" being an example.

func (*IPv4AddressStringParamsBuilder) Allow_inet_aton_single_segment_mask

func (builder *IPv4AddressStringParamsBuilder) Allow_inet_aton_single_segment_mask(allow bool) *IPv4AddressStringParamsBuilder

Allow_inet_aton_single_segment_mask dictates whether to allow a mask that looks like a prefix length when you allow IPv4 joined segments: "1.2.3.5/255".

func (*IPv4AddressStringParamsBuilder) AllowsLeadingZeros

func (params *IPv4AddressStringParamsBuilder) AllowsLeadingZeros() bool

AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*IPv4AddressStringParamsBuilder) AllowsUnlimitedLeadingZeros

func (params *IPv4AddressStringParamsBuilder) AllowsUnlimitedLeadingZeros() bool

AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004".

func (*IPv4AddressStringParamsBuilder) AllowsWildcardedSeparator

func (params *IPv4AddressStringParamsBuilder) AllowsWildcardedSeparator() bool

AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPv4AddressStringParamsBuilder) GetEmbeddedIPv4AddressParentBuilder

func (builder *IPv4AddressStringParamsBuilder) GetEmbeddedIPv4AddressParentBuilder() *IPv6AddressStringParamsBuilder

GetEmbeddedIPv4AddressParentBuilder the parent IPv6AddressStringParamsBuilder, if this builder was obtained by a call to getEmbeddedIPv4ParamsBuilder() from IPv6AddressStringParamsBuilder.

func (*IPv4AddressStringParamsBuilder) GetRangeParams

func (params *IPv4AddressStringParamsBuilder) GetRangeParams() RangeParams

GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.

func (*IPv4AddressStringParamsBuilder) GetRangeParamsBuilder

func (builder *IPv4AddressStringParamsBuilder) GetRangeParamsBuilder() *RangeParamsBuilder

GetRangeParamsBuilder returns a builder that builds the range parameters for these IPv4 address string parameters.

func (*IPv4AddressStringParamsBuilder) Set

Set populates this builder with the values from the given IPv4AddressStringParams.

func (*IPv4AddressStringParamsBuilder) SetRangeParams

func (builder *IPv4AddressStringParamsBuilder) SetRangeParams(rangeParams RangeParams) *IPv4AddressStringParamsBuilder

SetRangeParams populates this builder with the values from the given RangeParams.

func (*IPv4AddressStringParamsBuilder) ToParams

ToParams returns an immutable IPv4AddressStringParams instance built by this builder.

type IPv6AddressStringParams

type IPv6AddressStringParams interface {
	IPAddressStringFormatParams

	// AllowsMixed allows mixed-in embedded IPv4 like "a:b:c:d:e:f:1.2.3.4".
	AllowsMixed() bool

	// AllowsZone allows zones like "a:b:c:d:e:f:a:b%zone".
	AllowsZone() bool

	// AllowsEmptyZone allows the zone character % with no following zone.
	AllowsEmptyZone() bool

	// AllowsBase85 allows IPv6 single-segment base 85 addresses.
	AllowsBase85() bool

	// GetMixedParams provides the IP parameters that for parsing the embedded IPv4 section of a mixed IPv6/v4 address, if AllowsMixed is true.
	GetMixedParams() IPAddressStringParams

	// GetEmbeddedIPv4AddressParams returns the IPv4 parameters for parsing the embedded IPv4 section of a mixed IPv6/v4 address.
	GetEmbeddedIPv4AddressParams() IPv4AddressStringParams
}

IPv6AddressStringParams provides parameters specific to IPv6 addresses and subnets.

type IPv6AddressStringParamsBuilder

type IPv6AddressStringParamsBuilder struct {
	IPAddressStringFormatParamsBuilder
	// contains filtered or unexported fields
}

IPv6AddressStringParamsBuilder builds an immutable IPv6AddressStringParams for controlling parsing of IPv6 address strings'

func (*IPv6AddressStringParamsBuilder) AllowBase85

AllowBase85 dictates whether to allow IPv6 single-segment base 85 addresses.

func (*IPv6AddressStringParamsBuilder) AllowBinary

AllowBinary dictates whether to allow binary addresses like "11111111.0.1.0" or "1111111111111111::".

func (*IPv6AddressStringParamsBuilder) AllowEmptyZone

func (builder *IPv6AddressStringParamsBuilder) AllowEmptyZone(allow bool) *IPv6AddressStringParamsBuilder

AllowEmptyZone dictates whether to allow the zone character % with no following zone

func (*IPv6AddressStringParamsBuilder) AllowLeadingZeros

func (builder *IPv6AddressStringParamsBuilder) AllowLeadingZeros(allow bool) *IPv6AddressStringParamsBuilder

AllowLeadingZeros dictates whether to allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*IPv6AddressStringParamsBuilder) AllowMixed

AllowMixed dictates whether to allow mixed-in embedded IPv4 like "a:b:c:d:e:f:1.2.3.4".

func (*IPv6AddressStringParamsBuilder) AllowPrefixLenLeadingZeros

func (builder *IPv6AddressStringParamsBuilder) AllowPrefixLenLeadingZeros(allow bool) *IPv6AddressStringParamsBuilder

AllowPrefixLenLeadingZeros dictates whether to allow leading zeros in the prefix length like "1.2.3.4/016".

func (*IPv6AddressStringParamsBuilder) AllowPrefixesBeyondAddressSize

func (builder *IPv6AddressStringParamsBuilder) AllowPrefixesBeyondAddressSize(allow bool) *IPv6AddressStringParamsBuilder

AllowPrefixesBeyondAddressSize dictates whether to allow prefix length values greater than 32 for IPv4 or greater than 128 for IPv6.

func (*IPv6AddressStringParamsBuilder) AllowUnlimitedLeadingZeros

func (builder *IPv6AddressStringParamsBuilder) AllowUnlimitedLeadingZeros(allow bool) *IPv6AddressStringParamsBuilder

AllowUnlimitedLeadingZeros dictates whether to allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow 0001.0002.0003.0004

func (*IPv6AddressStringParamsBuilder) AllowWildcardedSeparator

func (builder *IPv6AddressStringParamsBuilder) AllowWildcardedSeparator(allow bool) *IPv6AddressStringParamsBuilder

AllowWildcardedSeparator dictates whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPv6AddressStringParamsBuilder) AllowZone

AllowZone dictates whether to allow zones like "a:b:c:d:e:f:a:b%zone".

func (*IPv6AddressStringParamsBuilder) Allow_mixed_inet_aton

func (builder *IPv6AddressStringParamsBuilder) Allow_mixed_inet_aton(allow bool) *IPv6AddressStringParamsBuilder

Allow_mixed_inet_aton dictates whether to allow inet_aton style formats, whether hex, octal, or joined segments, in the embedded IPv4 section of a mixed IPv6/v4 address.

func (*IPv6AddressStringParamsBuilder) AllowsBase85

func (builder *IPv6AddressStringParamsBuilder) AllowsBase85() bool

AllowsBase85 allows IPv6 single-segment base 85 addresses.

func (*IPv6AddressStringParamsBuilder) AllowsEmptyZone

func (builder *IPv6AddressStringParamsBuilder) AllowsEmptyZone() bool

AllowsEmptyZone allows the zone character % with no following zone.

func (*IPv6AddressStringParamsBuilder) AllowsLeadingZeros

func (params *IPv6AddressStringParamsBuilder) AllowsLeadingZeros() bool

AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*IPv6AddressStringParamsBuilder) AllowsMixed

func (builder *IPv6AddressStringParamsBuilder) AllowsMixed() bool

AllowsMixed allows mixed-in embedded IPv4 like "a:b:c:d:e:f:1.2.3.4".

func (*IPv6AddressStringParamsBuilder) AllowsUnlimitedLeadingZeros

func (params *IPv6AddressStringParamsBuilder) AllowsUnlimitedLeadingZeros() bool

AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004".

func (*IPv6AddressStringParamsBuilder) AllowsWildcardedSeparator

func (params *IPv6AddressStringParamsBuilder) AllowsWildcardedSeparator() bool

AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*IPv6AddressStringParamsBuilder) AllowsZone

func (builder *IPv6AddressStringParamsBuilder) AllowsZone() bool

AllowsZone allows zones like "a:b:c:d:e:f:a:b%zone".

func (*IPv6AddressStringParamsBuilder) GetEmbeddedIPv4AddressParamsBuilder

func (builder *IPv6AddressStringParamsBuilder) GetEmbeddedIPv4AddressParamsBuilder() (result *IPv4AddressStringParamsBuilder)

GetEmbeddedIPv4AddressParamsBuilder returns a builder to build the IPv4 parameters that controls parsing of the embedded IPv4 section of a mixed IPv6/v4 address.

func (*IPv6AddressStringParamsBuilder) GetRangeParams

func (params *IPv6AddressStringParamsBuilder) GetRangeParams() RangeParams

GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.

func (*IPv6AddressStringParamsBuilder) GetRangeParamsBuilder

func (builder *IPv6AddressStringParamsBuilder) GetRangeParamsBuilder() *RangeParamsBuilder

GetRangeParamsBuilder returns a builder that builds the range parameters for these IPv6 address string parameters.

func (*IPv6AddressStringParamsBuilder) Set

Set populates this builder with the values from the given IPv6AddressStringParams.

func (*IPv6AddressStringParamsBuilder) SetRangeParams

func (builder *IPv6AddressStringParamsBuilder) SetRangeParams(rangeParams RangeParams) *IPv6AddressStringParamsBuilder

SetRangeParams populates this builder with the values from the given RangeParams.

func (*IPv6AddressStringParamsBuilder) ToParams

ToParams returns an immutable IPv6AddressStringParams instance built by this builder'

type MACAddressLen

type MACAddressLen string

MACAddressLen is an option indicating a MAC address length.

const (
	// MAC48Len indicates 48-bit MAC addresses.
	MAC48Len MACAddressLen = "MAC48"

	// EUI64Len indicates 64-bit MAC addresses.
	EUI64Len MACAddressLen = "EUI64"

	// UnspecifiedMACLen indicates unspecified bit-length MAC addresses.
	UnspecifiedMACLen MACAddressLen = ""
)

type MACAddressStringFormatParams

type MACAddressStringFormatParams interface {
	AddressStringFormatParams

	// AllowsShortSegments allows segments that are just a single hex digit and not two.
	AllowsShortSegments() bool
}

MACAddressStringFormatParams provides format parameters for MAC addresses, indicating what formatting is allowed.

type MACAddressStringFormatParamsBuilder

type MACAddressStringFormatParamsBuilder struct {
	AddressStringFormatParamsBuilder
	// contains filtered or unexported fields
}

MACAddressStringFormatParamsBuilder builds an immutable MACAddressStringFormatParams for controlling parsing of MAC address strings.

func (*MACAddressStringFormatParamsBuilder) AllowLeadingZeros

AllowLeadingZeros dictates whether to allow addresses with segments that have leasing zeros like "01:02:03:04:05:06".

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*MACAddressStringFormatParamsBuilder) AllowShortSegments

AllowShortSegments dictates whether to allow segments that are just a single hex digit and not two.

func (*MACAddressStringFormatParamsBuilder) AllowUnlimitedLeadingZeros

func (builder *MACAddressStringFormatParamsBuilder) AllowUnlimitedLeadingZeros(allow bool) *MACAddressStringFormatParamsBuilder

AllowUnlimitedLeadingZeros dictates whether to allow leading zeros that extend segments beyond the usual segment length of 2 hex digits. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true.

func (*MACAddressStringFormatParamsBuilder) AllowWildcardedSeparator

func (builder *MACAddressStringFormatParamsBuilder) AllowWildcardedSeparator(allow bool) *MACAddressStringFormatParamsBuilder

AllowWildcardedSeparator dictates whether the wildcard '*' or '%' can replace the segment separators '.', '-' and ':'. If so, then you can write addresses like "*.*" or "*:*".

func (*MACAddressStringFormatParamsBuilder) AllowsLeadingZeros

func (params *MACAddressStringFormatParamsBuilder) AllowsLeadingZeros() bool

AllowsLeadingZeros indicates whether you allow addresses with segments that have leasing zeros like "001.2.3.004" or "1:000a::". For IPV4, this option overrides inet_aton octal.

Single segment addresses that must have the requisite length to be parsed are not affected by this flag.

func (*MACAddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros

func (params *MACAddressStringFormatParamsBuilder) AllowsUnlimitedLeadingZeros() bool

AllowsUnlimitedLeadingZeros determines if you allow leading zeros that extend segments beyond the usual segment length, which is 3 for IPv4 dotted-decimal and 4 for IPv6. However, this only takes effect if leading zeros are allowed, which is when AllowsLeadingZeros is true or the address is IPv4 and Allows_inet_aton_octal is true.

For example, this determines whether you allow "0001.0002.0003.0004".

func (*MACAddressStringFormatParamsBuilder) AllowsWildcardedSeparator

func (params *MACAddressStringFormatParamsBuilder) AllowsWildcardedSeparator() bool

AllowsWildcardedSeparator controls whether the wildcard '*' or '%' can replace the segment separators '.' and ':'. If so, then you can write addresses like *.* or *:*

func (*MACAddressStringFormatParamsBuilder) GetParentBuilder

GetParentBuilder returns the original MACAddressStringParamsBuilder builder that this was obtained from, if this builder was obtained from a MACAddressStringParamsBuilder.

func (*MACAddressStringFormatParamsBuilder) GetRangeParams

func (params *MACAddressStringFormatParamsBuilder) GetRangeParams() RangeParams

GetRangeParams returns the RangeParams describing whether ranges of values are allowed and what wildcards are allowed.

func (*MACAddressStringFormatParamsBuilder) GetRangeParamsBuilder

func (builder *MACAddressStringFormatParamsBuilder) GetRangeParamsBuilder() *RangeParamsBuilder

GetRangeParamsBuilder returns a builder that builds the range parameters for these MAC address string format parameters.

func (*MACAddressStringFormatParamsBuilder) Set

Set populates this builder with the values from the given MACAddressStringFormatParams.

func (*MACAddressStringFormatParamsBuilder) SetRangeParams

SetRangeParams populates this builder with the values from the given RangeParams.

func (*MACAddressStringFormatParamsBuilder) ToParams

ToParams returns an immutable MACAddressStringFormatParams instance built by this builder.

type MACAddressStringParams

type MACAddressStringParams interface {
	AddressStringParams

	// GetPreferredLen indicates whether an ambiguous address like * is considered to be MAC 6 bytes, EUI-64 8 bytes, or either one.
	GetPreferredLen() MACAddressLen

	// AllowsDashed allows addresses like "aa-bb-cc-dd-ee-ff".
	AllowsDashed() bool

	// AllowsSingleDashed allows addresses like "aabbcc-ddeeff".
	AllowsSingleDashed() bool

	// AllowsColonDelimited allows addresses like "aa:bb:cc:dd:ee:ff".
	AllowsColonDelimited() bool

	// AllowsDotted allows addresses like "aaa.bbb.ccc.ddd".
	AllowsDotted() bool

	// AllowsSpaceDelimited allows addresses like "aa bb cc dd ee ff".
	AllowsSpaceDelimited() bool

	// GetFormatParams returns the parameters that apply to formatting of the address segments.
	GetFormatParams() MACAddressStringFormatParams
}

MACAddressStringParams provides parameters for parsing MAC address strings.

This allows you to control the validation performed by the MACAddressString.

MACAddressString uses a default permissive MACAddressStringParams instance when you do not specify one.

If you wish to use parameters different from the default, then use this interface. Immutable instances can be constructed with MACAddressStringParamsBuilder.

func CopyMACAddressStringParams

func CopyMACAddressStringParams(orig MACAddressStringParams) MACAddressStringParams

CopyMACAddressStringParams produces an immutable copy of the original MACAddressStringParams. Copying a MACAddressStringParams created by a MACAddressStringParamsBuilder is unnecessary since it is already immutable.

type MACAddressStringParamsBuilder

type MACAddressStringParamsBuilder struct {
	AddressStringParamsBuilder
	// contains filtered or unexported fields
}

MACAddressStringParamsBuilder builds an immutable MACAddressStringParameters for controlling parsing of MAC address strings.

func (*MACAddressStringParamsBuilder) AllowAll

AllowAll dictates whether to allow the string of just the wildcard "*" to denote all MAC addresses.

func (*MACAddressStringParamsBuilder) AllowColonDelimited

func (builder *MACAddressStringParamsBuilder) AllowColonDelimited(allow bool) *MACAddressStringParamsBuilder

AllowColonDelimited dictates whether to allow addresses like "aa:bb:cc:dd:ee:ff".

func (*MACAddressStringParamsBuilder) AllowDashed

AllowDashed dictates whether to allow addresses like "aa-bb-cc-dd-ee-ff".

func (*MACAddressStringParamsBuilder) AllowDotted

AllowDotted dictates whether to allow addresses like "aaa.bbb.ccc.ddd".

func (*MACAddressStringParamsBuilder) AllowEmpty

AllowEmpty dictates whether to allow empty zero-length address strings.

func (*MACAddressStringParamsBuilder) AllowSingleDashed

func (builder *MACAddressStringParamsBuilder) AllowSingleDashed(allow bool) *MACAddressStringParamsBuilder

AllowSingleDashed dictates whether to allow addresses like "aabbcc-ddeeff".

func (*MACAddressStringParamsBuilder) AllowSingleSegment

func (builder *MACAddressStringParamsBuilder) AllowSingleSegment(allow bool) *MACAddressStringParamsBuilder

AllowSingleSegment dictates whether to allow an address to be specified as a single value, eg "ffffffff", without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8".

func (*MACAddressStringParamsBuilder) AllowSpaceDelimited

func (builder *MACAddressStringParamsBuilder) AllowSpaceDelimited(allow bool) *MACAddressStringParamsBuilder

AllowSpaceDelimited dictates whether to allow addresses like "aa bb cc dd ee ff".

func (*MACAddressStringParamsBuilder) AllowWildcardedSeparator

func (builder *MACAddressStringParamsBuilder) AllowWildcardedSeparator(allow bool) *MACAddressStringParamsBuilder

AllowWildcardedSeparator dictates whether the wildcard '*' or '%' can replace the segment separators '.', '-' and ':'. If so, then you can write addresses like "*.*" or "*:*".

func (*MACAddressStringParamsBuilder) AllowsAll

func (params *MACAddressStringParamsBuilder) AllowsAll() bool

AllowsAll indicates if we allow the string of just the wildcard "*" to denote all addresses of all version. If false, then for IP addresses we check the preferred version with GetPreferredVersion(), and then check AllowsWildcardedSeparator(), to determine if the string represents all addresses of that version.

func (*MACAddressStringParamsBuilder) AllowsEmpty

func (params *MACAddressStringParamsBuilder) AllowsEmpty() bool

AllowsEmpty indicates whether it allows zero-length address strings: "".

func (*MACAddressStringParamsBuilder) AllowsSingleSegment

func (params *MACAddressStringParamsBuilder) AllowsSingleSegment() bool

AllowsSingleSegment allows an address to be specified as a single value, eg ffffffff, without the standard use of segments like "1.2.3.4" or "1:2:4:3:5:6:7:8".

func (*MACAddressStringParamsBuilder) GetFormatParamsBuilder

func (builder *MACAddressStringParamsBuilder) GetFormatParamsBuilder() (result *MACAddressStringFormatParamsBuilder)

GetFormatParamsBuilder returns a builder that builds the MACAddressStringFormatParams for the MACAddressStringParams being built by this builder.

func (*MACAddressStringParamsBuilder) Set

Set populates this builder with the values from the given MACAddressStringParams.

func (*MACAddressStringParamsBuilder) SetPreferredLen

SetPreferredLen indicates the length for an ambiguous address like *, whether it is considered to be MAC 6 bytes, EUI-64 8 bytes, or either one.

func (*MACAddressStringParamsBuilder) SetRangeParams

func (builder *MACAddressStringParamsBuilder) SetRangeParams(rangeParams RangeParams) *MACAddressStringParamsBuilder

SetRangeParams populates this builder with the values from the given RangeParams.

func (*MACAddressStringParamsBuilder) ToParams

ToParams returns an immutable MACAddressStringParams instance built by this builder.

type RangeParams

type RangeParams interface {
	// AllowsWildcard indicates whether '*' is allowed to denote segments covering all possible segment values
	AllowsWildcard() bool

	// AllowsRangeSeparator indicates whether '-' (or the expected range separator for the address) is allowed to denote a range from lower to higher, like 1-10
	AllowsRangeSeparator() bool

	// AllowsSingleWildcard indicates whether to allow a segment terminating with '_' characters, which represent any digit
	AllowsSingleWildcard() bool

	// AllowsReverseRange indicates whether '-' (or the expected range separator for the address) is allowed to denote a range from higher to lower, like 10-1
	AllowsReverseRange() bool

	// AllowsInferredBoundary indicates whether a missing range value before or after a '-' is allowed to denote the mininum or maximum potential value
	AllowsInferredBoundary() bool
}

RangeParams indicates what wildcards and ranges are allowed in the string.

var (
	// NoRange - use no wildcards nor range separators
	NoRange RangeParams = &rangeParameters{
		noWildcard:         true,
		noValueRange:       true,
		noReverseRange:     true,
		noSingleWildcard:   true,
		noInferredBoundary: true,
	}

	// WildcardOnly - use this to support addresses like "1.*.3.4" or "1::*:3" or "1.2_.3.4" or "1::a__:3"
	WildcardOnly RangeParams = &rangeParameters{
		noValueRange:   true,
		noReverseRange: true,
	}

	// WildcardAndRange - use this to support addresses supported by the default wildcard options and also addresses like "1.2-3.3.4" or "1:0-ff::".
	WildcardAndRange RangeParams = &rangeParameters{}
)

type RangeParamsBuilder

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

RangeParamsBuilder is used to build an immutable RangeParams for parsing address strings.

func (*RangeParamsBuilder) AllowInferredBoundary

func (builder *RangeParamsBuilder) AllowInferredBoundary(allow bool) *RangeParamsBuilder

AllowInferredBoundary dictates whether a missing range value before or after a '-' is allowed to denote the mininum or maximum potential value.

func (*RangeParamsBuilder) AllowRangeSeparator

func (builder *RangeParamsBuilder) AllowRangeSeparator(allow bool) *RangeParamsBuilder

AllowRangeSeparator dictates whether '-' (or the expected range separator for the address) is allowed to denote a range from lower to higher, like 1-10.

func (*RangeParamsBuilder) AllowReverseRange

func (builder *RangeParamsBuilder) AllowReverseRange(allow bool) *RangeParamsBuilder

AllowReverseRange dictates whether '-' (or the expected range separator for the address) is allowed to denote a range from higher to lower, like 10-1.

func (*RangeParamsBuilder) AllowSingleWildcard

func (builder *RangeParamsBuilder) AllowSingleWildcard(allow bool) *RangeParamsBuilder

AllowSingleWildcard dictates whether to allow a segment terminating with '_' characters, which represent any digit.

func (*RangeParamsBuilder) AllowWildcard

func (builder *RangeParamsBuilder) AllowWildcard(allow bool) *RangeParamsBuilder

AllowWildcard dictates whether '*' is allowed to denote segments covering all possible segment values.

func (*RangeParamsBuilder) AllowsInferredBoundary

func (builder *RangeParamsBuilder) AllowsInferredBoundary() bool

AllowsInferredBoundary indicates whether a missing range value before or after a '-' is allowed to denote the mininum or maximum potential value.

func (*RangeParamsBuilder) AllowsRangeSeparator

func (builder *RangeParamsBuilder) AllowsRangeSeparator() bool

AllowsRangeSeparator indicates whether '-' (or the expected range separator for the address) is allowed to denote a range from lower to higher, like 1-10.

func (*RangeParamsBuilder) AllowsReverseRange

func (builder *RangeParamsBuilder) AllowsReverseRange() bool

AllowsReverseRange indicates whether '-' (or the expected range separator for the address) is allowed to denote a range from higher to lower, like 10-1.

func (*RangeParamsBuilder) AllowsSingleWildcard

func (builder *RangeParamsBuilder) AllowsSingleWildcard() bool

AllowsSingleWildcard indicates whether to allow a segment terminating with '_' characters, which represent any digit.

func (*RangeParamsBuilder) AllowsWildcard

func (builder *RangeParamsBuilder) AllowsWildcard() bool

AllowsWildcard indicates whether '*' is allowed to denote segments covering all possible segment values.

func (*RangeParamsBuilder) GetIPv4ParentBuilder

func (builder *RangeParamsBuilder) GetIPv4ParentBuilder() *IPv4AddressStringParamsBuilder

GetIPv4ParentBuilder returns the IPv4AddressStringParamsBuilder if this builder was obtained by a call to IPv4AddressStringParamsBuilder.GetRangeParamsBuilder.

func (*RangeParamsBuilder) GetIPv6ParentBuilder

func (builder *RangeParamsBuilder) GetIPv6ParentBuilder() *IPv6AddressStringParamsBuilder

GetIPv6ParentBuilder returns the IPv6AddressStringParamsBuilder if this builder was obtained by a call to IPv6AddressStringParamsBuilder.GetRangeParamsBuilder.

func (*RangeParamsBuilder) GetMACParentBuilder

func (builder *RangeParamsBuilder) GetMACParentBuilder() *MACAddressStringFormatParamsBuilder

GetMACParentBuilder returns the IPv6AddressStringParamsBuilder if this builder was obtained by a call to IPv6AddressStringParamsBuilder.GetRangeParamsBuilder.

func (*RangeParamsBuilder) Set

func (builder *RangeParamsBuilder) Set(rangeParams RangeParams) *RangeParamsBuilder

Set initializes this builder with the values from the given RangeParams.

func (*RangeParamsBuilder) ToParams

func (builder *RangeParamsBuilder) ToParams() RangeParams

ToParams returns an immutable RangeParams instance built by this builder.

Jump to

Keyboard shortcuts

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