This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function
Check hostname according to RFC2818 specification:
If more than one identity of a given type is present in the certificate (e.g., more than one DNSName name, a match in any one of the set is considered acceptable.) Names may contain the wildcard character * which is considered to match any single domain name component. E.g., .a.com matches foo.a.com but not bar.foo.a.com. Partial wildcards like f.com are not supported.
fncheckHostName(host_name: []constu8, dns_name: []constu8) bool {
// Empty strings should not matchif (host_name.len == 0ordns_name.len == 0) returnfalse;
// RFC 6125 Section 6.4.1: Exact match (case-insensitive)if (std.ascii.eqlIgnoreCase(dns_name, host_name)) {
returntrue; // exact match
}
// RFC 6125 Section 6.4.3: Wildcard certificates// Wildcard must be leftmost label and in the form "*.rest.of.domain"if (dns_name.len >= 3andmem.startsWith(u8, dns_name, "*.")) {
constwildcard_suffix = dns_name[2..];
// No additional wildcards allowed in the suffixif (mem.find(u8, wildcard_suffix, "*") != null) returnfalse;
// Find the first dot in hostname to split first label from restconstdot_pos = mem.find(u8, host_name, ".") orelsereturnfalse;
// Wildcard matches exactly one label, so compare the restconsthost_suffix = host_name[dot_pos + 1 ..];
// Match suffixes (case-insensitive per RFC 6125)returnstd.ascii.eqlIgnoreCase(wildcard_suffix, host_suffix);
}
returnfalse;
}
Check hostname according to RFC2818 specification:
If more than one identity of a given type is present in the certificate (e.g., more than one DNSName name, a match in any one of the set is considered acceptable.) Names may contain the wildcard character * which is considered to match any single domain name component. E.g., .a.com matches foo.a.com but not bar.foo.a.com. Partial wildcards like f.com are not supported.