use 'go.wit.com/log'

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-03 19:33:13 -06:00
parent 138f72728c
commit c1a00fcc1a
14 changed files with 115 additions and 155 deletions

23
args.go
View File

@ -19,24 +19,45 @@ var args struct {
}
var NET log.LogFlag
var NOW log.LogFlag
var PROC log.LogFlag
var SPEW log.LogFlag
var CHANGE log.LogFlag
func init() {
arg.MustParse(&args)
// fmt.Println(args.Foo, args.Bar, args.User)
NOW.B = false
NOW.Name = "NOW"
NOW.Subsystem = "cpdns"
NOW.Desc = "temp debugging stuff"
NOW.Register()
NET.B = false
NET.Name = "NET"
NET.Subsystem = "cpdns"
NET.Desc = "Network logging"
NET.Register()
PROC.B = false
PROC.Name = "PROC"
PROC.Subsystem = "cpdns"
PROC.Desc = "/proc logging"
PROC.Register()
SPEW.B = false
SPEW.Name = "SPEW"
SPEW.Subsystem = "cpdns"
SPEW.Desc = "spew logging"
SPEW.Register()
CHANGE.B = false
CHANGE.Name = "CHANGE"
CHANGE.Subsystem = "cpdns"
CHANGE.Desc = "show droplet state changes"
CHANGE.Register()
if debugger.ArgDebug() {
log.Log(true, "INIT() gui debug == true")
} else {
@ -50,5 +71,5 @@ func init() {
me.artificialS = "blah"
log.Log(true, "init() me.artificialSleep =", me.artificialSleep)
log.Log(true, "init() me.artificialS =", me.artificialS)
sleep(me.artificialSleep)
log.Sleep(me.artificialSleep)
}

View File

@ -2,7 +2,6 @@ package main
import (
"io"
"log"
"os"
"os/exec"
"os/signal"
@ -10,6 +9,8 @@ import (
"github.com/creack/pty"
"golang.org/x/term"
"go.wit.com/log"
)
func test() error {
@ -54,7 +55,7 @@ func test() error {
func mainBash() {
if err := test(); err != nil {
debug(LogError, "exit in mainBash()")
exit(err)
log.Error(err, "exit in mainBash()")
log.Exit(err)
}
}

12
dns.go
View File

@ -5,10 +5,10 @@
package main
import (
"log"
"net"
"strings"
"go.wit.com/log"
"go.wit.com/shell"
)
@ -27,7 +27,7 @@ func (h *Host) verifyETC() bool {
func (h *Host) updateIPs(host string) {
ips, err := net.LookupIP(host)
if err != nil {
debug(LogError, "updateIPs failed", err)
log.Error(err, "updateIPs failed")
}
for _, ip := range ips {
log.Println(host, ip)
@ -93,7 +93,7 @@ func lookupNS(domain string) {
for _, server := range servers {
server = strings.TrimRight(server, ".")
if (me.nsmap[server] != domain) {
debug(LogChange, "lookupNS() domain", domain, "has NS", server)
log.Log(CHANGE, "lookupNS() domain", domain, "has NS", server)
me.nsmap[server] = domain
domains += server + "\n"
}
@ -102,7 +102,7 @@ func lookupNS(domain string) {
var tmp string
// checks to see if the NS records change
for s, d := range me.nsmap {
debug(LogChange, "lookupNS() domain =", d, "server =", s)
log.Log(CHANGE, "lookupNS() domain =", d, "server =", s)
if (domain == d) {
tmp += s + "\n"
// figure out the provider (google, cloudflare, etc)
@ -113,7 +113,7 @@ func lookupNS(domain string) {
if (tmp != me.NSrr.S) {
me.changed = true
debug(LogChange, "lookupNS() setting me.NSrr =", tmp)
log.Log(CHANGE, "lookupNS() setting me.NSrr =", tmp)
me.NSrr.SetText(tmp)
}
}
@ -127,7 +127,7 @@ func setProvider(hostname string) {
}
if (me.DnsAPI.S != provider) {
me.changed = true
debug(LogChange, "setProvider() changed to =", provider)
log.Log(CHANGE, "setProvider() changed to =", provider)
me.DnsAPI.SetText(provider)
}
}

View File

@ -3,7 +3,7 @@ package main
// Watches for changes to a directory. Works cross-platform
import (
"log"
"go.wit.com/log"
"github.com/fsnotify/fsnotify"
)
@ -14,7 +14,7 @@ func watchSysClassNet() {
// Create new watcher.
watcher, err := fsnotify.NewWatcher()
if err != nil {
debug(LogError, "watchSysClassNet() failed:", err)
log.Error(err, "watchSysClassNet() failed")
return
}
defer watcher.Close()
@ -43,7 +43,7 @@ func watchSysClassNet() {
// Add a path.
err = watcher.Add("/tmp")
if err != nil {
debug(LogError, "watchSysClassNet() watcher.Add() failed:", err)
log.Error(err, "watchSysClassNet() watcher.Add() failed")
return
}

45
gui.go
View File

@ -22,8 +22,8 @@ func setupControlPanelWindow() {
me.window = myGui.NewWindow("DNS and IPv6 Control Panel")
// me.window.Dump() // will dump out some info
debug("artificial sleep of:", me.artificialSleep)
sleep(me.artificialSleep)
log.Info("artificial sleep of:", me.artificialSleep)
log.Sleep(me.artificialSleep)
// setup the main tab
dnsTab("DNS")
@ -109,10 +109,10 @@ func debugTab(title string) {
g2.NewButton("checkDNS:", func () {
ipv6s, ipv4s := checkDNS()
for s, _ := range ipv6s {
debug(LogNow, "check if", s, "is in DNS")
log.Log(NOW, "check if", s, "is in DNS")
}
for s, _ := range ipv4s {
debug(LogNow, "check if", s, "is in DNS")
log.Log(NOW, "check if", s, "is in DNS")
}
})
@ -153,19 +153,14 @@ func debugTab(title string) {
g2 = tab.NewGroup("debugging options")
// DEBUG flags
me.dbOn = g2.NewCheckbox("turn on debugging (will override all flags below)")
me.dbOn.Custom = func() {
DEBUGON = me.dbOn.B
}
me.dbNet = g2.NewCheckbox("turn on network debugging)")
me.dbNet.Custom = func() {
LogNet = me.dbNet.B
log.Warn("TODO: re-implement")
}
me.dbProc = g2.NewCheckbox("turn on /proc debugging)")
me.dbProc.Custom = func() {
LogProc = me.dbProc.B
log.Warn("TODO: re-implement")
}
// makes a slider widget
@ -185,7 +180,7 @@ func deleteAAA() string {
var aaaa []string
aaaa = dhcpAAAA() // your AAAA IP addresses right now
for _, s := range aaaa {
debug(LogNow, "DNS AAAA =", s)
log.Log(NOW, "DNS AAAA =", s)
if ( me.ipmap[s] == nil) {
return s
}
@ -198,7 +193,7 @@ func missingAAAA() string {
var aaaa []string
aaaa = dhcpAAAA() // your AAAA IP addresses right now
for _, s := range aaaa {
debug(LogNow, "missing AAAA =", s)
log.Log(NOW, "missing AAAA =", s)
return s
}
return ""
@ -213,10 +208,10 @@ func displayDNS() string {
var all string
var broken string = "unknown"
for _, s := range aaaa {
debug(LogNow, "host", h, "DNS AAAA =", s, "ipmap[s] =", me.ipmap[s])
log.Log(NOW, "host", h, "DNS AAAA =", s, "ipmap[s] =", me.ipmap[s])
all += s + "\n"
if ( me.ipmap[s] == nil) {
debug(LogError, "THIS IS THE WRONG AAAA DNS ENTRY: host", h, "DNS AAAA =", s)
log.Warn("THIS IS THE WRONG AAAA DNS ENTRY: host", h, "DNS AAAA =", s)
broken = "wrong AAAA entry"
} else {
if (broken == "unknown") {
@ -226,7 +221,7 @@ func displayDNS() string {
}
all = sortLines(all)
if (me.workingIPv6.S != all) {
debug(LogError, "workingIPv6.SetText() to:", all)
log.Warn("workingIPv6.SetText() to:", all)
me.workingIPv6.SetText(all)
}
@ -234,11 +229,11 @@ func displayDNS() string {
a = realA()
all = sortLines(strings.Join(a, "\n"))
if (all == "") {
debug(LogInfo, "THERE IS NOT a real A DNS ENTRY")
log.Info("THERE IS NOT a real A DNS ENTRY")
all = "CNAME ipv6.wit.com"
}
if (me.DnsA.S != all) {
debug(LogError, "DnsA.SetText() to:", all)
log.Warn("DnsA.SetText() to:", all)
me.DnsA.SetText(all)
}
return broken
@ -270,9 +265,9 @@ func dnsTab(title string) {
me.fix = me.mainStatus.NewButton("Fix", func () {
if (goodHostname(me.hostname)) {
debug(LogInfo, "hostname is good:", me.hostname)
log.Info("hostname is good:", me.hostname)
} else {
debug(LogError, "FIX: you need to fix your hostname here", me.hostname)
log.Warn("FIX: you need to fix your hostname here", me.hostname)
return
}
// check to see if the cloudflare window exists
@ -396,11 +391,11 @@ func updateDNS() {
// log.Println("digAAAA()")
aaaa = digAAAA(h)
debug(LogNow, "digAAAA() =", aaaa)
log.Log(NOW, "digAAAA() =", aaaa)
// log.Println(SPEW, me)
if (aaaa == nil) {
debug(LogError, "There are no DNS AAAA records for hostname: ", h)
log.Warn("There are no DNS AAAA records for hostname: ", h)
me.DnsAAAA.SetText("(none)")
if (cloudflare.CFdialog.TypeNode != nil) {
cloudflare.CFdialog.TypeNode.SetText("AAAA new")
@ -467,14 +462,12 @@ func suggestProcDebugging() {
}
me.fixProc = me.mainStatus.NewButton("Try debugging Slow DNS lookups", func () {
debug("You're DNS lookups are very slow")
log.Warn("You're DNS lookups are very slow")
me.dbOn.Set(true)
me.dbProc.Set(true)
DEBUGON = true
LogProc = true
processName := getProcessNameByPort(53)
log.Println("Process with port 53:", processName)
log.Info("Process with port 53:", processName)
})
// me.fixProc.Disable()
}

View File

@ -19,7 +19,7 @@ func getHostname() {
var s string = "gui.Label == nil"
s, err = fqdn.FqdnHostname()
if (err != nil) {
debug(LogError, "FQDN hostname error =", err)
log.Error(err, "FQDN hostname error")
return
}
if (me.fqdn != nil) {
@ -29,18 +29,18 @@ func getHostname() {
me.changed = true
}
}
debug(LogNet, "FQDN =", s)
log.Log(NET, "FQDN =", s)
dn := run("domainname")
if (me.domainname.S != dn) {
debug(LogChange, "domainname has changed from", me.domainname.S, "to", dn)
log.Log(CHANGE, "domainname has changed from", me.domainname.S, "to", dn)
me.domainname.SetText(dn)
me.changed = true
}
hshort := run("hostname -s")
if (me.hostshort.S != hshort) {
debug(LogChange, "hostname -s has changed from", me.hostshort.S, "to", hshort)
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.S, "to", hshort)
me.hostshort.SetText(hshort)
me.changed = true
}
@ -48,21 +48,21 @@ func getHostname() {
var test string
test = hshort + "." + dn
if (me.hostname != test) {
debug(LogInfo, "me.hostname", me.hostname, "does not equal", test)
log.Info("me.hostname", me.hostname, "does not equal", test)
if (me.hostnameStatusOLD.S != "BROKEN") {
debug(LogChange, "me.hostname", me.hostname, "does not equal", test)
log.Log(CHANGE, "me.hostname", me.hostname, "does not equal", test)
me.changed = true
me.hostnameStatusOLD.SetText("BROKEN")
}
} else {
if (me.hostnameStatusOLD.S != "VALID") {
debug(LogChange, "me.hostname", me.hostname, "is valid")
log.Log(CHANGE, "me.hostname", me.hostname, "is valid")
me.hostnameStatusOLD.SetText("VALID")
me.changed = true
}
// enable the cloudflare button if the provider is cloudflare
if (me.cloudflareB == nil) {
debug(LogChange, "me.cloudflare == nil; me.DnsAPI.S =", me.DnsAPI.S)
log.Log(CHANGE, "me.cloudflare == nil; me.DnsAPI.S =", me.DnsAPI.S)
if (me.DnsAPI.S == "cloudflare") {
me.cloudflareB = me.mainStatus.NewButton("cloudflare wit.com", func () {
cloudflare.CreateRR(myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
@ -78,15 +78,15 @@ func getHostname() {
// and domainname and hostname
func goodHostname(h string) bool {
hostname := shell.Chomp(shell.Cat("/etc/hostname"))
debug(true, "hostname =", hostname)
log.Log(NOW, "hostname =", hostname)
hs := run("hostname -s")
dn := run("domainname")
debug(true, "hostname short =", hs, "domainname =", dn)
log.Log(NOW, "hostname short =", hs, "domainname =", dn)
tmp := hs + "." + dn
if (hostname == tmp) {
debug(true, "hostname seems to be good", hostname)
log.Log(NOW, "hostname seems to be good", hostname)
return true
}
@ -98,18 +98,18 @@ func digAAAA(s string) []string {
var aaaa []string
// lookup the IP address from DNS
rrset := dnssecsocket.Dnstrace(s, "AAAA")
// debug(true, args.VerboseDNS, SPEW, rrset)
// log.Spew(args.VerboseDNS, SPEW, rrset)
for i, rr := range rrset {
ipaddr := dns.Field(rr, 1)
// how the hell do you detect a RRSIG AAAA record here?
if (ipaddr == "28") {
continue
}
debug(LogNow, "r.Answer =", i, "rr =", rr, "ipaddr =", ipaddr)
log.Log(NOW, "r.Answer =", i, "rr =", rr, "ipaddr =", ipaddr)
aaaa = append(aaaa, ipaddr)
me.ipv6s[ipaddr] = rr
}
debug(true, args.VerboseDNS, "aaaa =", aaaa)
log.Info(args.VerboseDNS, "aaaa =", aaaa)
log.Println("digAAAA() returned =", aaaa)
log.Println("digAAAA() me.ipv6s =", me.ipv6s)
os.Exit(0)

View File

@ -247,7 +247,7 @@ func (hs *hostnameStatus) missingAAAA() bool {
var aaaa []string
aaaa = dhcpAAAA()
for _, s := range aaaa {
debug(LogNet, "my actual AAAA = ",s)
log.Log(NET, "my actual AAAA = ",s)
hs.dnsValue.SetText(s)
hs.dnsAction.SetText("CREATE")
return true

59
log.go
View File

@ -1,59 +0,0 @@
package main
import (
"log"
"reflect"
witlog "go.wit.com/log"
)
var LogPrefix = "ipv6cp" // ipv6 control panel debugging line
// various debugging flags
var DEBUGON bool = true
var LogNow bool = true // useful for active development
var LogError bool = true // probably always leave this one
var LogChange bool = true // turn on /proc debugging output
var LogInfo bool = false // general info
var LogNet bool = false // general network debugging
var LogProc bool = false // turn on /proc debugging output
var LogExec bool = false // turn on os.Exec() debugging
// var SPEW witlog.Spewt
// var log interface{}
/*
func log(a ...any) {
witlog.Where = "wit/gui"
witlog.Log(a...)
}
*/
func sleep(a ...any) {
witlog.Sleep(a...)
}
func exit(a ...any) {
debug(LogError, "got to log() exit")
witlog.Exit(a...)
}
func debug(a ...any) {
if (! DEBUGON) {
return
}
if (a == nil) {
return
}
var tbool bool
if (reflect.TypeOf(a[0]) == reflect.TypeOf(tbool)) {
if (a[0] == false) {
return
}
a[0] = LogPrefix // ipv6 control panel debugging line
}
log.Println(a...)
}

28
main.go
View File

@ -43,16 +43,16 @@ func main() {
myGui = gui.New().Default()
sleep(me.artificialSleep)
log.Sleep(me.artificialSleep)
setupControlPanelWindow()
if debugger.ArgDebug() {
sleep(2)
log.Sleep(2)
debugger.DebugWindow(myGui)
}
// forever monitor for network and dns changes
sleep(me.artificialSleep)
log.Sleep(me.artificialSleep)
checkNetworkChanges()
}
@ -99,7 +99,7 @@ func checkNetworkChanges() {
me.LocalSpeedActual.SetText(s)
} else {
// TODO: make windows and macos diagnostics
debug(LogError, "Windows and MacOS don't work yet")
log.Warn("Windows and MacOS don't work yet")
}
lastLocal = time.Now()
}
@ -120,7 +120,7 @@ func checkNetworkChanges() {
// run this on each timeout
func DNSloop() {
duration := timeFunction(dnsTTL)
debug(LogInfo, "dnsTTL() execution Time: ", duration)
log.Info("dnsTTL() execution Time: ", duration)
var s, newSpeed string
if (duration > 5000 * time.Millisecond ) {
newSpeed = "VERY BAD"
@ -143,8 +143,8 @@ func DNSloop() {
}
}
if (newSpeed != me.DnsSpeedLast) {
debug(LogChange, "dns lookup speed changed =", newSpeed)
debug(LogChange, "dnsTTL() execution Time: ", duration)
log.Log(CHANGE, "dns lookup speed changed =", newSpeed)
log.Log(CHANGE, "dnsTTL() execution Time: ", duration)
me.DnsSpeed.SetText(newSpeed)
me.DnsSpeedLast = newSpeed
}
@ -160,30 +160,30 @@ func dnsTTL() {
func linuxLoop() {
me.changed = false
debug(LogNet, "FQDN =", me.fqdn.GetText())
log.Log(NET, "FQDN =", me.fqdn.GetText())
duration := timeFunction(getHostname)
debug(LogInfo, "getHostname() execution Time: ", duration, "me.changed =", me.changed)
log.Info("getHostname() execution Time: ", duration, "me.changed =", me.changed)
duration = timeFunction(scanInterfaces)
debug(LogNet, "scanInterfaces() execution Time: ", duration)
log.Log(NET, "scanInterfaces() execution Time: ", duration)
for i, t := range me.ifmap {
debug(LogNet, strconv.Itoa(i) + " iface = " + t.iface.Name)
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
}
var aaaa []string
aaaa = dhcpAAAA()
var all string
for _, s := range aaaa {
debug(LogNet, "my actual AAAA = ",s)
log.Log(NET, "my actual AAAA = ",s)
all += s + "\n"
}
// me.IPv6.SetText(all)
if (me.changed) {
stamp := time.Now().Format("2006/01/02 15:04:05")
debug(LogChange, "Network things changed on", stamp)
log.Log(CHANGE, "Network things changed on", stamp)
duration := timeFunction(updateDNS)
debug(LogChange, "updateDNS() execution Time: ", duration)
log.Log(CHANGE, "updateDNS() execution Time: ", duration)
}
/*

10
net.go
View File

@ -270,7 +270,7 @@ func deleteChanges() bool {
var changed bool = false
for i, t := range me.ifmap {
if (t.gone) {
log.Log(LogChange, "DELETE int =", i, "name =", t.name, t.iface)
log.Log(CHANGE, "DELETE int =", i, "name =", t.name, t.iface)
delete(me.ifmap, i)
changed = true
}
@ -278,10 +278,10 @@ func deleteChanges() bool {
}
for s, t := range me.ipmap {
if (t.gone) {
log.Log(LogChange, "DELETE name =", s, "IPv4 =", t.ipv4)
log.Log(LogChange, "DELETE name =", s, "IPv6 =", t.ipv6)
log.Log(LogChange, "DELETE name =", s, "iface =", t.iface)
log.Log(LogChange, "DELETE name =", s, "ip =", t.ip)
log.Log(CHANGE, "DELETE name =", s, "IPv4 =", t.ipv4)
log.Log(CHANGE, "DELETE name =", s, "IPv6 =", t.ipv6)
log.Log(CHANGE, "DELETE name =", s, "iface =", t.iface)
log.Log(CHANGE, "DELETE name =", s, "ip =", t.ip)
delete(me.ipmap, s)
changed = true
}

View File

@ -7,6 +7,8 @@ package main
import (
"os"
"go.wit.com/log"
)
// ./go-nsupdate \
@ -16,17 +18,17 @@ import (
func nsupdate() {
var tsigSecret string
debug(true, "nsupdate() START")
log.Log(NET, "nsupdate() START")
cmd := "go-nsupdate --tsig-algorithm=hmac-sha512"
tsigSecret = os.Getenv("TIG_SECRET")
cmd += " --tig-secret=\"" + tsigSecret + "\""
cmd += " -i wlo1 " + me.hostname
debug(true, "nsupdate() RUN:", cmd)
log.Log(NET, "nsupdate() RUN:", cmd)
for s, t := range me.ipmap {
if (t.IsReal()) {
if (t.ipv6) {
debug(true, "nsupdate() found real AAAA =", s, "on iface", t.iface.Name)
log.Log(NET, "nsupdate() found real AAAA =", s, "on iface", t.iface.Name)
}
}
}

28
proc.go
View File

@ -6,6 +6,8 @@ import (
"path/filepath"
"strconv"
"strings"
"go.wit.com/log"
)
func getProcessNameByPort(port int) string {
@ -18,24 +20,24 @@ func getProcessNameByPort(port int) string {
if err != nil {
return ""
}
// debug(LogProc, "searchProcNet() data:", string(data))
// log.Log(PROC, "searchProcNet() data:", string(data))
lines := strings.Split(string(data), "\n")
for _, line := range lines {
fields := strings.Fields(line)
debug(LogProc, "searchProcNet() portHex:", portHex)
log.Log(PROC, "searchProcNet() portHex:", portHex)
if (len(fields) > 9) {
debug(LogProc, "searchProcNet() fields[9]", fields[9])
log.Log(PROC, "searchProcNet() fields[9]", fields[9])
}
debug(LogProc, "searchProcNet() lines:", line)
log.Log(PROC, "searchProcNet() lines:", line)
if len(fields) > 1 {
parts := strings.Split(fields[1], ":")
if len(parts) > 1 {
// Convert the hexadecimal string to an integer
value, _ := strconv.ParseInt(parts[1], 16, 64)
debug(LogProc, "searchProcNet() value, port =", value, port, "parts[1] =", parts[1])
log.Log(PROC, "searchProcNet() value, port =", value, port, "parts[1] =", parts[1])
if (port == int(value)) {
debug(LogProc, "searchProcNet() THIS IS THE LINE:", fields)
log.Log(PROC, "searchProcNet() THIS IS THE LINE:", fields)
return fields[9]
}
}
@ -50,7 +52,7 @@ func getProcessNameByPort(port int) string {
if inode == "" {
inode = searchProcNet("/proc/net/udp")
}
debug(LogProc, "searchProcNet() inode =", inode)
log.Log(PROC, "searchProcNet() inode =", inode)
// Search for process with the inode
procs, _ := ioutil.ReadDir("/proc")
@ -70,23 +72,23 @@ func getProcessNameByPort(port int) string {
var s string
s = "socket:["+inode+"]"
if strings.Contains(fdLink, "socket:[") {
debug(LogProc, "searchProcNet() fdLink has socket:", fdLink)
debug(LogProc, "searchProcNet() proc.Name() =", proc.Name(), "s =", s)
log.Log(PROC, "searchProcNet() fdLink has socket:", fdLink)
log.Log(PROC, "searchProcNet() proc.Name() =", proc.Name(), "s =", s)
}
if strings.Contains(fdLink, "socket:[35452]") {
debug(LogProc, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
log.Log(PROC, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
return proc.Name()
}
if strings.Contains(fdLink, "socket:[35450]") {
debug(LogProc, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
log.Log(PROC, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
return proc.Name()
}
if strings.Contains(fdLink, "socket:[35440]") {
debug(LogProc, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
log.Log(PROC, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
return proc.Name()
}
if strings.Contains(fdLink, "socket:[21303]") {
debug(LogProc, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
log.Log(PROC, "searchProcNet() found proc.Name() =", proc.Name(), fdLink)
// return proc.Name()
}
if strings.Contains(fdLink, "socket:["+inode+"]") {

View File

@ -1,8 +1,8 @@
package main
import (
"log"
"github.com/jsimonetti/rtnetlink"
"go.wit.com/log"
)
// List all interfaces
@ -10,7 +10,7 @@ func Example_listLink() {
// Dial a connection to the rtnetlink socket
conn, err := rtnetlink.Dial(nil)
if err != nil {
debug(LogError, "Example_listLink() failed", err)
log.Error(err, "Example_listLink() failed")
return
}
defer conn.Close()

10
unix.go
View File

@ -5,7 +5,6 @@
package main
import (
"log"
"os"
"os/exec"
"net"
@ -13,6 +12,7 @@ import (
"fmt"
"strings"
"go.wit.com/log"
"go.wit.com/shell"
)
@ -28,8 +28,8 @@ func Escalate() {
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
debug(LogError, "exit in Escalate()")
exit(err)
log.Error(err, "exit in Escalate()")
log.Exit(err)
}
}
}
@ -50,7 +50,7 @@ func DumpPublicDNSZone(zone string) {
func dumpIPs(host string) {
ips, err := net.LookupIP(host)
if err != nil {
debug(LogError, "dumpIPs() failed:", err)
log.Error(err, "dumpIPs() failed")
}
for _, ip := range ips {
log.Println(host, ip)
@ -91,7 +91,7 @@ func run(s string) string {
tmp := shell.Chomp(out.String())
// Output the results
debug(LogExec, "Command Output:", tmp)
log.Info("Command Output:", tmp)
return tmp
}