summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-18 01:33:28 -0600
committerJeff Carr <[email protected]>2024-01-18 01:33:28 -0600
commitf0b712faf865b460b8be7a9edfd78e1b3852cae5 (patch)
treea20ae083ec79e99ba1c2cbe828edbee12c9d8911
parent586494505bb57aa1c4383641c6693a7021e1621d (diff)
fix pathsv0.12.3
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--api.go60
-rw-r--r--args.go6
-rw-r--r--create.go12
-rw-r--r--delete.go16
-rw-r--r--http.go16
-rw-r--r--json.go2
-rw-r--r--loadZoneWindow.go28
-rw-r--r--mainWindow.go22
-rw-r--r--rr.go26
-rw-r--r--structs.go108
-rw-r--r--zonesBox.go8
11 files changed, 152 insertions, 152 deletions
diff --git a/api.go b/api.go
index 7f820d8..464dbbd 100644
--- a/api.go
+++ b/api.go
@@ -1,7 +1,7 @@
// This is a simple example
package cloudflare
-import (
+import (
"encoding/json"
"io/ioutil"
"net/http"
@@ -10,20 +10,20 @@ import (
)
/*
- This function should run each time
- the user chanegs anything in the GUi
- or each time something in general changes
-
- It returns a RR record which then can be
- turned into JSON and sent via http
- to cloudflare's API
+This function should run each time
+the user chanegs anything in the GUi
+or each time something in general changes
+
+It returns a RR record which then can be
+turned into JSON and sent via http
+to cloudflare's API
*/
func DoChange() *RRT {
var dnsRow *RRT
dnsRow = new(RRT)
log.Log(INFO, "DoChange() START")
- if (CFdialog.proxyNode.String() == "On") {
+ if CFdialog.proxyNode.String() == "On" {
dnsRow.Proxied = true
} else {
dnsRow.Proxied = false
@@ -44,7 +44,7 @@ func DoChange() *RRT {
// show the JSON
log.Log(INFO, dnsRow)
- if (CFdialog.curlNode != nil) {
+ if CFdialog.curlNode != nil {
pretty, _ := FormatJSON(dnsRow.data)
log.Log(INFO, "http PUT curl =", pretty)
CFdialog.curlNode.SetText(pretty)
@@ -54,36 +54,36 @@ func DoChange() *RRT {
func SetRow(dnsRow *RRT) {
log.Log(INFO, "Look for changes in row", dnsRow.ID)
- if (CFdialog.proxyNode != nil) {
+ if CFdialog.proxyNode != nil {
log.Log(INFO, "Proxy", dnsRow.Proxied, "vs", CFdialog.proxyNode.String())
- if (dnsRow.Proxied == true) {
+ if dnsRow.Proxied == true {
CFdialog.proxyNode.SetText("On")
} else {
CFdialog.proxyNode.SetText("Off")
}
}
- if (CFdialog.zoneNode != nil) {
+ if CFdialog.zoneNode != nil {
CFdialog.zoneNode.SetText(dnsRow.Domain)
}
- if (CFdialog.zoneIdNode != nil) {
+ if CFdialog.zoneIdNode != nil {
CFdialog.zoneIdNode.SetText(dnsRow.ZoneID)
}
log.Log(INFO, "zoneIdNode =", dnsRow.ZoneID)
- if (CFdialog.rrNode != nil) {
+ if CFdialog.rrNode != nil {
CFdialog.rrNode.SetText(dnsRow.ID)
}
- if (CFdialog.ValueNode != nil) {
+ if CFdialog.ValueNode != nil {
log.Log(INFO, "Content", dnsRow.Content, "vs", CFdialog.ValueNode.String())
CFdialog.ValueNode.SetText(dnsRow.Content)
}
- if (CFdialog.NameNode != nil) {
+ if CFdialog.NameNode != nil {
CFdialog.NameNode.SetText(dnsRow.Name)
}
- if (CFdialog.TypeNode != nil) {
+ if CFdialog.TypeNode != nil {
CFdialog.TypeNode.SetText(dnsRow.Type)
}
- if (CFdialog.urlNode != nil) {
+ if CFdialog.urlNode != nil {
url := cloudflareURL + dnsRow.ZoneID + "/dns_records/" + dnsRow.ID
CFdialog.urlNode.SetText(url)
}
@@ -91,7 +91,7 @@ func SetRow(dnsRow *RRT) {
// show the JSON
tmp := makeJSON(dnsRow)
log.Spew(tmp)
- if (CFdialog.curlNode != nil) {
+ if CFdialog.curlNode != nil {
pretty, _ := FormatJSON(tmp)
log.Spew("http PUT curl =", pretty)
CFdialog.curlNode.SetText(pretty)
@@ -108,7 +108,7 @@ func GetZonefile(c *ConfigT) *DNSRecords {
}
// Set headers
- req.Header.Set("Authorization", "Bearer " + c.Auth)
+ req.Header.Set("Authorization", "Bearer "+c.Auth)
// req.Header.Set("X-Auth-Key", c.Auth)
// req.Header.Set("X-Auth-Email", c.Email)
@@ -147,14 +147,14 @@ func GetZonefile(c *ConfigT) *DNSRecords {
}
/*
- pass in a DNS Resource Records (the stuff in a zonefile)
+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:
+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.
+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 makeJSON(dnsRow *RRT) string {
// make a json record to send on port 80 to cloudflare
@@ -162,9 +162,9 @@ func makeJSON(dnsRow *RRT) string {
tmp = `{"content": "` + dnsRow.Content + `", `
tmp += `"name": "` + dnsRow.Name + `", `
tmp += `"type": "` + dnsRow.Type + `", `
- tmp+= `"ttl": "` + "1" + `", `
+ tmp += `"ttl": "` + "1" + `", `
tmp += `"comment": "WIT DNS Control Panel"`
- tmp += `}`
+ tmp += `}`
return tmp
}
@@ -180,7 +180,7 @@ func GetZones(auth, email string) *DNSRecords {
}
// Set headers
- req.Header.Set("Authorization", "Bearer " + auth)
+ req.Header.Set("Authorization", "Bearer "+auth)
// req.Header.Set("X-Auth-Key", auth)
// req.Header.Set("X-Auth-Email", email)
diff --git a/args.go b/args.go
index 2c8d378..7ec66cb 100644
--- a/args.go
+++ b/args.go
@@ -18,11 +18,11 @@ func init() {
full := "go.wit.com/gui/cloudflare"
short := "cfgui"
- NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
+ NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
INFO = log.NewFlag("INFO", false, full, short, "general info")
- WARN = log.NewFlag("WARN", true, full, short, "bad things")
+ WARN = log.NewFlag("WARN", true, full, short, "bad things")
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
- CURL = log.NewFlag("CURL", true, full, short, "curl interactions")
+ CURL = log.NewFlag("CURL", true, full, short, "curl interactions")
ZONE = log.NewFlag("ZONE", false, full, short, "zone details")
}
diff --git a/create.go b/create.go
index 554f634..2e8d5f0 100644
--- a/create.go
+++ b/create.go
@@ -6,7 +6,7 @@
package cloudflare
-import (
+import (
"os"
"go.wit.com/log"
@@ -17,11 +17,11 @@ func Create(zone string, hostname string, value string) bool {
key := os.Getenv("CF_API_KEY")
email := os.Getenv("CF_API_EMAIL")
- if (key == "") {
+ if key == "" {
log.Warn("cloudflare.Create() MISSING environment variable CF_API_KEY")
return false
}
- if (email == "") {
+ if email == "" {
log.Warn("cloudflare.Create() MISSING environment variable CF_API_EMAIL")
return false
}
@@ -30,12 +30,12 @@ func Create(zone string, hostname string, value string) bool {
var z *ConfigT
for d, v := range Config {
log.Log(INFO, "cloudflare.Create() zone =", d, "value =", v)
- if (zone == d) {
+ if zone == d {
z = Config[zone]
log.Log(INFO, "cloudflare.Create() FOUND ZONE", zone, "ID =", z.ZoneID)
}
}
- if (z == nil) {
+ if z == nil {
log.Warn("cloudflare.Create() COULD NOT FIND ZONE", zone)
return false
}
@@ -48,7 +48,7 @@ func Create(zone string, hostname string, value string) bool {
data += `"type": "AAAA", `
data += `"ttl": "1", `
data += `"comment": "WIT DNS Control Panel"`
- data += `}`
+ data += `}`
result := doCurlCreate(key, email, z.ZoneID, data)
pretty, _ := FormatJSON(result)
diff --git a/delete.go b/delete.go
index 157229f..4949de4 100644
--- a/delete.go
+++ b/delete.go
@@ -6,9 +6,9 @@
package cloudflare
-import (
- "os"
+import (
"go.wit.com/log"
+ "os"
)
func Delete(zone string, hostname string, value string) (bool, string) {
@@ -16,11 +16,11 @@ func Delete(zone string, hostname string, value string) (bool, string) {
key := os.Getenv("CF_API_KEY")
email := os.Getenv("CF_API_EMAIL")
- if (key == "") {
+ if key == "" {
log.Log(WARN, "Delete() MISSING environment variable CF_API_KEY")
return false, ""
}
- if (email == "") {
+ if email == "" {
log.Log(WARN, "Delete() MISSING environment variable CF_API_EMAIL")
return false, ""
}
@@ -29,12 +29,12 @@ func Delete(zone string, hostname string, value string) (bool, string) {
var z *ConfigT
for d, v := range Config {
log.Log(INFO, "Delete() zone =", d, "value =", v)
- if (zone == d) {
+ if zone == d {
z = Config[zone]
log.Log(INFO, "Delete() FOUND ZONE", zone, "ID =", z.ZoneID)
}
}
- if (z == nil) {
+ if z == nil {
log.Log(WARN, "Delete() COULD NOT FIND ZONE", zone)
return false, ""
}
@@ -42,10 +42,10 @@ func Delete(zone string, hostname string, value string) (bool, string) {
records := GetZonefile(z)
for i, record := range records.Result {
- if (record.Name == hostname) {
+ if record.Name == hostname {
log.Log(INFO, "Delete() FOUND hostname:", i, record.ID, record.Type, record.Name, record.Content)
}
- if (record.Content == value) {
+ if record.Content == value {
log.Log(INFO, "Delete() FOUND CONTENT:", i, record.ID, record.Type, record.Name, record.Content)
log.Log(INFO, "Delete() DO THE ACTUAL cloudflare DELETE here")
result := doCurlDelete(key, email, z.ZoneID, record.ID)
diff --git a/http.go b/http.go
index e1865af..b503859 100644
--- a/http.go
+++ b/http.go
@@ -1,10 +1,10 @@
// This is a simple example
package cloudflare
-import (
+import (
+ "bytes"
"io/ioutil"
"net/http"
- "bytes"
"go.wit.com/log"
)
@@ -49,7 +49,7 @@ func doCurlDelete(auth string, email string, zoneId string, rrId string) string
// Set headers
req.Header.Set("Content-Type", "application/json")
- req.Header.Set("Authorization", "Bearer " + auth)
+ req.Header.Set("Authorization", "Bearer "+auth)
// changed from this 2024-01-05
// req.Header.Set("X-Auth-Key", auth)
// req.Header.Set("X-Auth-Email", email)
@@ -87,11 +87,11 @@ func doCurlCreate(auth string, email string, zoneId string, data string) string
log.Log(CURL, "doCurlCreate() POST Email =", email)
log.Log(CURL, "doCurlCreate() POST data =", data)
- req, err = http.NewRequest(http.MethodPost, url, bytes.NewBuffer( []byte(data) ))
+ req, err = http.NewRequest(http.MethodPost, url, bytes.NewBuffer([]byte(data)))
// Set headers
req.Header.Set("Content-Type", "application/json")
- req.Header.Set("Authorization", "Bearer " + auth)
+ req.Header.Set("Authorization", "Bearer "+auth)
client := &http.Client{}
resp, err := client.Do(req)
@@ -118,7 +118,7 @@ func doCurl(method string, rr *RRT) string {
data := []byte(rr.data)
- if (method == "PUT") {
+ if method == "PUT" {
req, err = http.NewRequest(http.MethodPut, rr.url, bytes.NewBuffer(data))
} else {
req, err = http.NewRequest(http.MethodPost, rr.url, bytes.NewBuffer(data))
@@ -126,7 +126,7 @@ func doCurl(method string, rr *RRT) string {
// Set headers
req.Header.Set("Content-Type", "application/json")
- req.Header.Set("Authorization", "Bearer " + rr.Auth)
+ req.Header.Set("Authorization", "Bearer "+rr.Auth)
log.Log(CURL, "http PUT url =", rr.url)
log.Log(CURL, "http PUT Auth =", rr.Auth)
@@ -166,7 +166,7 @@ func curlPost(dnsRow *RRT) string {
// Set headers
req.Header.Set("Content-Type", "application/json")
- req.Header.Set("Authorization", "Bearer " + authKey)
+ req.Header.Set("Authorization", "Bearer "+authKey)
client := &http.Client{}
resp, err := client.Do(req)
diff --git a/json.go b/json.go
index b7c71a8..f4b253b 100644
--- a/json.go
+++ b/json.go
@@ -1,7 +1,7 @@
// This is a simple example
package cloudflare
-import (
+import (
"encoding/json"
)
diff --git a/loadZoneWindow.go b/loadZoneWindow.go
index 6342eca..68839e1 100644
--- a/loadZoneWindow.go
+++ b/loadZoneWindow.go
@@ -1,12 +1,12 @@
// This is a simple example
package cloudflare
-import (
+import (
"strconv"
- "go.wit.com/log"
"go.wit.com/gui/gui"
- "go.wit.com/gui/gadgets"
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/log"
)
func LoadZoneWindow(n *gui.Node, c *ConfigT) {
@@ -20,9 +20,9 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
// make a grid 6 things wide
grid := newg.NewGrid("gridnuts", 6, 1)
-// grid.NewButton("Type", func () {
-// log.Log(INFO, "sort by Type")
-// })
+ // grid.NewButton("Type", func () {
+ // log.Log(INFO, "sort by Type")
+ // })
grid.NewLabel("RR type")
grid.NewLabel("hostname")
@@ -54,14 +54,14 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
grid.NewLabel(record.Name)
proxy := grid.NewLabel("proxy")
- if (record.Proxied) {
+ if record.Proxied {
proxy.SetText("On")
} else {
proxy.SetText("Off")
}
- var ttl string
- if (record.TTL == 1) {
+ var ttl string
+ if record.TTL == 1 {
ttl = "Auto"
} else {
ttl = strconv.Itoa(record.TTL)
@@ -72,15 +72,15 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
val.SetText(record.Content)
load := grid.NewButton("Load", nil)
- load.Custom = func () {
+ load.Custom = func() {
name := "save stuff to cloudflare for " + rr.ID
log.Log(INFO, name)
/*
- rr.Domain = domainWidget.S
- rr.ZoneID = zoneWidget.S
- rr.Auth = authWidget.S
- rr.Email = emailWidget.S
+ rr.Domain = domainWidget.S
+ rr.ZoneID = zoneWidget.S
+ rr.Auth = authWidget.S
+ rr.Email = emailWidget.S
*/
SetRow(&rr)
diff --git a/mainWindow.go b/mainWindow.go
index 602162e..ee0df49 100644
--- a/mainWindow.go
+++ b/mainWindow.go
@@ -1,12 +1,12 @@
// This is a simple example
package cloudflare
-import (
+import (
"os"
- "go.wit.com/log"
"go.wit.com/gui/gui"
- "go.wit.com/gui/gadgets"
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/log"
)
// This creates a window
@@ -15,13 +15,13 @@ func MakeCloudflareWindow(n *gui.Node) *gadgets.BasicWindow {
log.Log(INFO, "buttonWindow() START")
- CFdialog.mainWindow = gadgets.NewBasicWindow(n,"Cloudflare Config")
+ CFdialog.mainWindow = gadgets.NewBasicWindow(n, "Cloudflare Config")
CFdialog.mainWindow.Vertical()
// this tab has the master cloudflare API credentials
makeConfigWindow(CFdialog.mainWindow.Box())
- win := gadgets.NewBasicWindow(n,"Zones")
+ win := gadgets.NewBasicWindow(n, "Zones")
g1 := win.Box().NewGroup("zones")
// make dropdown list of zones
@@ -32,10 +32,10 @@ func MakeCloudflareWindow(n *gui.Node) *gadgets.BasicWindow {
}
CFdialog.zonedrop.AddText("stablesid.org")
- CFdialog.zonedrop.Custom = func () {
+ CFdialog.zonedrop.Custom = func() {
domain := CFdialog.zonedrop.String()
log.Log(ZONE, "custom dropdown() zone (domain name) =", CFdialog.zonedrop.String(), domain)
- if (Config[domain] == nil) {
+ if Config[domain] == nil {
log.Log(ZONE, "custom dropdown() Config[domain] = nil for domain =", domain)
CFdialog.domainWidget.SetText(domain)
CFdialog.zoneWidget.SetText("")
@@ -81,7 +81,7 @@ func makeConfigWindow(vb *gui.Node) {
grid.Pad()
- vb.NewButton("Lookup Hostname", func () {
+ vb.NewButton("Lookup Hostname", func() {
log.Log(INFO, "Find all the Resource Records for hostname:", hostname.String())
log.Log(INFO, "Find all the Resource Records for zone:", zone.String())
GetZones(aw.String(), ew.String())
@@ -90,7 +90,7 @@ func makeConfigWindow(vb *gui.Node) {
}
})
- vb.NewButton("getZones()", func () {
+ vb.NewButton("getZones()", func() {
log.Log(ZONE, "getZones()")
GetZones(aw.String(), ew.String())
for d, _ := range Config {
@@ -98,7 +98,7 @@ func makeConfigWindow(vb *gui.Node) {
}
})
- vb.NewButton("cloudflare wit.com", func () {
+ vb.NewButton("cloudflare wit.com", func() {
CreateRR(CFdialog.rootGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
})
@@ -130,7 +130,7 @@ func showCloudflareCredentials(box *gui.Node) {
grid.Pad()
- CFdialog.loadButton = box.NewButton("Load Cloudflare DNS zonefile", func () {
+ CFdialog.loadButton = box.NewButton("Load Cloudflare DNS zonefile", func() {
var domain ConfigT
domain.Domain = CFdialog.domainWidget.String()
domain.ZoneID = CFdialog.zoneWidget.String()
diff --git a/rr.go b/rr.go
index f08a730..565b00a 100644
--- a/rr.go
+++ b/rr.go
@@ -6,12 +6,12 @@
package cloudflare
-import (
+import (
"os"
- "go.wit.com/log"
"go.wit.com/gui/gui"
- "go.wit.com/gui/gadgets"
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/log"
)
func init() {
@@ -19,13 +19,13 @@ func init() {
}
func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow {
- if (CFdialog.cloudflareW != nil) {
+ if CFdialog.cloudflareW != nil {
// skip this if the window has already been created
log.Warn("createRR() the cloudflare window already exists")
CFdialog.cloudflareB.Disable()
return CFdialog.cloudflareW
}
- CFdialog.cloudflareW = gadgets.NewBasicWindow(myGui, "cloudflare " + zone + " API")
+ CFdialog.cloudflareW = gadgets.NewBasicWindow(myGui, "cloudflare "+zone+" API")
group := CFdialog.cloudflareW.Box().NewGroup("Create a new DNS Resource Record (rr)")
@@ -60,7 +60,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
CFdialog.TypeNode.AddText("TXT")
CFdialog.TypeNode.AddText("MX")
CFdialog.TypeNode.AddText("NS")
- CFdialog.TypeNode.Custom = func () {
+ CFdialog.TypeNode.Custom = func() {
DoChange()
}
CFdialog.TypeNode.SetText("AAAA")
@@ -73,7 +73,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
CFdialog.NameNode.AddText("go")
CFdialog.NameNode.AddText("blog")
CFdialog.NameNode.AddText("ns1")
- CFdialog.NameNode.Custom = func () {
+ CFdialog.NameNode.Custom = func() {
DoChange()
}
CFdialog.NameNode.SetText("www")
@@ -82,7 +82,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
CFdialog.proxyNode = grid.NewDropdown()
CFdialog.proxyNode.AddText("On")
CFdialog.proxyNode.AddText("Off")
- CFdialog.proxyNode.Custom = func () {
+ CFdialog.proxyNode.Custom = func() {
DoChange()
}
CFdialog.proxyNode.SetText("Off")
@@ -92,7 +92,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
CFdialog.ValueNode.AddText("127.0.0.1")
CFdialog.ValueNode.AddText("2001:4860:4860::8888")
CFdialog.ValueNode.AddText("ipv6.wit.com")
- CFdialog.ValueNode.Custom = func () {
+ CFdialog.ValueNode.Custom = func() {
DoChange()
}
CFdialog.ValueNode.SetText("127.0.0.1")
@@ -103,7 +103,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
group.NewLabel("curl")
CFdialog.curlNode = group.NewTextbox("curl")
- CFdialog.curlNode.Custom = func () {
+ CFdialog.curlNode.Custom = func() {
DoChange()
}
CFdialog.curlNode.SetText("put the curl text here")
@@ -111,7 +111,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
CFdialog.resultNode = group.NewTextbox("result")
CFdialog.resultNode.SetText("API response will show here")
- CFdialog.SaveNode = group.NewButton("Save curlPost()", func () {
+ CFdialog.SaveNode = group.NewButton("Save curlPost()", func() {
dnsRow := DoChange()
result := curlPost(dnsRow)
CFdialog.resultNode.SetText(result)
@@ -121,7 +121,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
// CFdialog.resultNode.SetText(result)
})
// CFdialog.saveNode.Disable()
- group.NewButton("New RR doCurl(PUT)", func () {
+ group.NewButton("New RR doCurl(PUT)", func() {
rr := DoChange()
rr.url = "https://api.cloudflare.com/client/v4/zones/" + rr.ZoneID + "/dns_records"
@@ -133,7 +133,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
log.Spew(pretty)
})
- group.NewButton("Update RR doCurl(PUT)", func () {
+ group.NewButton("Update RR doCurl(PUT)", func() {
rr := DoChange()
rr.url = "https://api.cloudflare.com/client/v4/zones/" + rr.ZoneID + "/dns_records/" + rr.ID
diff --git a/structs.go b/structs.go
index 2f33532..8ac9a34 100644
--- a/structs.go
+++ b/structs.go
@@ -1,9 +1,9 @@
// This is a simple example
package cloudflare
-import (
+import (
"go.wit.com/gui/gui"
- "go.wit.com/gui/gadgets"
+ "go.wit.com/lib/gadgets"
)
var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/"
@@ -12,95 +12,95 @@ var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/"
// 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"`
+ 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"`
}
-// CFdialog is everything you need forcreating
+// CFdialog is everything you need forcreating
// a new record: name, TTL, type (CNAME, A, etc)
var CFdialog dialogT
type dialogT struct {
- rootGui *gui.Node // the root node
- mainWindow *gadgets.BasicWindow // the window node
- zonedrop *gui.Node // the drop down menu of zones
+ rootGui *gui.Node // the root node
+ mainWindow *gadgets.BasicWindow // the window node
+ zonedrop *gui.Node // the drop down menu of zones
domainWidget *gui.Node
- zoneWidget *gui.Node
- authWidget *gui.Node
- emailWidget *gui.Node
+ zoneWidget *gui.Node
+ authWidget *gui.Node
+ emailWidget *gui.Node
loadButton *gui.Node
saveButton *gui.Node
- cloudflareW *gadgets.BasicWindow // the window node
- cloudflareB *gui.Node // the cloudflare button
+ cloudflareW *gadgets.BasicWindow // the window node
+ cloudflareB *gui.Node // the cloudflare button
- TypeNode *gui.Node // CNAME, A, AAAA, ...
- NameNode *gui.Node // www, mail, ...
- ValueNode *gui.Node // 4.2.2.2, "dkim stuff", etc
+ TypeNode *gui.Node // CNAME, A, AAAA, ...
+ NameNode *gui.Node // www, mail, ...
+ ValueNode *gui.Node // 4.2.2.2, "dkim stuff", etc
- rrNode *gui.Node // cloudflare Resource Record ID
- proxyNode *gui.Node // If cloudflare is a port 80 & 443 proxy
- ttlNode *gui.Node // just set to 1 which means automatic to cloudflare
- 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
+ rrNode *gui.Node // cloudflare Resource Record ID
+ proxyNode *gui.Node // If cloudflare is a port 80 & 443 proxy
+ ttlNode *gui.Node // just set to 1 which means automatic to cloudflare
+ 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
- zoneNode *gui.Node // "wit.com"
- zoneIdNode *gui.Node // cloudflare zone ID
- apiNode *gui.Node // cloudflare API key (from environment var CF_API_KEY)
- emailNode *gui.Node // cloudflare email (from environment var CF_API_EMAIL)
- urlNode *gui.Node // the URL to POST, PUT, DELETE, etc
+ zoneNode *gui.Node // "wit.com"
+ zoneIdNode *gui.Node // cloudflare zone ID
+ apiNode *gui.Node // cloudflare API key (from environment var CF_API_KEY)
+ emailNode *gui.Node // cloudflare email (from environment var CF_API_EMAIL)
+ urlNode *gui.Node // the URL to POST, PUT, DELETE, etc
}
// Resource Record (used in a DNS zonefile)
type RRT struct {
- ID string
- Type string
- Name string
- Content string
- ProxyS string
- Proxied bool
+ ID string
+ Type string
+ Name string
+ Content string
+ ProxyS string
+ Proxied bool
Proxiable bool
- Ttl string
+ Ttl string
Domain string
ZoneID string
- Auth string
- Email string
- url string
- data string
+ Auth string
+ Email string
+ url string
+ data string
}
/*
- This is a structure of all the RR's (Resource Records)
- in the DNS zonefiile for a hostname. For example:
+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:
+For the host test.wit.com:
- test.wit.com A 127.0.0.1
- test.wit.com AAAA
- test.wit.com TXT email [email protected]
- test.wit.com TXT phone 212-555-1212
- test.wit.com CNAME real.wit.com
+test.wit.com A 127.0.0.1
+test.wit.com AAAA
+test.wit.com TXT email [email protected]
+test.wit.com TXT phone 212-555-1212
+test.wit.com CNAME real.wit.com
*/
type hostT struct {
hostname string
- RRs []ConfigT
+ RRs []ConfigT
}
type ConfigT struct {
Domain string
ZoneID string
- Auth string
- Email string
+ Auth string
+ Email string
}
var Config map[string]*ConfigT
diff --git a/zonesBox.go b/zonesBox.go
index 9f71173..79eac33 100644
--- a/zonesBox.go
+++ b/zonesBox.go
@@ -1,9 +1,9 @@
// This is a simple example
package cloudflare
-import (
- "go.wit.com/log"
+import (
"go.wit.com/gui/gui"
+ "go.wit.com/log"
)
func drawZoneBox(box *gui.Node) {
@@ -17,10 +17,10 @@ func drawZoneBox(box *gui.Node) {
}
CFdialog.zonedrop.AddText("stablesid.org")
- CFdialog.zonedrop.Custom = func () {
+ CFdialog.zonedrop.Custom = func() {
domain := CFdialog.zonedrop.String()
log.Log(INFO, "custom dropdown() zone (domain name) =", CFdialog.zonedrop.String(), domain)
- if (Config[domain] == nil) {
+ if Config[domain] == nil {
log.Log(INFO, "custom dropdown() Config[domain] = nil for domain =", domain)
CFdialog.domainWidget.SetText(domain)
CFdialog.zoneWidget.SetText("")