58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package main
|
|
|
|
import "log"
|
|
import "os"
|
|
import "bufio"
|
|
import "git.wit.org/wit/gui"
|
|
|
|
func resolvWindow(w *gui.Node) {
|
|
if (w == nil) {
|
|
gui.Config.Title = "resolv.conf Window"
|
|
gui.Config.Width = 113
|
|
gui.Config.Height = 112
|
|
gui.Config.Exit = customExit
|
|
w = gui.NewWindow()
|
|
}
|
|
|
|
tab := w.AddTab("resolv.conf Tab", nil)
|
|
// populateNEW(tab, "new")
|
|
|
|
////////////// filename /////////////////////////
|
|
gNode := tab.AddGroup("filename")
|
|
|
|
resolvNode := gNode.AddComboBox("resolv-1-1-1-1.conf",
|
|
"resolv-4.2.2.2.conf",
|
|
"resolv-8-8-8-8.conf",
|
|
"resolv-bind.wit.org.conf",
|
|
"resolv-ipv6-only.conf",
|
|
"resolv-localhost.conf")
|
|
|
|
resolvNode.SetText("resolv-1-1-1-1.conf")
|
|
resolvNode.OnChanged = func () {
|
|
log.Println("STARTED HOSTNAME")
|
|
filename := resolvNode.GetText()
|
|
log.Println("ENDED GetText() HOSTNAME =", filename)
|
|
}
|
|
|
|
////////////// connect /////////////////////////
|
|
gNode = tab.AddGroup("Update")
|
|
|
|
gNode.AddButton("/etc/resolv.conf", func (*gui.Node) {
|
|
filename := "resolv/" + resolvNode.GetText()
|
|
log.Println("set resolv.conf to",filename)
|
|
b, _ := packrBox.FindString(filename)
|
|
log.Println(filename, "=\n\n" + b)
|
|
// spew.Dump(b)
|
|
|
|
f, err := os.Create("/etc/resolv.conf")
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer f.Close()
|
|
w := bufio.NewWriter(f)
|
|
n4, err := w.WriteString(b)
|
|
log.Println("n4 =", n4)
|
|
w.Flush()
|
|
})
|
|
}
|