remove example with circular dependancies
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
4888500f3f
commit
542b4226b0
|
@ -1,24 +0,0 @@
|
|||
run: build
|
||||
./cloudflare
|
||||
|
||||
build-release:
|
||||
go get -v -u -x .
|
||||
go build
|
||||
./cloudflare
|
||||
|
||||
build:
|
||||
GO111MODULE="off" go get -v -x .
|
||||
GO111MODULE="off" go build
|
||||
|
||||
update:
|
||||
GO111MODULE="off" go get -v -u -x .
|
||||
|
||||
log:
|
||||
reset
|
||||
tail -f /tmp/witgui.* /tmp/guilogfile
|
||||
|
||||
gocui: build
|
||||
./cloudflare -gui gocui >/tmp/witgui.log.stderr 2>&1
|
||||
|
||||
quiet:
|
||||
./cloudflare >/tmp/witgui.log.stderr 2>&1
|
|
@ -1,219 +0,0 @@
|
|||
// This is a simple example
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
// "strconv"
|
||||
"bytes"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
func doChange(dnsRow *RRT) {
|
||||
log.Println("Look for changes in row", dnsRow.ID)
|
||||
log.Println("Proxy", dnsRow.Proxied, "vs", dnsRow.proxyNode.S)
|
||||
log.Println("Content", dnsRow.Content, "vs", dnsRow.valueNode.S)
|
||||
if (dnsRow.Content != dnsRow.valueNode.S) {
|
||||
log.Println("UPDATE VALUE", dnsRow.nameNode.Name, dnsRow.typeNode.Name, "to", dnsRow.valueNode.S)
|
||||
stuff, result := httpPut(dnsRow)
|
||||
if (dnsRow.curlNode != nil) {
|
||||
pretty, _ := formatJSON(stuff)
|
||||
log.Println("http PUT curl =", pretty)
|
||||
dnsRow.curlNode.SetText(pretty)
|
||||
}
|
||||
if (dnsRow.resultNode != nil) {
|
||||
pretty, _ := formatJSON(result)
|
||||
log.Println("http PUT result =", pretty)
|
||||
dnsRow.resultNode.SetText(pretty)
|
||||
}
|
||||
}
|
||||
dnsRow.saveNode.Disable()
|
||||
}
|
||||
|
||||
func getZonefile(c *configT) *DNSRecords {
|
||||
var url = cloudflareURL + c.zoneID + "/dns_records/"
|
||||
log.Println("getZonefile()", c.domain, url)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Println("http.NewRequest error:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set headers
|
||||
req.Header.Set("X-Auth-Key", c.auth)
|
||||
req.Header.Set("X-Auth-Email", c.email)
|
||||
|
||||
log.Println("getZonefile() auth, email", c.auth, c.email)
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Println("http.Client error:", err)
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("ioutil.ReadAll() error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var records DNSRecords
|
||||
if err := json.Unmarshal(body, &records); err != nil {
|
||||
log.Println("json.Unmarshal() error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Println("getZonefile() worked", records)
|
||||
return &records
|
||||
}
|
||||
|
||||
/*
|
||||
pass in a DNS Resource Records (the stuff in a zonefile)
|
||||
|
||||
This will talk to the cloudflare API and generate a resource record in the zonefile:
|
||||
|
||||
For example:
|
||||
gitea.wit.com. 3600 IN CNAME git.wit.com.
|
||||
go.wit.com. 3600 IN A 1.1.1.9
|
||||
test.wit.com. 3600 IN NS ns1.wit.com.
|
||||
*/
|
||||
func httpPut(dnsRow *RRT) (string, string) {
|
||||
var url string = cloudflareURL + os.Getenv("CF_API_ZONEID") + "/dns_records/" + dnsRow.ID
|
||||
var authKey string = os.Getenv("CF_API_KEY")
|
||||
var email string = os.Getenv("CF_API_EMAIL")
|
||||
|
||||
// make a json record to send on port 80 to cloudflare
|
||||
var tmp string
|
||||
tmp = `{"content": "` + dnsRow.valueNode.S + `", `
|
||||
tmp += `"name": "` + dnsRow.Name + `", `
|
||||
tmp += `"type": "` + dnsRow.Type + `", `
|
||||
tmp+= `"ttl": "` + "1" + `", `
|
||||
tmp += `"comment": "WIT DNS Control Panel"`
|
||||
tmp += `}`
|
||||
data := []byte(tmp)
|
||||
|
||||
log.Println("http PUT url =", url)
|
||||
// log.Println("http PUT data =", data)
|
||||
// spew.Dump(data)
|
||||
pretty, _ := formatJSON(string(data))
|
||||
log.Println("http PUT data =", pretty)
|
||||
|
||||
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(data))
|
||||
|
||||
// Set headers
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("X-Auth-Key", authKey)
|
||||
req.Header.Set("X-Auth-Email", email)
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return tmp, fmt.Sprintf("blah err =", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return tmp, fmt.Sprintf("blah err =", err)
|
||||
}
|
||||
// log.Println("http PUT body =", body)
|
||||
// spew.Dump(body)
|
||||
|
||||
return tmp, string(body)
|
||||
}
|
||||
|
||||
// https://api.cloudflare.com/client/v4/zones
|
||||
func getZones(auth, email string) *DNSRecords {
|
||||
var url = "https://api.cloudflare.com/client/v4/zones"
|
||||
log.Println("getZones()", url)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Println("http.NewRequest error:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set headers
|
||||
req.Header.Set("X-Auth-Key", auth)
|
||||
req.Header.Set("X-Auth-Email", email)
|
||||
|
||||
log.Println("getZones() auth, email", auth, email)
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Println("getZones() http.Client error:", err)
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("getZones() ioutil.ReadAll() error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var records DNSRecords
|
||||
if err := json.Unmarshal(body, &records); err != nil {
|
||||
log.Println("getZones() json.Unmarshal() error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
/* Cloudflare API returns struct[] of:
|
||||
struct { ID string "json:\"id\""; Type string "json:\"type\""; Name string "json:\"name\"";
|
||||
Content string "json:\"content\""; Proxied bool "json:\"proxied\"";
|
||||
Proxiable bool "json:\"proxiable\""; TTL int "json:\"ttl\"" }
|
||||
*/
|
||||
|
||||
// log.Println("getZones() worked", records)
|
||||
// log.Println("spew dump:")
|
||||
spew.Dump(records)
|
||||
for _, record := range records.Result {
|
||||
log.Println("spew record:", record)
|
||||
log.Println("record:", record.Name, record.ID)
|
||||
|
||||
var newc *configT
|
||||
newc = new(configT)
|
||||
|
||||
newc.domain = record.Name
|
||||
newc.zoneID = record.ID
|
||||
newc.auth = auth
|
||||
newc.email = email
|
||||
|
||||
config[record.Name] = newc
|
||||
zonedrop.AddText(record.Name)
|
||||
log.Println("zonedrop.AddText:", record.Name, record.ID)
|
||||
}
|
||||
for d, _ := range config {
|
||||
log.Println("config entry:", d)
|
||||
}
|
||||
|
||||
return &records
|
||||
}
|
||||
|
||||
// formatJSON takes an unformatted JSON string and returns a formatted version.
|
||||
func formatJSON(unformattedJSON string) (string, error) {
|
||||
var jsonData interface{}
|
||||
|
||||
// Decode the JSON string into an interface
|
||||
err := json.Unmarshal([]byte(unformattedJSON), &jsonData)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Re-encode the JSON with indentation for formatting
|
||||
formattedJSON, err := json.MarshalIndent(jsonData, "", " ")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(formattedJSON), nil
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
// This creates a simple hello world window
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
arg "github.com/alexflint/go-arg"
|
||||
"go.wit.com/gui"
|
||||
log "go.wit.com/gui/log"
|
||||
)
|
||||
|
||||
|
||||
var args struct {
|
||||
Foo string
|
||||
Bar bool
|
||||
User string `arg:"env:USER"`
|
||||
Demo bool `help:"run a demo"`
|
||||
gui.GuiArgs
|
||||
log.LogArgs
|
||||
}
|
||||
|
||||
func init() {
|
||||
arg.MustParse(&args)
|
||||
fmt.Println(args.Foo, args.Bar, args.User)
|
||||
|
||||
if (args.Gui != "") {
|
||||
gui.GuiArg.Gui = args.Gui
|
||||
}
|
||||
log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui)
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
|
||||
# -H "Authorization: Bearer AAAPutYourTokenInHereSoYouCanTestItL5Cl3" \
|
||||
# -H "Content-Type:application/json"
|
||||
|
||||
# https://api.cloudflare.com/client/v4/zones/27b900d9e05cfb9f3a64fecff2497f90/dns_records
|
||||
#
|
||||
# {
|
||||
# "comment": "WIT DNS Control Panel",
|
||||
# "content": "2001:4860:4860::8888",
|
||||
# "name": "www",
|
||||
# "proxied": false,
|
||||
# "ttl": 3600,
|
||||
# "type": "AAAA"
|
||||
#}
|
||||
|
||||
curl --request POST \
|
||||
--url https://api.cloudflare.com/client/v4/zones/27b900d9e05cfb9f3a64fecff2497f90/dns_records \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'X-Auth-Key: e08806ad85ef97aebaacd2d7fa462a7d417a7x' \
|
||||
--header 'X-Auth-Email: basilarchia@gmail.com' \
|
||||
--data '{
|
||||
"comment": "WIT DNS Control Panel",
|
||||
"content": "2001:4860:4860::5555",
|
||||
"name": "www5",
|
||||
"proxied": false,
|
||||
"ttl": 3600,
|
||||
"type": "AAAA"
|
||||
}'
|
|
@ -1,81 +0,0 @@
|
|||
// This is a simple example
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"go.wit.com/control-panel-dns/cloudflare"
|
||||
)
|
||||
|
||||
func loadDNS(c *configT) {
|
||||
hostname := c.domain
|
||||
log.Println("adding DNS record", hostname)
|
||||
|
||||
newt := mainWindow.NewTab(hostname)
|
||||
vb := newt.NewBox("vBox", false)
|
||||
newg := vb.NewGroup("more zoneID = " + c.zoneID)
|
||||
|
||||
// make a grid 6 things wide
|
||||
grid := newg.NewGrid("gridnuts", 6, gridH)
|
||||
|
||||
// grid.NewButton("Type", func () {
|
||||
// log.Println("sort by Type")
|
||||
// })
|
||||
grid.NewLabel("RR type")
|
||||
grid.NewLabel("hostname")
|
||||
|
||||
grid.NewLabel("Proxy")
|
||||
grid.NewLabel("TTL")
|
||||
grid.NewLabel("Value")
|
||||
grid.NewLabel("Save")
|
||||
|
||||
masterSave = vb.NewButton("Master Save", func () {
|
||||
log.Println("save stuff to cloudflare")
|
||||
})
|
||||
masterSave.Disable()
|
||||
|
||||
records := getZonefile(c)
|
||||
for _, record := range records.Result {
|
||||
var rr cloudflare.RRT // dns zonefile resource record
|
||||
|
||||
// copy all the JSON values into the row record.
|
||||
rr.ID = record.ID
|
||||
rr.Type = record.Type
|
||||
rr.Name = record.Name
|
||||
rr.Content = record.Content
|
||||
rr.Proxied = record.Proxied
|
||||
rr.Proxiable = record.Proxiable
|
||||
// rr.Ttl = record.TTL
|
||||
|
||||
grid.NewLabel(record.Type)
|
||||
grid.NewLabel(record.Name)
|
||||
|
||||
proxy := grid.NewLabel("proxy")
|
||||
if (record.Proxied) {
|
||||
proxy.SetText("On")
|
||||
} else {
|
||||
proxy.SetText("Off")
|
||||
}
|
||||
|
||||
var ttl string
|
||||
if (record.TTL == 1) {
|
||||
ttl = "Auto"
|
||||
} else {
|
||||
ttl = strconv.Itoa(record.TTL)
|
||||
}
|
||||
grid.NewLabel(ttl)
|
||||
|
||||
val := grid.NewLabel("Value")
|
||||
val.SetText(record.Content)
|
||||
|
||||
load := grid.NewButton("Load", nil)
|
||||
load.Custom = func () {
|
||||
name := "save stuff to cloudflare for " + rr.ID
|
||||
log.Println(name)
|
||||
// doChange(&rr)
|
||||
}
|
||||
}
|
||||
|
||||
grid.Pad()
|
||||
}
|
|
@ -1,236 +0,0 @@
|
|||
// This is a simple example
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"log"
|
||||
"bufio"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/control-panel-dns/cloudflare"
|
||||
)
|
||||
|
||||
var title string = "Cloudflare DNS Control Panel"
|
||||
var outfile string = "/tmp/guilogfile"
|
||||
var configfile string = ".config/wit/cloudflare"
|
||||
var myGui *gui.Node
|
||||
|
||||
var buttonCounter int = 5
|
||||
var gridW int = 5
|
||||
var gridH int = 3
|
||||
|
||||
var mainWindow, more, more2 *gui.Node
|
||||
|
||||
func main() {
|
||||
config = make(map[string]*configT)
|
||||
readConfig()
|
||||
myGui = gui.New().Default()
|
||||
makeCloudflareWindow()
|
||||
|
||||
// This is just a optional goroutine to watch that things are alive
|
||||
gui.Watchdog()
|
||||
gui.StandardExit()
|
||||
}
|
||||
|
||||
// This creates a window
|
||||
func makeCloudflareWindow() {
|
||||
var t *gui.Node
|
||||
|
||||
log.Println("buttonWindow() START")
|
||||
|
||||
mainWindow = myGui.NewWindow(title).SetText(title)
|
||||
|
||||
// this tab has the master cloudflare API credentials
|
||||
makeConfigTab(mainWindow)
|
||||
|
||||
t = mainWindow.NewTab("Zones")
|
||||
vb := t.NewBox("vBox", false)
|
||||
g1 := vb.NewGroup("zones")
|
||||
|
||||
// make dropdown list of zones
|
||||
zonedrop = g1.NewDropdown("zone")
|
||||
zonedrop.AddText("example.org")
|
||||
for d, _ := range config {
|
||||
zonedrop.AddText(d)
|
||||
}
|
||||
zonedrop.AddText("stablesid.org")
|
||||
|
||||
zonedrop.Custom = func () {
|
||||
domain := zonedrop.S
|
||||
log.Println("custom dropdown() zone (domain name) =", zonedrop.Name, domain)
|
||||
if (config[domain] == nil) {
|
||||
log.Println("custom dropdown() config[domain] = nil for domain =", domain)
|
||||
domainWidget.SetText(domain)
|
||||
zoneWidget.SetText("")
|
||||
authWidget.SetText("")
|
||||
emailWidget.SetText("")
|
||||
} else {
|
||||
log.Println("custom dropdown() a =", domain, config[domain].zoneID, config[domain].auth, config[domain].email)
|
||||
domainWidget.SetText(config[domain].domain)
|
||||
zoneWidget.SetText(config[domain].zoneID)
|
||||
authWidget.SetText(config[domain].auth)
|
||||
emailWidget.SetText(config[domain].email)
|
||||
}
|
||||
}
|
||||
|
||||
more = g1.NewGroup("data")
|
||||
showCloudflareCredentials(more)
|
||||
|
||||
makeDebugTab(mainWindow)
|
||||
}
|
||||
|
||||
func makeConfigTab(window *gui.Node) {
|
||||
t := window.NewTab("Get Zones")
|
||||
vb := t.NewBox("vBox", false)
|
||||
g1 := vb.NewGroup("Cloudflare API Config")
|
||||
|
||||
g1.NewLabel("If you have an API key with access to list all of /n your zone files, enter it here. \n \n Alternatively, you can set the enviroment variables: \n env $CF_API_KEY \n env $CF_API_EMAIL\n")
|
||||
|
||||
// make grid to display credentials
|
||||
grid := g1.NewGrid("credsGrid", 2, 4) // width = 2
|
||||
|
||||
grid.NewLabel("Auth Key")
|
||||
aw := grid.NewEntryLine("CF_API_KEY")
|
||||
aw.SetText(os.Getenv("CF_API_KEY"))
|
||||
|
||||
grid.NewLabel("Email")
|
||||
ew := grid.NewEntryLine("CF_API_EMAIL")
|
||||
ew.SetText(os.Getenv("CF_API_EMAIL"))
|
||||
|
||||
var url string = "https://api.cloudflare.com/client/v4/zones/"
|
||||
grid.NewLabel("Cloudflare API")
|
||||
grid.NewLabel(url)
|
||||
|
||||
grid.Pad()
|
||||
|
||||
vb.NewButton("getZones()", func () {
|
||||
log.Println("getZones()")
|
||||
getZones(aw.S, ew.S)
|
||||
})
|
||||
|
||||
vb.NewButton("cloudflare wit.com", func () {
|
||||
cloudflare.CreateRR(myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
|
||||
})
|
||||
|
||||
t.Pad()
|
||||
t.Margin()
|
||||
vb.Pad()
|
||||
vb.Margin()
|
||||
g1.Pad()
|
||||
g1.Margin()
|
||||
}
|
||||
|
||||
func makeDebugTab(window *gui.Node) {
|
||||
t2 := window.NewTab("debug")
|
||||
g := t2.NewGroup("debug")
|
||||
g.NewButton("Load 'gocui'", func () {
|
||||
// this set the xterm and mate-terminal window title. maybe works generally?
|
||||
fmt.Println("\033]0;" + title + "blah \007")
|
||||
myGui.LoadToolkit("gocui")
|
||||
})
|
||||
|
||||
g.NewButton("Load 'andlabs'", func () {
|
||||
myGui.LoadToolkit("andlabs")
|
||||
})
|
||||
|
||||
g.NewButton("gui.DebugWindow()", func () {
|
||||
gui.DebugWindow()
|
||||
})
|
||||
|
||||
g.NewButton("List all Widgets", func () {
|
||||
myGui.ListChildren(true)
|
||||
})
|
||||
g.NewButton("Dump all Widgets", func () {
|
||||
myGui.Dump()
|
||||
})
|
||||
}
|
||||
|
||||
func showCloudflareCredentials(box *gui.Node) {
|
||||
// make grid to display credentials
|
||||
grid := box.NewGrid("credsGrid", 2, 4) // width = 2
|
||||
|
||||
grid.NewLabel("Domain")
|
||||
domainWidget = grid.NewEntryLine("CF_API_DOMAIN")
|
||||
|
||||
grid.NewLabel("Zone ID")
|
||||
zoneWidget = grid.NewEntryLine("CF_API_ZONEID")
|
||||
|
||||
grid.NewLabel("Auth Key")
|
||||
authWidget = grid.NewEntryLine("CF_API_KEY")
|
||||
|
||||
grid.NewLabel("Email")
|
||||
emailWidget = grid.NewEntryLine("CF_API_EMAIL")
|
||||
|
||||
var url string = "https://api.cloudflare.com/client/v4/zones/"
|
||||
grid.NewLabel("Cloudflare API")
|
||||
grid.NewLabel(url)
|
||||
|
||||
grid.Pad()
|
||||
|
||||
loadButton = box.NewButton("Load Cloudflare DNS zonefile", func () {
|
||||
var domain configT
|
||||
domain.domain = domainWidget.S
|
||||
domain.zoneID = zoneWidget.S
|
||||
domain.auth = authWidget.S
|
||||
domain.email = emailWidget.S
|
||||
loadDNS(&domain)
|
||||
})
|
||||
}
|
||||
|
||||
func readConfig() {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Println("searchPaths() error. exiting here?")
|
||||
}
|
||||
filename := homeDir + "/" + configfile
|
||||
log.Println("filename =", filename)
|
||||
|
||||
readFileLineByLine(filename)
|
||||
// os.Exit(0)
|
||||
}
|
||||
|
||||
// readFileLineByLine opens a file and reads through each line.
|
||||
func readFileLineByLine(filename string) error {
|
||||
// Open the file.
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
log.Println("readFileLineByLine() =", filename)
|
||||
|
||||
// Create a new Scanner for the file.
|
||||
scanner := bufio.NewScanner(file)
|
||||
|
||||
// Read through each line using scanner.
|
||||
for scanner.Scan() {
|
||||
var newc *configT
|
||||
newc = new(configT)
|
||||
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(line)
|
||||
|
||||
if (len(parts) < 4) {
|
||||
log.Println("readFileLineByLine() SKIP =", parts)
|
||||
continue
|
||||
}
|
||||
|
||||
newc.domain = parts[0]
|
||||
newc.zoneID = parts[1]
|
||||
newc.auth = parts[2]
|
||||
newc.email = parts[3]
|
||||
|
||||
config[parts[0]] = newc
|
||||
log.Println("readFileLineByLine() =", newc.domain, newc.zoneID, newc.auth, newc.email)
|
||||
}
|
||||
|
||||
// Check for errors during Scan.
|
||||
if err := scanner.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
// This is a simple example
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
)
|
||||
|
||||
var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/"
|
||||
|
||||
// Define a struct to match the JSON structure of the response.
|
||||
// This structure should be adjusted based on the actual format of the response.
|
||||
type DNSRecords struct {
|
||||
Result []struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Content string `json:"content"`
|
||||
Proxied bool `json:"proxied"`
|
||||
Proxiable bool `json:"proxiable"`
|
||||
TTL int `json:"ttl"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
var masterSave *gui.Node
|
||||
|
||||
var domainWidget *gui.Node
|
||||
var zoneWidget *gui.Node
|
||||
var authWidget *gui.Node
|
||||
var emailWidget *gui.Node
|
||||
|
||||
var loadButton *gui.Node
|
||||
var saveButton *gui.Node
|
||||
var zonedrop *gui.Node
|
||||
|
||||
// Resource Record (used in a DNS zonefile)
|
||||
type RRT struct {
|
||||
typeNode *gui.Node // CNAME, A, AAAA, ...
|
||||
nameNode *gui.Node // www, mail, ...
|
||||
proxyNode *gui.Node // If cloudflare is a port 80 & 443 proxy
|
||||
ttlNode *gui.Node // just set to 1 which means automatic to cloudflare
|
||||
valueNode *gui.Node // 4.2.2.2, "dkim stuff", etc
|
||||
curlNode *gui.Node // shows you what you could run via curl
|
||||
resultNode *gui.Node // what the cloudflare API returned
|
||||
saveNode *gui.Node // button to send it to cloudflare
|
||||
|
||||
ID string
|
||||
Type string
|
||||
Name string
|
||||
Content string
|
||||
ProxyS string
|
||||
Proxied bool
|
||||
Proxiable bool
|
||||
Ttl string
|
||||
}
|
||||
|
||||
/*
|
||||
This is a structure of all the RR's (Resource Records)
|
||||
in the DNS zonefiile for a hostname. For example:
|
||||
|
||||
For the host test.wit.com:
|
||||
|
||||
test.wit.com A 127.0.0.1
|
||||
test.wit.com AAAA
|
||||
test.wit.com TXT email test@wit.com
|
||||
test.wit.com TXT phone 212-555-1212
|
||||
test.wit.com CNAME real.wit.com
|
||||
*/
|
||||
type hostT struct {
|
||||
hostname string
|
||||
RRs []configT
|
||||
}
|
||||
|
||||
type configT struct {
|
||||
domain string
|
||||
zoneID string
|
||||
auth string
|
||||
email string
|
||||
}
|
||||
|
||||
var config map[string]*configT
|
19
go.mod
19
go.mod
|
@ -1,9 +1,8 @@
|
|||
module go.wit.com/gui
|
||||
|
||||
go 1.21.1
|
||||
go 1.21.4
|
||||
|
||||
require (
|
||||
git.wit.org/jcarr/control-panel-dns v0.1.2
|
||||
github.com/alexflint/go-arg v1.4.3
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e
|
||||
github.com/awesome-gocui/gocui v1.1.0
|
||||
|
@ -13,16 +12,16 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/alexflint/go-scalar v1.2.0 // indirect
|
||||
github.com/alexflint/go-scalar v1.1.0 // indirect
|
||||
github.com/gdamore/encoding v1.0.0 // indirect
|
||||
github.com/gdamore/tcell/v2 v2.6.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/gdamore/tcell/v2 v2.4.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.10 // indirect
|
||||
github.com/rivo/uniseg v0.1.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
|
||||
golang.org/x/text v0.3.3 // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
)
|
||||
|
|
47
go.sum
47
go.sum
|
@ -1,10 +1,7 @@
|
|||
git.wit.org/jcarr/control-panel-dns v0.1.2 h1:sir4X2vyIInDLfFNTP6PjsbsVbeZ5Izg75PNmA2dd4A=
|
||||
git.wit.org/jcarr/control-panel-dns v0.1.2/go.mod h1:F4AHUeumaEZqQwLpca0tNcHT2xYXLAd8H6WahG73zpw=
|
||||
github.com/alexflint/go-arg v1.4.3 h1:9rwwEBpMXfKQKceuZfYcwuc/7YY7tWJbFsgG5cAU/uo=
|
||||
github.com/alexflint/go-arg v1.4.3/go.mod h1:3PZ/wp/8HuqRZMUUgu7I+e1qcpUbvmS258mRXkFH4IA=
|
||||
github.com/alexflint/go-scalar v1.1.0 h1:aaAouLLzI9TChcPXotr6gUhq+Scr8rl0P9P4PnltbhM=
|
||||
github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
|
||||
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
|
||||
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e h1:wSQCJiig/QkoUnpvelSPbLiZNWvh2yMqQTQvIQqSUkU=
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e/go.mod h1:5G2EjwzgZUPnnReoKvPWVneT8APYbyKkihDVAHUi0II=
|
||||
github.com/awesome-gocui/gocui v1.1.0 h1:db2j7yFEoHZjpQFeE2xqiatS8bm1lO3THeLwE6MzOII=
|
||||
|
@ -14,27 +11,21 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57KM=
|
||||
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
|
||||
github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
|
||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
@ -43,40 +34,18 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
|
|
Loading…
Reference in New Issue