octodns.record.srv
Classes
|
Strict SRV name validator per RFC 2782 and RFC 6335 §5.1. |
|
Validates that an SRV record's name matches the |
|
|
|
|
|
Checks that the SRV |
|
Strict SRV rdata validator per RFC 2782. |
|
Validates SRV rdata: priority, weight, and port are present and integer-parsable, and target is a valid FQDN. |
- class octodns.record.srv.SrvNameValidator(id, sets=None)[source]
Bases:
RecordValidatorValidates that an SRV record’s name matches the
_service._protocolpattern required by RFC 2782 (e.g._http._tcp), or is a wildcard.- _name_re = re.compile('^(\\*|_[^\\.]+)\\.[^\\.]+')
- validate(record_cls, name, fqdn, data)[source]
Validate a record’s non-value attributes.
- Parameters:
record_cls (type) – The concrete
Recordsubclass being validated. Validators that need access to record class-level attributes (e.g._type,_value_type) should read them fromrecord_cls. Per-instance configuration should live onself, not onrecord_cls.name (str) – The record’s name relative to its zone (
''for the zone root). Alreadyidna_encode’d.fqdn (str) – The record’s fully-qualified domain name (
name+ zone name).data (dict) – The raw record config dict (as loaded from YAML/JSON) including
ttl,type,value/values, and any type-specific fields likedynamic,geo, oroctodns.
- Returns:
A list of human-readable reason strings describing validation failures. Must return an empty list when the record is valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others.
- Return type:
Notes
Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in
ValidationErrormessages, so phrasing and punctuation should be stable across releases.
- class octodns.record.srv.SrvValueValidator(id, sets=None)[source]
Bases:
ValueValidatorValidates SRV rdata: priority, weight, and port are present and integer-parsable, and target is a valid FQDN.
- validate(value_cls, data, _type)[source]
Validate a record’s rdata values.
- Parameters:
value_cls (type) – The concrete value class being validated (e.g.
MxValue,_Ipv4Value). Validators that need access to value class-level attributes (e.g.VALID_ALGORITHMS,_address_type) should read them fromvalue_cls. Per-instance configuration should live onself, not onvalue_cls.data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate
datadirectly — when a validator needs to accept either form it should normalize withif not isinstance(data, (list, tuple)): data = (data,)._type (str) – The record type string (e.g.
'MX','A'). Passed through to helpers like_check_target_formatwhich format it into their reason strings.
- Returns:
A list of human-readable reason strings describing validation failures. Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others.
- Return type:
Notes
Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in
ValidationErrormessages, so phrasing and punctuation should be stable across releases.
- class octodns.record.srv.SrvNameRfcValidator(id, sets=None)[source]
Bases:
RecordValidatorStrict SRV name validator per RFC 2782 and RFC 6335 §5.1.
Requires the first two labels of the record name to be
_service._proto(*._protois still accepted for wildcards). Both the service and proto label bodies (after the leading_) must conform to the RFC 6335 §5.1 service name syntax: 1-15 characters, starting with a letter, ending with a letter or digit, containing only letters, digits, and hyphens, and with no consecutive hyphens.Enabled as part of the
rfcvalidator set:manager: enabled: - rfc
- _max_len = 15
- validate(record_cls, name, fqdn, data)[source]
Validate a record’s non-value attributes.
- Parameters:
record_cls (type) – The concrete
Recordsubclass being validated. Validators that need access to record class-level attributes (e.g._type,_value_type) should read them fromrecord_cls. Per-instance configuration should live onself, not onrecord_cls.name (str) – The record’s name relative to its zone (
''for the zone root). Alreadyidna_encode’d.fqdn (str) – The record’s fully-qualified domain name (
name+ zone name).data (dict) – The raw record config dict (as loaded from YAML/JSON) including
ttl,type,value/values, and any type-specific fields likedynamic,geo, oroctodns.
- Returns:
A list of human-readable reason strings describing validation failures. Must return an empty list when the record is valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others.
- Return type:
Notes
Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in
ValidationErrormessages, so phrasing and punctuation should be stable across releases.
- class octodns.record.srv.SrvValueRfcValidator(id, sets=None)[source]
Bases:
ValueValidatorStrict SRV rdata validator per RFC 2782.
priority,weight, andportmust each be in the 0-65535 range.When
targetis".",priority,weight, andportmust all be0(RFC 2782 “service not available” convention).When
targetis not".",portmust be greater than 0 (port 0 is IANA-reserved).
Assumes the base
SrvValueValidatorhas already caught missing or non-integer fields; entries that fail those checks are skipped here to avoid duplicated reasons. Enabled as part of therfcvalidator set:manager: enabled: - rfc
- validate(value_cls, data, _type)[source]
Validate a record’s rdata values.
- Parameters:
value_cls (type) – The concrete value class being validated (e.g.
MxValue,_Ipv4Value). Validators that need access to value class-level attributes (e.g.VALID_ALGORITHMS,_address_type) should read them fromvalue_cls. Per-instance configuration should live onself, not onvalue_cls.data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate
datadirectly — when a validator needs to accept either form it should normalize withif not isinstance(data, (list, tuple)): data = (data,)._type (str) – The record type string (e.g.
'MX','A'). Passed through to helpers like_check_target_formatwhich format it into their reason strings.
- Returns:
A list of human-readable reason strings describing validation failures. Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others.
- Return type:
Notes
Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in
ValidationErrormessages, so phrasing and punctuation should be stable across releases.
- class octodns.record.srv.SrvValueBestPracticeValidator(id, sets=None)[source]
Bases:
ValueValidatorChecks that the SRV
targetfield ends with a trailing.(fully-qualified name).Enabled as part of the
best-practicevalidator set:manager: enabled: - best-practice
- validate(value_cls, data, _type)[source]
Validate a record’s rdata values.
- Parameters:
value_cls (type) – The concrete value class being validated (e.g.
MxValue,_Ipv4Value). Validators that need access to value class-level attributes (e.g.VALID_ALGORITHMS,_address_type) should read them fromvalue_cls. Per-instance configuration should live onself, not onvalue_cls.data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate
datadirectly — when a validator needs to accept either form it should normalize withif not isinstance(data, (list, tuple)): data = (data,)._type (str) – The record type string (e.g.
'MX','A'). Passed through to helpers like_check_target_formatwhich format it into their reason strings.
- Returns:
A list of human-readable reason strings describing validation failures. Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others.
- Return type:
Notes
Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in
ValidationErrormessages, so phrasing and punctuation should be stable across releases.
- class octodns.record.srv.SrvValue(value)[source]
Bases:
EqualityTupleMixin,dict- VALIDATORS = [<octodns.record.srv.SrvValueValidator object>, <octodns.record.srv.SrvValueRfcValidator object>, <octodns.record.srv.SrvValueBestPracticeValidator object>]
- property priority
- property weight
- property port
- property target
- property data
- property rdata_text
- class octodns.record.srv.SrvRecord(zone, name, data, source=None, context=None)[source]
Bases:
ValuesMixin,Record- REFERENCES = ('https://datatracker.ietf.org/doc/html/rfc2782', 'https://datatracker.ietf.org/doc/html/rfc6335')
- _type = 'SRV'
- VALIDATORS = [<octodns.record.srv.SrvNameValidator object>, <octodns.record.srv.SrvNameRfcValidator object>]