summaryrefslogtreecommitdiff
path: root/hostname.go
blob: cf033df811ae09d9f09237c951ec51dff924a487 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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 (
	"log"
	"git.wit.org/wit/shell"
)

// 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.Println("FQDN hostname error =", err)
		return
	}
	if (me.fqdn != nil) {
		if (me.hostname != s) {
			me.fqdn.SetText(s)
			me.hostname = s
			me.changed = true
		}
	}
	log.Println("FQDN =", s)
}

// returns true if the hostname is good
// check that all the OS settings are correct here
// On Linux, /etc/hosts, /etc/hostname
//      and domainname and hostname
func goodHostname(h string) bool {
	hostname := shell.Cat("/etc/hostname")	
	log.Println("hostname =", hostname)

	return false
}

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