parent
ad8a25d85f
commit
f8df2d1ce3
1
Makefile
1
Makefile
|
@ -1,6 +1,5 @@
|
|||
.PHONY: debian
|
||||
|
||||
|
||||
run: build
|
||||
# ./control-panel-dns >/tmp/witgui.log.stderr 2>&1
|
||||
cp -f control-panel-dns ~/
|
||||
|
|
|
@ -42,6 +42,7 @@ type digStatus struct {
|
|||
speed *gadgets.OneLiner
|
||||
speedActual *gadgets.OneLiner
|
||||
|
||||
detailsGroup *gui.Node
|
||||
details *gui.Node
|
||||
dsLocalhost *resolverStatus
|
||||
dsLocalNetwork *resolverStatus
|
||||
|
@ -77,7 +78,8 @@ func NewDigStatusWindow(p *gui.Node) *digStatus {
|
|||
ds.speedActual = gadgets.NewOneLiner(g, "actual").Set("unknown")
|
||||
|
||||
// make the area to store the raw details
|
||||
ds.details = ds.window.Box().NewGroup("Details")
|
||||
ds.detailsGroup = ds.window.Box().NewGroup("Details")
|
||||
ds.details = ds.detailsGroup.NewBox("bw vbox", false)
|
||||
ds.dsLocalhost = NewResolverStatus(ds.details, "(localhost)", "127.0.0.1:53", "go.wit.com")
|
||||
ds.dsLocalNetwork = NewResolverStatus(ds.details, "(Local Network)", "192.168.86.1:53", "go.wit.com")
|
||||
ds.dsCloudflare = NewResolverStatus(ds.details, "(cloudflare)", "1.1.1.1:53", "go.wit.com")
|
||||
|
|
15
dns.go
15
dns.go
|
@ -40,6 +40,7 @@ func (h *Host) setIPv4(ipv4s map[string]*IPtype) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func lookupNSprovider(domain string) string {
|
||||
for s, d := range me.nsmap {
|
||||
log.Log(CHANGE, "lookupNS() domain =", d, "server =", s)
|
||||
|
@ -50,6 +51,7 @@ func lookupNSprovider(domain string) string {
|
|||
}
|
||||
return "blah"
|
||||
}
|
||||
*/
|
||||
|
||||
// nsLookup performs an NS lookup on the given domain name.
|
||||
func lookupNS(domain string) {
|
||||
|
@ -94,22 +96,15 @@ func lookupNS(domain string) {
|
|||
}
|
||||
}
|
||||
|
||||
// getDomain returns the second-to-last part of a domain name.
|
||||
// returns the second-to-last part of a domain name.
|
||||
func setProvider(hostname string) {
|
||||
var provider string = ""
|
||||
parts := strings.Split(hostname, ".")
|
||||
if len(parts) >= 2 {
|
||||
provider = parts[len(parts)-2]
|
||||
}
|
||||
if me.APIprovider != provider {
|
||||
if me.statusDNS.GetDNSapi() != provider {
|
||||
log.Log(CHANGE, "setProvider() changed to =", provider)
|
||||
}
|
||||
me.APIprovider = provider
|
||||
/*
|
||||
if (me.DnsAPI.S != provider) {
|
||||
me.changed = true
|
||||
log.Log(CHANGE, "setProvider() changed to =", provider)
|
||||
me.DnsAPI.SetText(provider)
|
||||
}
|
||||
*/
|
||||
me.statusDNS.SetDNSapi(provider)
|
||||
}
|
||||
|
|
81
errorBox.go
81
errorBox.go
|
@ -5,6 +5,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
"go.wit.com/gui/gadgets"
|
||||
|
@ -27,9 +29,10 @@ type errorBox struct {
|
|||
}
|
||||
|
||||
type anError struct {
|
||||
kind string // what kind of error is it?
|
||||
aaaa string
|
||||
status string
|
||||
// kind ProblemType // what kind of error is it?
|
||||
// action ActionType
|
||||
// aaaa string
|
||||
// status string
|
||||
|
||||
kindLabel *gui.Node
|
||||
actionLabel *gui.Node
|
||||
|
@ -89,11 +92,13 @@ func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) b
|
|||
tmp := kind.String() + " " + ip
|
||||
if eb.fixes[tmp] != nil {
|
||||
log.Log(WARN, "Error is already here", kind, ip)
|
||||
log.Log(WARN, "kind =", kind)
|
||||
log.Log(WARN, "action =", action)
|
||||
log.Log(WARN, "ip =", ip)
|
||||
return false
|
||||
}
|
||||
|
||||
anErr := new(anError)
|
||||
anErr.aaaa = ip
|
||||
|
||||
anErr.kindLabel = eb.grid.NewLabel(kind.String())
|
||||
anErr.actionLabel = eb.grid.NewLabel(action.String())
|
||||
|
@ -105,7 +110,12 @@ func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) b
|
|||
})
|
||||
anErr.problem = new(Problem)
|
||||
anErr.problem.kind = kind
|
||||
anErr.problem.action = action
|
||||
anErr.problem.aaaa = ip
|
||||
anErr.problem.born = time.Now()
|
||||
anErr.problem.duration = 30 * time.Second
|
||||
anErr.problem.begun = false
|
||||
anErr.problem.begunResult = false
|
||||
eb.fixes[tmp] = anErr
|
||||
return false
|
||||
}
|
||||
|
@ -125,22 +135,57 @@ func (eb *errorBox) fix(key string) bool {
|
|||
return true
|
||||
}
|
||||
myErr := eb.fixes[key]
|
||||
log.Log(WARN, "should try to fix", myErr.kind, "here. IP =", myErr.aaaa)
|
||||
if myErr.kind == "DELETE" {
|
||||
if deleteFromDNS(myErr.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
|
||||
}
|
||||
return true
|
||||
log.Log(WARN, "should try to fix", myErr.problem.kind, "here. IP =", myErr.problem.aaaa)
|
||||
if ! me.autofix.B {
|
||||
log.Log(WARN, "not autofixing. autofix == false")
|
||||
log.Log(WARN, "problem.kind =", myErr.problem.kind)
|
||||
log.Log(WARN, "problem.action =", myErr.problem.action)
|
||||
log.Log(WARN, "problem.aaaa =", myErr.problem.aaaa)
|
||||
log.Log(WARN, "problem.duration =", myErr.problem.duration)
|
||||
log.Log(WARN, "problem.begun =", myErr.problem.begun)
|
||||
log.Log(WARN, "problem.begunResult =", myErr.problem.begunResult)
|
||||
// if myErr.problem.begunTime != nil {
|
||||
log.Log(WARN, "problem.begunTime =", myErr.problem.begunTime)
|
||||
// }
|
||||
return false
|
||||
}
|
||||
if myErr.kind == "CREATE" {
|
||||
if addToDNS(myErr.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
|
||||
if myErr.problem.begun {
|
||||
log.Log(WARN, "problem has already begun. need to check the status of the problem here")
|
||||
log.Log(WARN, "problem.begun =", myErr.problem.begun)
|
||||
log.Log(WARN, "problem.begunResult =", myErr.problem.begunResult)
|
||||
log.Log(WARN, "problem.duration =", myErr.problem.duration)
|
||||
delay := time.Since(myErr.problem.begunTime)
|
||||
log.Log(WARN, "problem duration time =", delay)
|
||||
if delay >= myErr.problem.duration {
|
||||
log.Log(WARN, "duration eclipsed. check the status of the error here")
|
||||
}
|
||||
return false
|
||||
}
|
||||
if myErr.problem.kind == RR {
|
||||
if myErr.problem.action == DELETE {
|
||||
myErr.problem.begun = true
|
||||
myErr.problem.begunTime = time.Now()
|
||||
if deleteFromDNS(myErr.problem.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.problem.aaaa, "Worked")
|
||||
myErr.problem.begunResult = true
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.problem.aaaa, "Failed")
|
||||
myErr.problem.begunResult = false
|
||||
}
|
||||
return true
|
||||
}
|
||||
if myErr.problem.action == CREATE {
|
||||
myErr.problem.begun = true
|
||||
myErr.problem.begunTime = time.Now()
|
||||
if addToDNS(myErr.problem.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.problem.aaaa, "Worked")
|
||||
myErr.problem.begunResult = true
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.problem.aaaa, "Failed")
|
||||
myErr.problem.begunResult = false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ type hostnameStatus struct {
|
|||
dnsA *gadgets.OneLiner
|
||||
dnsAAAA *gadgets.OneLiner
|
||||
dnsAPI *gadgets.OneLiner
|
||||
APIprovider string
|
||||
|
||||
speed *gadgets.OneLiner
|
||||
speedActual *gadgets.OneLiner
|
||||
|
@ -96,25 +97,6 @@ func NewHostnameStatusWindow(p *gui.Node) *hostnameStatus {
|
|||
group.Pad()
|
||||
grid.Pad()
|
||||
|
||||
/*
|
||||
group = hs.window.Box().NewGroup("Actions")
|
||||
grid = group.NewGrid("LookupDetails", 2, 2)
|
||||
|
||||
hs.dnsValue = grid.NewLabel("3.4.5.6")
|
||||
hs.dnsAction = grid.NewButton("CHECK", func () {
|
||||
log.Warn("should", hs.dnsAction.S, "here for", hs.dnsValue.S)
|
||||
if (hs.dnsAction.S == "DELETE") {
|
||||
hs.deleteDNSrecord(hs.dnsValue.S)
|
||||
}
|
||||
if (hs.dnsAction.S == "CREATE") {
|
||||
hs.createDNSrecord(hs.dnsValue.S)
|
||||
}
|
||||
})
|
||||
*/
|
||||
|
||||
group.Pad()
|
||||
grid.Pad()
|
||||
|
||||
hs.hidden = false
|
||||
hs.ready = true
|
||||
return hs
|
||||
|
@ -381,5 +363,14 @@ func (hs *hostnameStatus) Hide() {
|
|||
}
|
||||
|
||||
func (hs *hostnameStatus) GetDNSapi() string {
|
||||
return me.APIprovider
|
||||
return hs.APIprovider
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) SetDNSapi(api string) {
|
||||
if api == hs.APIprovider {
|
||||
return
|
||||
}
|
||||
hs.APIprovider = api
|
||||
hs.dnsAPI.Set(api)
|
||||
hs.changed = true
|
||||
}
|
||||
|
|
110
ipv6box.go
110
ipv6box.go
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
Show your IPv6 addresses
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
"go.wit.com/gui/gadgets"
|
||||
)
|
||||
|
||||
type ipv6box struct {
|
||||
name string // the problem name
|
||||
|
||||
parent *gui.Node
|
||||
group *gui.Node
|
||||
grid *gui.Node
|
||||
|
||||
l *gui.Node
|
||||
b *gui.Node
|
||||
|
||||
fixes map[string]*anError
|
||||
|
||||
something *gadgets.OneLiner
|
||||
}
|
||||
|
||||
type anIPv6 struct {
|
||||
kind string // what kind of error is it?
|
||||
aaaa string
|
||||
status string
|
||||
|
||||
kindLabel *gui.Node
|
||||
ipLabel *gui.Node
|
||||
statusLabel *gui.Node
|
||||
button *gui.Node
|
||||
}
|
||||
|
||||
func NewIpv6box(p *gui.Node, name string, ip string) *ipv6box {
|
||||
var ib *ipv6box
|
||||
ib = new(ipv6box)
|
||||
ib.parent = p
|
||||
ib.group = p.NewGroup(name)
|
||||
ib.grid = ib.group.NewGrid("stuff", 4, 1)
|
||||
|
||||
ib.grid.NewLabel("Type")
|
||||
ib.grid.NewLabel("IP")
|
||||
ib.grid.NewLabel("Status")
|
||||
ib.grid.NewLabel("")
|
||||
|
||||
ib.fixes = make(map[string]*anError)
|
||||
return ib
|
||||
}
|
||||
|
||||
|
||||
func (ib *ipv6box) add(kind string, ip string) bool {
|
||||
tmp := kind + " " + ip
|
||||
if ib.fixes[tmp] != nil {
|
||||
log.Log(WARN, "Error is already here", kind, ip)
|
||||
return false
|
||||
}
|
||||
|
||||
anErr := new(anError)
|
||||
anErr.kind = kind
|
||||
anErr.aaaa = ip
|
||||
|
||||
anErr.kindLabel = ib.grid.NewLabel(kind)
|
||||
anErr.ipLabel = ib.grid.NewLabel(ip)
|
||||
anErr.statusLabel = ib.grid.NewLabel("")
|
||||
anErr.button = ib.grid.NewButton(kind, func() {
|
||||
log.Log(WARN, "got", kind, "here. IP =", ip)
|
||||
ib.fix(tmp)
|
||||
})
|
||||
ib.fixes[tmp] = anErr
|
||||
return false
|
||||
}
|
||||
|
||||
func (ib *ipv6box) fix(key string) bool {
|
||||
if ib.fixes[key] == nil {
|
||||
log.Log(WARN, "Unknown error. could not find key =", key)
|
||||
log.Log(WARN, "TODO: probably remove this error. key =", key)
|
||||
return true
|
||||
}
|
||||
myErr := ib.fixes[key]
|
||||
log.Log(WARN, "should try to fix", myErr.kind, "here. IP =", myErr.aaaa)
|
||||
if myErr.kind == "DELETE" {
|
||||
if deleteFromDNS(myErr.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
|
||||
}
|
||||
return true
|
||||
}
|
||||
if myErr.kind == "CREATE" {
|
||||
if addToDNS(myErr.aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
|
||||
} else {
|
||||
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (ib *ipv6box) update() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ib *ipv6box) toggle() {
|
||||
}
|
6
main.go
6
main.go
|
@ -123,7 +123,11 @@ func main() {
|
|||
// lookup the NS records for your domain
|
||||
// if your host is test.wit.com, find the NS resource records for wit.com
|
||||
lookupNS(me.statusOS.GetDomainName())
|
||||
log.Log(CHANGE, "updateDNS() END")
|
||||
log.Log(CHANGE, "lookupNS() RUNNING NOW. this will determine your DNS API provider")
|
||||
}
|
||||
if me.statusDNS.GetDNSapi() == "unknown" {
|
||||
lookupNS(me.statusOS.GetDomainName())
|
||||
log.Log(CHANGE, "lookupNS() RUNNING NOW. this will determine your DNS API provider")
|
||||
}
|
||||
})
|
||||
s := fmt.Sprint(duration)
|
||||
|
|
15
problems.go
15
problems.go
|
@ -18,7 +18,12 @@ type Problem struct {
|
|||
value string
|
||||
aaaa string
|
||||
fixed bool
|
||||
duration *time.Duration
|
||||
duration time.Duration // how long until you should check to see if it's fixed
|
||||
born time.Time // when first reported
|
||||
|
||||
begun bool // weather or not fixing it has begun
|
||||
begunTime time.Time // when the attempt to fix the problem happened
|
||||
begunResult bool // weather or not the attempt worked
|
||||
}
|
||||
|
||||
var IPcreate = Problem {
|
||||
|
@ -62,9 +67,9 @@ func (s ProblemType) String() string {
|
|||
case RR:
|
||||
return "RR"
|
||||
default:
|
||||
return "something"
|
||||
return "FIXMEP"
|
||||
}
|
||||
return "someprob"
|
||||
return "FIXMEP"
|
||||
}
|
||||
|
||||
func (s ActionType) String() string {
|
||||
|
@ -76,7 +81,7 @@ func (s ActionType) String() string {
|
|||
case DELETE:
|
||||
return "DELETE"
|
||||
default:
|
||||
return "something"
|
||||
return "FIXMEA"
|
||||
}
|
||||
return "someprob"
|
||||
return "FIXMEA"
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ func NewResolverStatus(p *gui.Node, title string, server string, hostname string
|
|||
rs = new(resolverStatus)
|
||||
rs.parent = p
|
||||
rs.group = p.NewGroup(server + " " + title + " lookup")
|
||||
rs.group = rs.group.NewBox("bw vbox", false)
|
||||
rs.grid = rs.group.NewGrid("LookupStatus", 5, 2)
|
||||
|
||||
rs.server = server
|
||||
|
|
|
@ -29,7 +29,7 @@ type Host struct {
|
|||
// WHEN THESE ARE ALL "WORKING", then everything is good
|
||||
hostnameStatus *gui.Node // a summary for the user of where things are
|
||||
DnsAPIstatus *gui.Node // does your DNS API work?
|
||||
APIprovider string
|
||||
// APIprovider string
|
||||
apiButton *gui.Node // the button you click for the API config page
|
||||
|
||||
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
||||
|
|
Loading…
Reference in New Issue