Debian Codegraph @

dnsutil/tsla.go

raw
1 package dnsutil
2
3 import (
4 "fmt"
5 "net"
6 "strconv"
7 )
8
9 // TLSAName returns the ownername of a TLSA resource record as per the rules specified in RFC 6698, Section 3.
10 func TLSAName(s, service, network string) (string, error) {
11 if !IsFqdn(s) {
12 return "", fmt.Errorf("dnsutil: domain must be fully qualified")
13 }
14 p, err := net.LookupPort(network, service)
15 if err != nil {
16 return "", err
17 }
18 return "_" + strconv.Itoa(p) + "._" + network + "." + s, nil
19 }