2023-02-18 23:37:11 -06:00
|
|
|
// This creates a simple hello world window
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
2023-12-20 03:13:43 -06:00
|
|
|
"time"
|
2024-01-03 12:40:31 -06:00
|
|
|
"go.wit.com/gui/gui"
|
2023-12-29 02:43:00 -06:00
|
|
|
"go.wit.com/gui/gadgets"
|
2024-01-06 05:24:11 -06:00
|
|
|
"go.wit.com/control-panels/dns/linuxstatus"
|
2024-01-06 01:41:33 -06:00
|
|
|
|
2023-12-20 03:13:43 -06:00
|
|
|
"github.com/miekg/dns"
|
2023-02-18 23:37:11 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// It's probably a terrible idea to call this 'me'
|
|
|
|
var me Host
|
|
|
|
|
|
|
|
type Host struct {
|
2024-01-06 01:41:33 -06:00
|
|
|
status *hostnameStatus // keeps track of the hostname and it's status
|
2024-01-06 05:24:11 -06:00
|
|
|
statusOS *linuxstatus.LinuxStatus // what the Linux OS sees
|
2024-01-06 01:41:33 -06:00
|
|
|
|
|
|
|
hostnameStatus *gui.Node // a summary for the user of where things are
|
|
|
|
|
2024-01-06 05:24:11 -06:00
|
|
|
// domainname *gui.Node // kernel.org
|
2023-12-20 03:13:43 -06:00
|
|
|
hostshort *gui.Node // hostname -s
|
2023-12-16 12:59:18 -06:00
|
|
|
|
2023-12-20 03:13:43 -06:00
|
|
|
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
|
|
|
artificialS string `default:"abc"` // artificial sleep on startup
|
|
|
|
|
2023-12-29 02:43:00 -06:00
|
|
|
ttl *gadgets.Duration
|
|
|
|
dnsTtl *gadgets.Duration
|
2023-12-20 03:13:43 -06:00
|
|
|
dnsSleep time.Duration
|
|
|
|
localSleep time.Duration
|
2023-12-16 12:59:18 -06:00
|
|
|
|
2023-03-26 16:17:32 -05:00
|
|
|
changed bool // set to true if things changed
|
2023-03-01 11:21:47 -06:00
|
|
|
user string // name of the user
|
2023-12-16 12:59:18 -06:00
|
|
|
|
2023-02-18 23:37:11 -06:00
|
|
|
ipmap map[string]*IPtype // the current ip addresses
|
2023-03-01 11:21:47 -06:00
|
|
|
dnsmap map[string]*IPtype // the current dns addresses
|
2023-02-18 23:37:11 -06:00
|
|
|
ifmap map[int]*IFtype // the current interfaces
|
2023-12-20 03:13:43 -06:00
|
|
|
nsmap map[string]string // the NS records
|
|
|
|
|
|
|
|
// DNS A and AAAA results
|
|
|
|
ipv4s map[string]dns.RR
|
|
|
|
ipv6s map[string]dns.RR
|
2023-12-16 12:59:18 -06:00
|
|
|
|
2024-01-05 00:07:13 -06:00
|
|
|
window *gadgets.BasicWindow // the main window
|
2024-01-05 00:11:48 -06:00
|
|
|
debug *gadgets.BasicWindow // more attempts to debug the DNS state
|
2024-01-05 00:07:13 -06:00
|
|
|
|
2023-03-01 11:21:47 -06:00
|
|
|
tab *gui.Node // the main dns tab
|
|
|
|
notes *gui.Node // using this to put notes here
|
2023-12-20 03:13:43 -06:00
|
|
|
|
|
|
|
// local OS settings, network interfaces, etc
|
2024-01-06 05:32:52 -06:00
|
|
|
// uid *gui.Node // user
|
2023-03-09 14:21:34 -06:00
|
|
|
fqdn *gui.Node // display the full hostname
|
2024-01-06 14:57:51 -06:00
|
|
|
// IPv4 *gui.Node // show valid IPv4 addresses
|
|
|
|
// IPv6 *gui.Node // show valid IPv6 addresses
|
2023-03-25 08:09:34 -05:00
|
|
|
Interfaces *gui.Node // Interfaces
|
2023-12-20 03:13:43 -06:00
|
|
|
LocalSpeedActual *gui.Node // the time it takes to check each network interface
|
|
|
|
|
|
|
|
// DNS stuff
|
2024-01-06 14:57:51 -06:00
|
|
|
// NSrr *gui.Node // NS resource records for the domain name
|
2023-12-20 03:13:43 -06:00
|
|
|
DnsAPI *gui.Node // what DNS API to use?
|
2024-01-06 01:41:33 -06:00
|
|
|
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results
|
2024-01-06 14:57:51 -06:00
|
|
|
// workingIPv6 *gui.Node // currently working AAAA
|
2023-03-25 15:43:24 -05:00
|
|
|
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
|
|
|
DnsStatus *gui.Node // the current state of DNS
|
2023-12-20 03:13:43 -06:00
|
|
|
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
|
|
|
DnsSpeedActual *gui.Node // the last actual duration
|
|
|
|
DnsSpeedLast string // the last state 'FAST', 'OK', etc
|
|
|
|
|
2024-01-06 02:21:56 -06:00
|
|
|
// fix *gui.Node // button for the user to click
|
|
|
|
// fixProc *gui.Node // button for the user to click
|
2023-12-20 03:13:43 -06:00
|
|
|
|
2024-01-06 02:21:56 -06:00
|
|
|
// mainStatus *gui.Node // group for the main display of stuff
|
|
|
|
// cloudflareB *gui.Node // cloudflare button
|
2023-12-28 09:43:45 -06:00
|
|
|
|
|
|
|
digStatus *digStatus
|
2023-12-29 02:43:00 -06:00
|
|
|
statusIPv6 *gadgets.OneLiner
|
2023-12-28 15:36:05 -06:00
|
|
|
digStatusButton *gui.Node
|
2023-12-29 01:36:10 -06:00
|
|
|
|
2024-01-05 00:07:13 -06:00
|
|
|
myDebug *gui.Node
|
|
|
|
myGui *gui.Node
|
2023-02-18 23:37:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type IPtype struct {
|
|
|
|
gone bool // used to track if the ip exists
|
|
|
|
ipv6 bool // the future
|
|
|
|
ipv4 bool // the past
|
|
|
|
LinkLocal bool
|
|
|
|
iface *net.Interface
|
|
|
|
ip net.IP
|
|
|
|
ipnet *net.IPNet
|
|
|
|
}
|
|
|
|
|
|
|
|
type IFtype struct {
|
|
|
|
gone bool // used to track if the interface exists
|
|
|
|
name string // just a shortcut to the name. maybe this is dumb
|
|
|
|
// up bool // could be used to track ifup/ifdown
|
|
|
|
iface *net.Interface
|
|
|
|
}
|