File: krb.go

package info (click to toggle)
golang-github-lib-pq 1.10.9-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 724 kB
  • sloc: makefile: 35; sh: 14
file content (29 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package kerberos

import (
	"net"
	"strings"
)

/*
 *  Find the A record associated with a hostname
 *  In general, hostnames supplied to the driver should be
 *  canonicalized because the KDC usually only has one
 *  principal and not one per potential alias of a host.
 */
func canonicalizeHostname(host string) (string, error) {
	canon := host

	name, err := net.LookupCNAME(host)
	if err != nil {
		return "", err
	}

	name = strings.TrimSuffix(name, ".")

	if name != "" {
		canon = name
	}

	return canon, nil
}