go.wit.com/log NewFlag()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9b4bf224dc
commit
ba020cdb37
10
Makefile
10
Makefile
|
@ -1,14 +1,18 @@
|
|||
.PHONY: debian
|
||||
|
||||
|
||||
run: build
|
||||
# ./control-panel-dns >/tmp/witgui.log.stderr 2>&1
|
||||
cp -f control-panel-dns ~/
|
||||
./control-panel-dns --tmp-log
|
||||
|
||||
redomod:
|
||||
check-git-clean:
|
||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||
|
||||
redomod: check-git-clean
|
||||
rm -f go.*
|
||||
go mod init
|
||||
go mod tidy
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
|
||||
install:
|
||||
go install -v go.wit.com/control-panel-dns@latest
|
||||
|
|
40
args.go
40
args.go
|
@ -23,37 +23,33 @@ var NOW log.LogFlag
|
|||
var INFO log.LogFlag
|
||||
var NET log.LogFlag
|
||||
var DNS log.LogFlag
|
||||
|
||||
var WARN log.LogFlag
|
||||
var SPEW log.LogFlag
|
||||
|
||||
var CHANGE log.LogFlag
|
||||
var STATUS log.LogFlag
|
||||
|
||||
func myreg(f *log.LogFlag, b bool, name string, desc string) {
|
||||
f.B = b
|
||||
f.Subsystem = "go.wit.com/control-panels/dns"
|
||||
f.Short = "cpdns"
|
||||
f.Desc = desc
|
||||
f.Name = name
|
||||
f.Register()
|
||||
}
|
||||
|
||||
func init() {
|
||||
arg.MustParse(&args)
|
||||
// fmt.Println(args.Foo, args.Bar, args.User)
|
||||
full := "go.wit.com/control-panels/dns"
|
||||
short := "cpdns"
|
||||
|
||||
myreg(&NOW, true, "NOW", "temp debugging stuff")
|
||||
myreg(&INFO, false, "INFO", "normal debugging stuff")
|
||||
myreg(&NET, false, "NET", "Network logging")
|
||||
myreg(&DNS, false, "DNS", "dnsStatus.update()")
|
||||
myreg(&WARN, true, "WARN", "bad things")
|
||||
myreg(&SPEW, false, "SPEW", "spew stuff")
|
||||
myreg(&CHANGE, true, "CHANGE", "when host or dns change")
|
||||
myreg(&STATUS, false, "STATUS", "updateStatus()")
|
||||
NOW.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
||||
INFO.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
||||
NET.NewFlag( "NET", false, full, short, "Network logging")
|
||||
DNS.NewFlag( "DNS", false, full, short, "dnsStatus.update()")
|
||||
|
||||
WARN.NewFlag("WARN", true, full, short, "bad things")
|
||||
SPEW.NewFlag("SPEW", false, full, short, "spew stuff")
|
||||
|
||||
CHANGE.NewFlag("CHANGE", true, full, short, "when host or dns change")
|
||||
STATUS.NewFlag("STATUS", false, full, short, "updateStatus() polling")
|
||||
|
||||
if debugger.ArgDebug() {
|
||||
log.Log(true, "INIT() gui debug == true")
|
||||
log.Log(NOW, "INIT() gui debug == true")
|
||||
} else {
|
||||
log.Log(true, "INIT() gui debug == false")
|
||||
log.Log(NOW, "INIT() gui debug == false")
|
||||
}
|
||||
|
||||
me.dnsSleep = 500 * time.Millisecond
|
||||
|
@ -61,7 +57,7 @@ func init() {
|
|||
|
||||
me.artificialSleep = 0.4 // seems to need to exist or GTK crashes. TODO: fix andlabs plugin
|
||||
me.artificialS = "blah"
|
||||
log.Log(true, "init() me.artificialSleep =", me.artificialSleep)
|
||||
log.Log(true, "init() me.artificialS =", me.artificialS)
|
||||
log.Log(INFO, "init() me.artificialSleep =", me.artificialSleep)
|
||||
log.Log(INFO, "init() me.artificialS =", me.artificialS)
|
||||
log.Sleep(me.artificialSleep)
|
||||
}
|
||||
|
|
19
errorBox.go
19
errorBox.go
|
@ -32,9 +32,12 @@ type anError struct {
|
|||
status string
|
||||
|
||||
kindLabel *gui.Node
|
||||
actionLabel *gui.Node
|
||||
ipLabel *gui.Node
|
||||
statusLabel *gui.Node
|
||||
button *gui.Node
|
||||
|
||||
problem *Problem
|
||||
}
|
||||
|
||||
func NewErrorBox(p *gui.Node, name string, ip string) *errorBox {
|
||||
|
@ -42,9 +45,10 @@ func NewErrorBox(p *gui.Node, name string, ip string) *errorBox {
|
|||
eb = new(errorBox)
|
||||
eb.parent = p
|
||||
eb.group = p.NewGroup(name)
|
||||
eb.grid = eb.group.NewGrid("stuff", 4, 1)
|
||||
eb.grid = eb.group.NewGrid("stuff", 5, 1)
|
||||
|
||||
eb.grid.NewLabel("Type")
|
||||
eb.grid.NewLabel("Action")
|
||||
eb.grid.NewLabel("IP")
|
||||
eb.grid.NewLabel("Status")
|
||||
eb.grid.NewLabel("")
|
||||
|
@ -80,25 +84,28 @@ func (eb *errorBox) Ready() bool {
|
|||
return eb.ready
|
||||
}
|
||||
|
||||
func (eb *errorBox) add(kind string, ip string) bool {
|
||||
func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) bool {
|
||||
if ! eb.Ready() {return false}
|
||||
tmp := kind + " " + ip
|
||||
tmp := kind.String() + " " + ip
|
||||
if eb.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 = eb.grid.NewLabel(kind)
|
||||
anErr.kindLabel = eb.grid.NewLabel(kind.String())
|
||||
anErr.actionLabel = eb.grid.NewLabel(action.String())
|
||||
anErr.ipLabel = eb.grid.NewLabel(ip)
|
||||
anErr.statusLabel = eb.grid.NewLabel("")
|
||||
anErr.button = eb.grid.NewButton("Fix", func() {
|
||||
anErr.button = eb.grid.NewButton("Try to Fix", func() {
|
||||
log.Log(WARN, "got", kind, "here. IP =", ip)
|
||||
eb.fix(tmp)
|
||||
})
|
||||
anErr.problem = new(Problem)
|
||||
anErr.problem.kind = kind
|
||||
anErr.problem.aaaa = ip
|
||||
eb.fixes[tmp] = anErr
|
||||
return false
|
||||
}
|
||||
|
|
5
fix.go
5
fix.go
|
@ -84,7 +84,8 @@ func fixIPv6dns() bool {
|
|||
} else {
|
||||
broken = true
|
||||
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
||||
addToFixWindow("DELETE", aaaa)
|
||||
// addToFixWindow("DELETE", aaaa)
|
||||
me.problems.addIPerror(RR, DELETE, aaaa)
|
||||
/*
|
||||
if deleteFromDNS(aaaa) {
|
||||
log.Log(INFO, "Delete AAAA", aaaa, "Worked")
|
||||
|
@ -153,7 +154,7 @@ func exists(m map[string]bool, s string) bool {
|
|||
func addToFixWindow(t string, ip string) {
|
||||
log.Log(INFO, "addToFixWindow() START")
|
||||
if ! me.problems.Ready() { return }
|
||||
me.problems.add(t, ip)
|
||||
me.problems.addIPerror(RR, CREATE, ip)
|
||||
log.Log(INFO, "addToFixWindow() END")
|
||||
}
|
||||
|
||||
|
|
2
gui.go
2
gui.go
|
@ -128,7 +128,7 @@ func mainWindow(title string) {
|
|||
|
||||
// These are your problems
|
||||
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
|
||||
me.problems.add("SOMETHING", "1:1:1:1:3")
|
||||
me.problems.addIPerror(RR, USER, "1:1:1:1")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,29 +12,27 @@ var NOW log.LogFlag
|
|||
var INFO log.LogFlag
|
||||
var NET log.LogFlag
|
||||
var DNS log.LogFlag
|
||||
|
||||
var PROC log.LogFlag
|
||||
var SPEW log.LogFlag
|
||||
var WARN log.LogFlag
|
||||
|
||||
var CHANGE log.LogFlag
|
||||
var STATUS log.LogFlag
|
||||
|
||||
func myreg(f *log.LogFlag, b bool, name string, desc string) {
|
||||
f.B = b
|
||||
f.Subsystem = "go.wit.com/control-panels/dns/linuxstatus"
|
||||
f.Short = "linux"
|
||||
f.Desc = desc
|
||||
f.Name = name
|
||||
f.Register()
|
||||
}
|
||||
|
||||
func init() {
|
||||
myreg(&NOW, true, "NOW", "temp debugging stuff")
|
||||
myreg(&INFO, false, "INFO", "normal debugging stuff")
|
||||
myreg(&NET, false, "NET", "Network Logging")
|
||||
myreg(&DNS, false, "DNS", "dnsStatus.update()")
|
||||
myreg(&PROC, false, "PROC", "/proc logging")
|
||||
myreg(&SPEW, false, "SPEW", "spew stuff")
|
||||
myreg(&WARN, true, "WARN", "bad things")
|
||||
myreg(&CHANGE, true, "CHANGE", "show droplet state changes")
|
||||
myreg(&STATUS, false, "STATUS", "Update() details")
|
||||
full := "go.wit.com/control-panels/dns/linuxstatus"
|
||||
short := "linux"
|
||||
|
||||
NOW.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
||||
INFO.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
||||
NET.NewFlag( "NET", false, full, short, "Network logging")
|
||||
DNS.NewFlag( "DNS", false, full, short, "dnsStatus.update()")
|
||||
|
||||
PROC.NewFlag("PROC", false, full, short, "/proc loggging")
|
||||
WARN.NewFlag("WARN", true, full, short, "bad things")
|
||||
SPEW.NewFlag("SPEW", false, full, short, "spew stuff")
|
||||
|
||||
CHANGE.NewFlag("CHANGE", true, full, short, "when host or dns change")
|
||||
STATUS.NewFlag("STATUS", false, full, short, "Update() details")
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ func scanInterfaces() {
|
|||
switch v := addr.(type) {
|
||||
case *net.IPNet:
|
||||
if checkIP(v, i) {
|
||||
log.Log(true, "scanInterfaces() IP is new () i =", v.IP.String())
|
||||
log.Log(NET, "scanInterfaces() IP is new () i =", v.IP.String())
|
||||
}
|
||||
default:
|
||||
log.Log(NET, "\t\taddr.(type) = NO IDEA WHAT TO DO HERE v =", v)
|
||||
|
|
34
problems.go
34
problems.go
|
@ -14,11 +14,19 @@ type Problem struct {
|
|||
|
||||
id int
|
||||
Name string
|
||||
desc string
|
||||
value string
|
||||
aaaa string
|
||||
fixed bool
|
||||
duration *time.Duration
|
||||
}
|
||||
|
||||
var IPcreate = Problem {
|
||||
kind: RR,
|
||||
action: CREATE,
|
||||
desc: "This RR entry in the zonefile needs to be removed",
|
||||
}
|
||||
|
||||
/*
|
||||
var hostname Problem = (
|
||||
kind: ProblemType.OS,
|
||||
|
@ -46,3 +54,29 @@ const (
|
|||
func (s Problem) String() string {
|
||||
return s.Name
|
||||
}
|
||||
|
||||
func (s ProblemType) String() string {
|
||||
switch s {
|
||||
case OS:
|
||||
return "OS"
|
||||
case RR:
|
||||
return "RR"
|
||||
default:
|
||||
return "something"
|
||||
}
|
||||
return "someprob"
|
||||
}
|
||||
|
||||
func (s ActionType) String() string {
|
||||
switch s {
|
||||
case USER:
|
||||
return "USER"
|
||||
case CREATE:
|
||||
return "CREATE"
|
||||
case DELETE:
|
||||
return "DELETE"
|
||||
default:
|
||||
return "something"
|
||||
}
|
||||
return "someprob"
|
||||
}
|
||||
|
|
|
@ -13,18 +13,12 @@ var INFO log.LogFlag
|
|||
var SPEW log.LogFlag
|
||||
var WARN log.LogFlag
|
||||
|
||||
func myreg(f *log.LogFlag, b bool, name string, desc string) {
|
||||
f.B = b
|
||||
f.Subsystem = "go.wit.com/gadgets/smartwindow"
|
||||
f.Short = "smartWin"
|
||||
f.Desc = desc
|
||||
f.Name = name
|
||||
f.Register()
|
||||
}
|
||||
|
||||
func init() {
|
||||
myreg(&NOW, true, "NOW", "temp debugging stuff")
|
||||
myreg(&INFO, false, "INFO", "normal debugging stuff")
|
||||
myreg(&SPEW, false, "SPEW", "spew stuff")
|
||||
myreg(&WARN, true, "WARN", "bad things")
|
||||
full := "go.wit.com/gui/gadgets/smartwindow"
|
||||
short := "smartWin"
|
||||
|
||||
NOW.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
||||
INFO.NewFlag("INFO", false, full, short, "General Info")
|
||||
SPEW.NewFlag("SPEW", false, full, short, "spew stuff")
|
||||
WARN.NewFlag("WARN", false, full, short, "bad things")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue