add a struct for the machine
'me' is probably not a great variable name Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
d00a8f5cd3
commit
3959b6c328
|
@ -0,0 +1,51 @@
|
||||||
|
// Various Linux/Unix'y things
|
||||||
|
|
||||||
|
// https://wiki.archlinux.org/title/Dynamic_DNS
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// "os"
|
||||||
|
// "os/exec"
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
// "git.wit.org/wit/gui"
|
||||||
|
// "github.com/davecgh/go-spew/spew"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IPtype struct {
|
||||||
|
// IP string
|
||||||
|
IPv4 bool
|
||||||
|
IPv6 bool
|
||||||
|
LinkLocal bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Host struct {
|
||||||
|
Name string
|
||||||
|
domainname string
|
||||||
|
hostname string
|
||||||
|
fqdn string
|
||||||
|
ips map[string]*IPtype
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check a bunch of things. If they don't work right, then things are not correctly configured
|
||||||
|
They are things like:
|
||||||
|
/etc/hosts
|
||||||
|
hostname
|
||||||
|
hostname -f
|
||||||
|
domainname
|
||||||
|
*/
|
||||||
|
func (h *Host) verifyETC() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Host) updateIPs(host string) {
|
||||||
|
ips, err := net.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, ip := range ips {
|
||||||
|
log.Println(host, ip)
|
||||||
|
}
|
||||||
|
}
|
1
gui.go
1
gui.go
|
@ -83,6 +83,7 @@ func addDemoTab(window *gui.Node, title string) {
|
||||||
})
|
})
|
||||||
g2.NewButton("DumpPublicDNSZone(apple.com)", func () {
|
g2.NewButton("DumpPublicDNSZone(apple.com)", func () {
|
||||||
DumpPublicDNSZone("apple.com")
|
DumpPublicDNSZone("apple.com")
|
||||||
|
dumpIPs("www.apple.com")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
main.go
4
main.go
|
@ -9,11 +9,15 @@ import (
|
||||||
arg "github.com/alexflint/go-arg"
|
arg "github.com/alexflint/go-arg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var me Host
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
arg.MustParse(&args)
|
arg.MustParse(&args)
|
||||||
// fmt.Println(args.Foo, args.Bar, args.User)
|
// fmt.Println(args.Foo, args.Bar, args.User)
|
||||||
log.Println("Toolkit = ", args.Toolkit)
|
log.Println("Toolkit = ", args.Toolkit)
|
||||||
|
|
||||||
|
me.ips = make(map[string]*IPtype)
|
||||||
|
|
||||||
// gui.InitPlugins([]string{"andlabs"})
|
// gui.InitPlugins([]string{"andlabs"})
|
||||||
|
|
||||||
scanInterfaces()
|
scanInterfaces()
|
||||||
|
|
15
unix.go
15
unix.go
|
@ -1,4 +1,7 @@
|
||||||
// This creates a simple hello world window
|
// Various Linux/Unix'y things
|
||||||
|
|
||||||
|
// https://wiki.archlinux.org/title/Dynamic_DNS
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -39,3 +42,13 @@ func DumpPublicDNSZone(zone string) {
|
||||||
log.Println(entry)
|
log.Println(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dumpIPs(host string) {
|
||||||
|
ips, err := net.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, ip := range ips {
|
||||||
|
log.Println(host, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue