summaryrefslogtreecommitdiff
path: root/hostname.go
blob: 9f5a66fd211039ea4c0f5e89bfe31dcd9aab0f89 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// inspired from:
// https://github.com/mactsouk/opensource.com.git
// and
// https://coderwall.com/p/wohavg/creating-a-simple-tcp-server-in-go

package main

// import "net"

// will try to get this hosts FQDN
import "github.com/Showmax/go-fqdn"

// this is the king of dns libraries
import "github.com/miekg/dns"

// dnssec IPv6 socket library
import "git.wit.org/jcarr/dnssecsocket"

func getHostname() {
	var err error
	var s string = "gui.Label == nil"
	s, err = fqdn.FqdnHostname()
	if (err != nil) {
		log("FQDN hostname error =", err)
		exit()
		return
	}
	if (me.fqdn != nil) {
		// s =  me.fqdn.GetText()
		output("trying to update gui.Label", true)
		me.fqdn.SetText(s)
	}
	output("FQDN = jcarr" + s + "\n", true)
}

func dnsAAAA(s string) []string {
	var aaaa []string
	// lookup the IP address from DNS
	rrset := dnssecsocket.Dnstrace(s, "AAAA")
	log(args.VerboseDNS, SPEW, rrset)
	for i, rr := range rrset {
		log(args.VerboseDNS, "r.Answer =", i, rr)
		ipaddr := dns.Field(rr, 1)
		aaaa = append(aaaa, ipaddr)
	}
	log(args.VerboseDNS, "aaaa =", aaaa)
	return aaaa
}