button to investigate port 53 daemon
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
a93266ebd8
commit
52361b2cba
44
gui.go
44
gui.go
|
@ -107,19 +107,19 @@ func debugTab(title string) {
|
||||||
g2 = tab.NewGroup("debugging options")
|
g2 = tab.NewGroup("debugging options")
|
||||||
|
|
||||||
// DEBUG flags
|
// DEBUG flags
|
||||||
dbOn := g2.NewCheckbox("turn on debugging (will override all flags below)")
|
me.dbOn = g2.NewCheckbox("turn on debugging (will override all flags below)")
|
||||||
dbOn.Custom = func() {
|
me.dbOn.Custom = func() {
|
||||||
DEBUGON = dbOn.B
|
DEBUGON = me.dbOn.B
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNet := g2.NewCheckbox("turn on network debugging)")
|
me.dbNet = g2.NewCheckbox("turn on network debugging)")
|
||||||
dbNet.Custom = func() {
|
me.dbNet.Custom = func() {
|
||||||
DEBUGNET = dbNet.B
|
DEBUGNET = me.dbNet.B
|
||||||
}
|
}
|
||||||
|
|
||||||
dbProc := g2.NewCheckbox("turn on /proc debugging)")
|
me.dbProc = g2.NewCheckbox("turn on /proc debugging)")
|
||||||
dbProc.Custom = func() {
|
me.dbProc.Custom = func() {
|
||||||
DEBUGPROC = dbProc.B
|
DEBUGPROC = me.dbProc.B
|
||||||
}
|
}
|
||||||
|
|
||||||
// various timeout settings
|
// various timeout settings
|
||||||
|
@ -151,9 +151,9 @@ func myDefaultExit(n *gui.Node) {
|
||||||
func dnsTab(title string) {
|
func dnsTab(title string) {
|
||||||
tab := me.window.NewTab(title)
|
tab := me.window.NewTab(title)
|
||||||
|
|
||||||
g := tab.NewGroup("dns update")
|
me.mainStatus = tab.NewGroup("dns update")
|
||||||
|
|
||||||
grid := g.NewGrid("gridnuts", 2, 2)
|
grid := me.mainStatus.NewGrid("gridnuts", 2, 2)
|
||||||
|
|
||||||
grid.SetNext(1,1)
|
grid.SetNext(1,1)
|
||||||
grid.NewLabel("hostname =")
|
grid.NewLabel("hostname =")
|
||||||
|
@ -183,7 +183,7 @@ func dnsTab(title string) {
|
||||||
me.DnsStatus = grid.NewLabel("unknown")
|
me.DnsStatus = grid.NewLabel("unknown")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
me.fix = g.NewButton("Fix", func () {
|
me.fix = me.mainStatus.NewButton("Fix", func () {
|
||||||
if (goodHostname(me.hostname)) {
|
if (goodHostname(me.hostname)) {
|
||||||
log.Println("hostname is good:", me.hostname)
|
log.Println("hostname is good:", me.hostname)
|
||||||
} else {
|
} else {
|
||||||
|
@ -191,6 +191,7 @@ func dnsTab(title string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nsupdate()
|
nsupdate()
|
||||||
|
me.fixProc.Disable()
|
||||||
})
|
})
|
||||||
me.fix.Disable()
|
me.fix.Disable()
|
||||||
|
|
||||||
|
@ -300,3 +301,22 @@ func updateDNS() {
|
||||||
}
|
}
|
||||||
log.Println("updateDNS() END")
|
log.Println("updateDNS() END")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func suggestProcDebugging() {
|
||||||
|
if (me.fixProc != nil) {
|
||||||
|
// me.fixProc.Disable()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
me.fixProc = me.mainStatus.NewButton("Try debugging Slow DNS lookups", func () {
|
||||||
|
debug("You're DNS lookups are very slow")
|
||||||
|
me.dbOn.Set(true)
|
||||||
|
me.dbProc.Set(true)
|
||||||
|
|
||||||
|
DEBUGON = true
|
||||||
|
DEBUGPROC = true
|
||||||
|
processName := getProcessNameByPort(53)
|
||||||
|
log.Println("Process with port 53:", processName)
|
||||||
|
})
|
||||||
|
// me.fixProc.Disable()
|
||||||
|
}
|
||||||
|
|
26
main.go
26
main.go
|
@ -58,28 +58,39 @@ func checkNetworkChanges() {
|
||||||
ttl -= 1
|
ttl -= 1
|
||||||
if (ttl < 0) {
|
if (ttl < 0) {
|
||||||
if (runtime.GOOS == "linux") {
|
if (runtime.GOOS == "linux") {
|
||||||
|
linuxLoop()
|
||||||
|
} else {
|
||||||
|
// TODO: make windows and macos diagnostics
|
||||||
|
log.Println("Windows and MacOS don't work yet")
|
||||||
|
}
|
||||||
|
ttl = me.dnsTTL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// run this on each timeout
|
||||||
|
func linuxLoop() {
|
||||||
duration := timeFunction(dnsTTL)
|
duration := timeFunction(dnsTTL)
|
||||||
log.Println("dnsTTL() execution Time: ", duration)
|
log.Println("dnsTTL() execution Time: ", duration)
|
||||||
var s string
|
var s string
|
||||||
if (duration > 5000 * time.Millisecond ) {
|
if (duration > 5000 * time.Millisecond ) {
|
||||||
s = fmt.Sprint("VERY BAD\n", duration)
|
s = fmt.Sprint("VERY BAD\n", duration)
|
||||||
|
suggestProcDebugging()
|
||||||
} else if (duration > 2000 * time.Millisecond ) {
|
} else if (duration > 2000 * time.Millisecond ) {
|
||||||
s = fmt.Sprint("BAD\n", duration)
|
s = fmt.Sprint("BAD\n", duration)
|
||||||
|
suggestProcDebugging()
|
||||||
} else if (duration > 500 * time.Millisecond ) {
|
} else if (duration > 500 * time.Millisecond ) {
|
||||||
s = fmt.Sprint("SLOW\n", duration)
|
s = fmt.Sprint("SLOW\n", duration)
|
||||||
} else if (duration > 100 * time.Millisecond ) {
|
} else if (duration > 100 * time.Millisecond ) {
|
||||||
s = fmt.Sprint("OK\n", duration)
|
s = fmt.Sprint("OK\n", duration)
|
||||||
} else {
|
} else {
|
||||||
s = fmt.Sprint("FAST\n", duration)
|
s = fmt.Sprint("FAST\n", duration)
|
||||||
|
if (me.fixProc != nil) {
|
||||||
|
me.fixProc.Disable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.Println(true, "getHostname()", s)
|
log.Println(true, "getHostname()", s)
|
||||||
me.DnsSpeed.SetText(s)
|
me.DnsSpeed.SetText(s)
|
||||||
} else {
|
|
||||||
log.Println("Windows and MacOS don't work yet")
|
|
||||||
}
|
|
||||||
ttl = me.dnsTTL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This checks for changes to the network settings
|
// This checks for changes to the network settings
|
||||||
|
@ -111,9 +122,10 @@ func dnsTTL() {
|
||||||
updateDNS()
|
updateDNS()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
processName := getProcessNameByPort(53)
|
processName := getProcessNameByPort(53)
|
||||||
fmt.Println("Process with port 53:", processName)
|
fmt.Println("Process with port 53:", processName)
|
||||||
/*
|
|
||||||
commPath := filepath.Join("/proc", proc.Name(), "comm")
|
commPath := filepath.Join("/proc", proc.Name(), "comm")
|
||||||
comm, err := ioutil.ReadFile(commPath)
|
comm, err := ioutil.ReadFile(commPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -38,7 +38,15 @@ type Host struct {
|
||||||
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
||||||
DnsStatus *gui.Node // the current state of DNS
|
DnsStatus *gui.Node // the current state of DNS
|
||||||
DnsSpeed *gui.Node // the current state of DNS
|
DnsSpeed *gui.Node // the current state of DNS
|
||||||
|
|
||||||
fix *gui.Node // button for the user to click
|
fix *gui.Node // button for the user to click
|
||||||
|
fixProc *gui.Node // button for the user to click
|
||||||
|
|
||||||
|
mainStatus *gui.Node // group for the main display of stuff
|
||||||
|
|
||||||
|
dbOn *gui.Node // button for setting debugging on
|
||||||
|
dbNet *gui.Node // button for setting network debugging on
|
||||||
|
dbProc *gui.Node // button for setting proc debugging on
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPtype struct {
|
type IPtype struct {
|
||||||
|
|
Loading…
Reference in New Issue