SubjectIsInternal returns true if subj is an internal-facing hostname or address, including localhost/loopback hosts. Ports are ignored, if present.
(subj string)
| 607 | // hostname or address, including localhost/loopback hosts. |
| 608 | // Ports are ignored, if present. |
| 609 | func SubjectIsInternal(subj string) bool { |
| 610 | subj = strings.ToLower(strings.TrimSuffix(hostOnly(subj), ".")) |
| 611 | return subj == "localhost" || |
| 612 | strings.HasSuffix(subj, ".localhost") || |
| 613 | strings.HasSuffix(subj, ".local") || |
| 614 | strings.HasSuffix(subj, ".internal") || |
| 615 | strings.HasSuffix(subj, ".home.arpa") || |
| 616 | isInternalIP(subj) |
| 617 | } |
| 618 | |
| 619 | // isInternalIP returns true if the IP of addr |
| 620 | // belongs to a private network IP range. addr |
no test coverage detected
searching dependent graphs…