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 21:02:41 -06:00
|
|
|
// "go.wit.com/gui/cloudflare"
|
2024-01-06 05:24:11 -06:00
|
|
|
"go.wit.com/control-panels/dns/linuxstatus"
|
2024-01-07 05:46:59 -06:00
|
|
|
"go.wit.com/control-panels/dns/smartwindow"
|
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 17:51:41 -06:00
|
|
|
myGui *gui.Node // the 'gui' binary tree root node
|
|
|
|
|
|
|
|
window *gadgets.BasicWindow // the main window
|
|
|
|
debug *gadgets.BasicWindow // the debug window
|
|
|
|
|
2024-01-06 19:58:58 -06:00
|
|
|
statusDNS *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 17:51:41 -06:00
|
|
|
digStatus *digStatus // window of the results of DNS lookups
|
2024-01-06 01:41:33 -06:00
|
|
|
|
2024-01-07 12:45:01 -06:00
|
|
|
// WHEN THESE ARE ALL "WORKING", then everything is good
|
2024-01-06 01:41:33 -06:00
|
|
|
hostnameStatus *gui.Node // a summary for the user of where things are
|
2024-01-07 12:45:01 -06:00
|
|
|
DnsAPIstatus *gui.Node // does your DNS API work?
|
|
|
|
APIprovider string
|
2024-01-07 14:43:17 -06:00
|
|
|
apiButton *gui.Node // the button you click for the API config page
|
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-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
|
|
|
|
2023-12-20 03:13:43 -06:00
|
|
|
// DNS stuff
|
2023-03-25 15:43:24 -05:00
|
|
|
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
|
|
|
|
|
2023-12-29 02:43:00 -06:00
|
|
|
statusIPv6 *gadgets.OneLiner
|
2023-12-28 15:36:05 -06:00
|
|
|
digStatusButton *gui.Node
|
2024-01-07 07:09:59 -06:00
|
|
|
statusDNSbutton *gui.Node
|
2024-01-06 21:02:41 -06:00
|
|
|
witcom *gadgets.BasicWindow
|
2024-01-06 21:17:06 -06:00
|
|
|
fixButton *gui.Node
|
2024-01-07 05:46:59 -06:00
|
|
|
fixWindow *smartwindow.SmartWindow
|
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
|
|
|
|
}
|