MCPcopy Index your code
hub / github.com/XTLS/REALITY / validDNSName

Function validDNSName

ech.go:476–499  ·  view source on GitHub ↗

validDNSName is a rather rudimentary check for the validity of a DNS name. This is used to check if the public_name in a ECHConfig is valid when we are picking a config. This can be somewhat lax because even if we pick a valid-looking name, the DNS layer will later reject it anyway.

(name string)

Source from the content-addressed store, hash-verified

474// picking a config. This can be somewhat lax because even if we pick a
475// valid-looking name, the DNS layer will later reject it anyway.
476func validDNSName(name string) bool {
477 if len(name) > 253 {
478 return false
479 }
480 labels := strings.Split(name, ".")
481 if len(labels) <= 1 {
482 return false
483 }
484 for _, l := range labels {
485 labelLen := len(l)
486 if labelLen == 0 {
487 return false
488 }
489 for i, r := range l {
490 if r == '-' && (i == 0 || i == labelLen-1) {
491 return false
492 }
493 if (r < '0' || r > '9') && (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') && r != '-' {
494 return false
495 }
496 }
497 }
498 return true
499}
500
501// ECHRejectionError is the error type returned when ECH is rejected by a remote
502// server. If the server offered a ECHConfigList to use for retries, the

Callers 1

pickECHConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…