fix paths

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 01:33:28 -06:00
parent 586494505b
commit f0b712faf8
11 changed files with 152 additions and 152 deletions

54
api.go
View File

@ -10,20 +10,20 @@ import (
) )
/* /*
This function should run each time This function should run each time
the user chanegs anything in the GUi the user chanegs anything in the GUi
or each time something in general changes or each time something in general changes
It returns a RR record which then can be It returns a RR record which then can be
turned into JSON and sent via http turned into JSON and sent via http
to cloudflare's API to cloudflare's API
*/ */
func DoChange() *RRT { func DoChange() *RRT {
var dnsRow *RRT var dnsRow *RRT
dnsRow = new(RRT) dnsRow = new(RRT)
log.Log(INFO, "DoChange() START") log.Log(INFO, "DoChange() START")
if (CFdialog.proxyNode.String() == "On") { if CFdialog.proxyNode.String() == "On" {
dnsRow.Proxied = true dnsRow.Proxied = true
} else { } else {
dnsRow.Proxied = false dnsRow.Proxied = false
@ -44,7 +44,7 @@ func DoChange() *RRT {
// show the JSON // show the JSON
log.Log(INFO, dnsRow) log.Log(INFO, dnsRow)
if (CFdialog.curlNode != nil) { if CFdialog.curlNode != nil {
pretty, _ := FormatJSON(dnsRow.data) pretty, _ := FormatJSON(dnsRow.data)
log.Log(INFO, "http PUT curl =", pretty) log.Log(INFO, "http PUT curl =", pretty)
CFdialog.curlNode.SetText(pretty) CFdialog.curlNode.SetText(pretty)
@ -54,36 +54,36 @@ func DoChange() *RRT {
func SetRow(dnsRow *RRT) { func SetRow(dnsRow *RRT) {
log.Log(INFO, "Look for changes in row", dnsRow.ID) 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()) log.Log(INFO, "Proxy", dnsRow.Proxied, "vs", CFdialog.proxyNode.String())
if (dnsRow.Proxied == true) { if dnsRow.Proxied == true {
CFdialog.proxyNode.SetText("On") CFdialog.proxyNode.SetText("On")
} else { } else {
CFdialog.proxyNode.SetText("Off") CFdialog.proxyNode.SetText("Off")
} }
} }
if (CFdialog.zoneNode != nil) { if CFdialog.zoneNode != nil {
CFdialog.zoneNode.SetText(dnsRow.Domain) CFdialog.zoneNode.SetText(dnsRow.Domain)
} }
if (CFdialog.zoneIdNode != nil) { if CFdialog.zoneIdNode != nil {
CFdialog.zoneIdNode.SetText(dnsRow.ZoneID) CFdialog.zoneIdNode.SetText(dnsRow.ZoneID)
} }
log.Log(INFO, "zoneIdNode =", dnsRow.ZoneID) log.Log(INFO, "zoneIdNode =", dnsRow.ZoneID)
if (CFdialog.rrNode != nil) { if CFdialog.rrNode != nil {
CFdialog.rrNode.SetText(dnsRow.ID) CFdialog.rrNode.SetText(dnsRow.ID)
} }
if (CFdialog.ValueNode != nil) { if CFdialog.ValueNode != nil {
log.Log(INFO, "Content", dnsRow.Content, "vs", CFdialog.ValueNode.String()) log.Log(INFO, "Content", dnsRow.Content, "vs", CFdialog.ValueNode.String())
CFdialog.ValueNode.SetText(dnsRow.Content) CFdialog.ValueNode.SetText(dnsRow.Content)
} }
if (CFdialog.NameNode != nil) { if CFdialog.NameNode != nil {
CFdialog.NameNode.SetText(dnsRow.Name) CFdialog.NameNode.SetText(dnsRow.Name)
} }
if (CFdialog.TypeNode != nil) { if CFdialog.TypeNode != nil {
CFdialog.TypeNode.SetText(dnsRow.Type) CFdialog.TypeNode.SetText(dnsRow.Type)
} }
if (CFdialog.urlNode != nil) { if CFdialog.urlNode != nil {
url := cloudflareURL + dnsRow.ZoneID + "/dns_records/" + dnsRow.ID url := cloudflareURL + dnsRow.ZoneID + "/dns_records/" + dnsRow.ID
CFdialog.urlNode.SetText(url) CFdialog.urlNode.SetText(url)
} }
@ -91,7 +91,7 @@ func SetRow(dnsRow *RRT) {
// show the JSON // show the JSON
tmp := makeJSON(dnsRow) tmp := makeJSON(dnsRow)
log.Spew(tmp) log.Spew(tmp)
if (CFdialog.curlNode != nil) { if CFdialog.curlNode != nil {
pretty, _ := FormatJSON(tmp) pretty, _ := FormatJSON(tmp)
log.Spew("http PUT curl =", pretty) log.Spew("http PUT curl =", pretty)
CFdialog.curlNode.SetText(pretty) CFdialog.curlNode.SetText(pretty)
@ -108,7 +108,7 @@ func GetZonefile(c *ConfigT) *DNSRecords {
} }
// Set headers // 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-Key", c.Auth)
// req.Header.Set("X-Auth-Email", c.Email) // 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: For example:
gitea.wit.com. 3600 IN CNAME git.wit.com. gitea.wit.com. 3600 IN CNAME git.wit.com.
go.wit.com. 3600 IN A 1.1.1.9 go.wit.com. 3600 IN A 1.1.1.9
test.wit.com. 3600 IN NS ns1.wit.com. test.wit.com. 3600 IN NS ns1.wit.com.
*/ */
func makeJSON(dnsRow *RRT) string { func makeJSON(dnsRow *RRT) string {
// make a json record to send on port 80 to cloudflare // make a json record to send on port 80 to cloudflare
@ -162,7 +162,7 @@ func makeJSON(dnsRow *RRT) string {
tmp = `{"content": "` + dnsRow.Content + `", ` tmp = `{"content": "` + dnsRow.Content + `", `
tmp += `"name": "` + dnsRow.Name + `", ` tmp += `"name": "` + dnsRow.Name + `", `
tmp += `"type": "` + dnsRow.Type + `", ` tmp += `"type": "` + dnsRow.Type + `", `
tmp+= `"ttl": "` + "1" + `", ` tmp += `"ttl": "` + "1" + `", `
tmp += `"comment": "WIT DNS Control Panel"` tmp += `"comment": "WIT DNS Control Panel"`
tmp += `}` tmp += `}`
@ -180,7 +180,7 @@ func GetZones(auth, email string) *DNSRecords {
} }
// Set headers // 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-Key", auth)
// req.Header.Set("X-Auth-Email", email) // req.Header.Set("X-Auth-Email", email)

View File

@ -18,7 +18,7 @@ func init() {
full := "go.wit.com/gui/cloudflare" full := "go.wit.com/gui/cloudflare"
short := "cfgui" 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") 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") SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")

View File

@ -17,11 +17,11 @@ func Create(zone string, hostname string, value string) bool {
key := os.Getenv("CF_API_KEY") key := os.Getenv("CF_API_KEY")
email := os.Getenv("CF_API_EMAIL") email := os.Getenv("CF_API_EMAIL")
if (key == "") { if key == "" {
log.Warn("cloudflare.Create() MISSING environment variable CF_API_KEY") log.Warn("cloudflare.Create() MISSING environment variable CF_API_KEY")
return false return false
} }
if (email == "") { if email == "" {
log.Warn("cloudflare.Create() MISSING environment variable CF_API_EMAIL") log.Warn("cloudflare.Create() MISSING environment variable CF_API_EMAIL")
return false return false
} }
@ -30,12 +30,12 @@ func Create(zone string, hostname string, value string) bool {
var z *ConfigT var z *ConfigT
for d, v := range Config { for d, v := range Config {
log.Log(INFO, "cloudflare.Create() zone =", d, "value =", v) log.Log(INFO, "cloudflare.Create() zone =", d, "value =", v)
if (zone == d) { if zone == d {
z = Config[zone] z = Config[zone]
log.Log(INFO, "cloudflare.Create() FOUND ZONE", zone, "ID =", z.ZoneID) 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) log.Warn("cloudflare.Create() COULD NOT FIND ZONE", zone)
return false return false
} }

View File

@ -7,8 +7,8 @@
package cloudflare package cloudflare
import ( import (
"os"
"go.wit.com/log" "go.wit.com/log"
"os"
) )
func Delete(zone string, hostname string, value string) (bool, string) { 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") key := os.Getenv("CF_API_KEY")
email := os.Getenv("CF_API_EMAIL") email := os.Getenv("CF_API_EMAIL")
if (key == "") { if key == "" {
log.Log(WARN, "Delete() MISSING environment variable CF_API_KEY") log.Log(WARN, "Delete() MISSING environment variable CF_API_KEY")
return false, "" return false, ""
} }
if (email == "") { if email == "" {
log.Log(WARN, "Delete() MISSING environment variable CF_API_EMAIL") log.Log(WARN, "Delete() MISSING environment variable CF_API_EMAIL")
return false, "" return false, ""
} }
@ -29,12 +29,12 @@ func Delete(zone string, hostname string, value string) (bool, string) {
var z *ConfigT var z *ConfigT
for d, v := range Config { for d, v := range Config {
log.Log(INFO, "Delete() zone =", d, "value =", v) log.Log(INFO, "Delete() zone =", d, "value =", v)
if (zone == d) { if zone == d {
z = Config[zone] z = Config[zone]
log.Log(INFO, "Delete() FOUND ZONE", zone, "ID =", z.ZoneID) 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) log.Log(WARN, "Delete() COULD NOT FIND ZONE", zone)
return false, "" return false, ""
} }
@ -42,10 +42,10 @@ func Delete(zone string, hostname string, value string) (bool, string) {
records := GetZonefile(z) records := GetZonefile(z)
for i, record := range records.Result { 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) 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() FOUND CONTENT:", i, record.ID, record.Type, record.Name, record.Content)
log.Log(INFO, "Delete() DO THE ACTUAL cloudflare DELETE here") log.Log(INFO, "Delete() DO THE ACTUAL cloudflare DELETE here")
result := doCurlDelete(key, email, z.ZoneID, record.ID) result := doCurlDelete(key, email, z.ZoneID, record.ID)

14
http.go
View File

@ -2,9 +2,9 @@
package cloudflare package cloudflare
import ( import (
"bytes"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"bytes"
"go.wit.com/log" "go.wit.com/log"
) )
@ -49,7 +49,7 @@ func doCurlDelete(auth string, email string, zoneId string, rrId string) string
// Set headers // Set headers
req.Header.Set("Content-Type", "application/json") 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 // changed from this 2024-01-05
// req.Header.Set("X-Auth-Key", auth) // req.Header.Set("X-Auth-Key", auth)
// req.Header.Set("X-Auth-Email", email) // 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 Email =", email)
log.Log(CURL, "doCurlCreate() POST data =", data) 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 // Set headers
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer " + auth) req.Header.Set("Authorization", "Bearer "+auth)
client := &http.Client{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)
@ -118,7 +118,7 @@ func doCurl(method string, rr *RRT) string {
data := []byte(rr.data) data := []byte(rr.data)
if (method == "PUT") { if method == "PUT" {
req, err = http.NewRequest(http.MethodPut, rr.url, bytes.NewBuffer(data)) req, err = http.NewRequest(http.MethodPut, rr.url, bytes.NewBuffer(data))
} else { } else {
req, err = http.NewRequest(http.MethodPost, rr.url, bytes.NewBuffer(data)) req, err = http.NewRequest(http.MethodPost, rr.url, bytes.NewBuffer(data))
@ -126,7 +126,7 @@ func doCurl(method string, rr *RRT) string {
// Set headers // Set headers
req.Header.Set("Content-Type", "application/json") 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 url =", rr.url)
log.Log(CURL, "http PUT Auth =", rr.Auth) log.Log(CURL, "http PUT Auth =", rr.Auth)
@ -166,7 +166,7 @@ func curlPost(dnsRow *RRT) string {
// Set headers // Set headers
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer " + authKey) req.Header.Set("Authorization", "Bearer "+authKey)
client := &http.Client{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)

View File

@ -4,9 +4,9 @@ package cloudflare
import ( import (
"strconv" "strconv"
"go.wit.com/log"
"go.wit.com/gui/gui" "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) { func LoadZoneWindow(n *gui.Node, c *ConfigT) {
@ -20,9 +20,9 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
// make a grid 6 things wide // make a grid 6 things wide
grid := newg.NewGrid("gridnuts", 6, 1) grid := newg.NewGrid("gridnuts", 6, 1)
// grid.NewButton("Type", func () { // grid.NewButton("Type", func () {
// log.Log(INFO, "sort by Type") // log.Log(INFO, "sort by Type")
// }) // })
grid.NewLabel("RR type") grid.NewLabel("RR type")
grid.NewLabel("hostname") grid.NewLabel("hostname")
@ -54,14 +54,14 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
grid.NewLabel(record.Name) grid.NewLabel(record.Name)
proxy := grid.NewLabel("proxy") proxy := grid.NewLabel("proxy")
if (record.Proxied) { if record.Proxied {
proxy.SetText("On") proxy.SetText("On")
} else { } else {
proxy.SetText("Off") proxy.SetText("Off")
} }
var ttl string var ttl string
if (record.TTL == 1) { if record.TTL == 1 {
ttl = "Auto" ttl = "Auto"
} else { } else {
ttl = strconv.Itoa(record.TTL) ttl = strconv.Itoa(record.TTL)
@ -72,7 +72,7 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
val.SetText(record.Content) val.SetText(record.Content)
load := grid.NewButton("Load", nil) load := grid.NewButton("Load", nil)
load.Custom = func () { load.Custom = func() {
name := "save stuff to cloudflare for " + rr.ID name := "save stuff to cloudflare for " + rr.ID
log.Log(INFO, name) log.Log(INFO, name)

View File

@ -4,9 +4,9 @@ package cloudflare
import ( import (
"os" "os"
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log"
) )
// This creates a window // This creates a window
@ -15,13 +15,13 @@ func MakeCloudflareWindow(n *gui.Node) *gadgets.BasicWindow {
log.Log(INFO, "buttonWindow() START") log.Log(INFO, "buttonWindow() START")
CFdialog.mainWindow = gadgets.NewBasicWindow(n,"Cloudflare Config") CFdialog.mainWindow = gadgets.NewBasicWindow(n, "Cloudflare Config")
CFdialog.mainWindow.Vertical() CFdialog.mainWindow.Vertical()
// this tab has the master cloudflare API credentials // this tab has the master cloudflare API credentials
makeConfigWindow(CFdialog.mainWindow.Box()) makeConfigWindow(CFdialog.mainWindow.Box())
win := gadgets.NewBasicWindow(n,"Zones") win := gadgets.NewBasicWindow(n, "Zones")
g1 := win.Box().NewGroup("zones") g1 := win.Box().NewGroup("zones")
// make dropdown list of zones // make dropdown list of zones
@ -32,10 +32,10 @@ func MakeCloudflareWindow(n *gui.Node) *gadgets.BasicWindow {
} }
CFdialog.zonedrop.AddText("stablesid.org") CFdialog.zonedrop.AddText("stablesid.org")
CFdialog.zonedrop.Custom = func () { CFdialog.zonedrop.Custom = func() {
domain := CFdialog.zonedrop.String() domain := CFdialog.zonedrop.String()
log.Log(ZONE, "custom dropdown() zone (domain name) =", CFdialog.zonedrop.String(), domain) 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) log.Log(ZONE, "custom dropdown() Config[domain] = nil for domain =", domain)
CFdialog.domainWidget.SetText(domain) CFdialog.domainWidget.SetText(domain)
CFdialog.zoneWidget.SetText("") CFdialog.zoneWidget.SetText("")
@ -81,7 +81,7 @@ func makeConfigWindow(vb *gui.Node) {
grid.Pad() 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 hostname:", hostname.String())
log.Log(INFO, "Find all the Resource Records for zone:", zone.String()) log.Log(INFO, "Find all the Resource Records for zone:", zone.String())
GetZones(aw.String(), ew.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()") log.Log(ZONE, "getZones()")
GetZones(aw.String(), ew.String()) GetZones(aw.String(), ew.String())
for d, _ := range Config { 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") CreateRR(CFdialog.rootGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
}) })
@ -130,7 +130,7 @@ func showCloudflareCredentials(box *gui.Node) {
grid.Pad() grid.Pad()
CFdialog.loadButton = box.NewButton("Load Cloudflare DNS zonefile", func () { CFdialog.loadButton = box.NewButton("Load Cloudflare DNS zonefile", func() {
var domain ConfigT var domain ConfigT
domain.Domain = CFdialog.domainWidget.String() domain.Domain = CFdialog.domainWidget.String()
domain.ZoneID = CFdialog.zoneWidget.String() domain.ZoneID = CFdialog.zoneWidget.String()

24
rr.go
View File

@ -9,9 +9,9 @@ package cloudflare
import ( import (
"os" "os"
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log"
) )
func init() { func init() {
@ -19,13 +19,13 @@ func init() {
} }
func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow { 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 // skip this if the window has already been created
log.Warn("createRR() the cloudflare window already exists") log.Warn("createRR() the cloudflare window already exists")
CFdialog.cloudflareB.Disable() CFdialog.cloudflareB.Disable()
return CFdialog.cloudflareW 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)") 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("TXT")
CFdialog.TypeNode.AddText("MX") CFdialog.TypeNode.AddText("MX")
CFdialog.TypeNode.AddText("NS") CFdialog.TypeNode.AddText("NS")
CFdialog.TypeNode.Custom = func () { CFdialog.TypeNode.Custom = func() {
DoChange() DoChange()
} }
CFdialog.TypeNode.SetText("AAAA") 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("go")
CFdialog.NameNode.AddText("blog") CFdialog.NameNode.AddText("blog")
CFdialog.NameNode.AddText("ns1") CFdialog.NameNode.AddText("ns1")
CFdialog.NameNode.Custom = func () { CFdialog.NameNode.Custom = func() {
DoChange() DoChange()
} }
CFdialog.NameNode.SetText("www") 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 = grid.NewDropdown()
CFdialog.proxyNode.AddText("On") CFdialog.proxyNode.AddText("On")
CFdialog.proxyNode.AddText("Off") CFdialog.proxyNode.AddText("Off")
CFdialog.proxyNode.Custom = func () { CFdialog.proxyNode.Custom = func() {
DoChange() DoChange()
} }
CFdialog.proxyNode.SetText("Off") 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("127.0.0.1")
CFdialog.ValueNode.AddText("2001:4860:4860::8888") CFdialog.ValueNode.AddText("2001:4860:4860::8888")
CFdialog.ValueNode.AddText("ipv6.wit.com") CFdialog.ValueNode.AddText("ipv6.wit.com")
CFdialog.ValueNode.Custom = func () { CFdialog.ValueNode.Custom = func() {
DoChange() DoChange()
} }
CFdialog.ValueNode.SetText("127.0.0.1") 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") group.NewLabel("curl")
CFdialog.curlNode = group.NewTextbox("curl") CFdialog.curlNode = group.NewTextbox("curl")
CFdialog.curlNode.Custom = func () { CFdialog.curlNode.Custom = func() {
DoChange() DoChange()
} }
CFdialog.curlNode.SetText("put the curl text here") 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 = group.NewTextbox("result")
CFdialog.resultNode.SetText("API response will show here") CFdialog.resultNode.SetText("API response will show here")
CFdialog.SaveNode = group.NewButton("Save curlPost()", func () { CFdialog.SaveNode = group.NewButton("Save curlPost()", func() {
dnsRow := DoChange() dnsRow := DoChange()
result := curlPost(dnsRow) result := curlPost(dnsRow)
CFdialog.resultNode.SetText(result) CFdialog.resultNode.SetText(result)
@ -121,7 +121,7 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) *gadgets.BasicWindow
// CFdialog.resultNode.SetText(result) // CFdialog.resultNode.SetText(result)
}) })
// CFdialog.saveNode.Disable() // CFdialog.saveNode.Disable()
group.NewButton("New RR doCurl(PUT)", func () { group.NewButton("New RR doCurl(PUT)", func() {
rr := DoChange() rr := DoChange()
rr.url = "https://api.cloudflare.com/client/v4/zones/" + rr.ZoneID + "/dns_records" 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) log.Spew(pretty)
}) })
group.NewButton("Update RR doCurl(PUT)", func () { group.NewButton("Update RR doCurl(PUT)", func() {
rr := DoChange() rr := DoChange()
rr.url = "https://api.cloudflare.com/client/v4/zones/" + rr.ZoneID + "/dns_records/" + rr.ID rr.url = "https://api.cloudflare.com/client/v4/zones/" + rr.ZoneID + "/dns_records/" + rr.ID

View File

@ -3,7 +3,7 @@ package cloudflare
import ( import (
"go.wit.com/gui/gui" "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/" var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/"
@ -80,16 +80,16 @@ type RRT struct {
} }
/* /*
This is a structure of all the RR's (Resource Records) This is a structure of all the RR's (Resource Records)
in the DNS zonefiile for a hostname. For example: 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 A 127.0.0.1
test.wit.com AAAA test.wit.com AAAA
test.wit.com TXT email test@wit.com test.wit.com TXT email test@wit.com
test.wit.com TXT phone 212-555-1212 test.wit.com TXT phone 212-555-1212
test.wit.com CNAME real.wit.com test.wit.com CNAME real.wit.com
*/ */
type hostT struct { type hostT struct {
hostname string hostname string

View File

@ -2,8 +2,8 @@
package cloudflare package cloudflare
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/log"
) )
func drawZoneBox(box *gui.Node) { func drawZoneBox(box *gui.Node) {
@ -17,10 +17,10 @@ func drawZoneBox(box *gui.Node) {
} }
CFdialog.zonedrop.AddText("stablesid.org") CFdialog.zonedrop.AddText("stablesid.org")
CFdialog.zonedrop.Custom = func () { CFdialog.zonedrop.Custom = func() {
domain := CFdialog.zonedrop.String() domain := CFdialog.zonedrop.String()
log.Log(INFO, "custom dropdown() zone (domain name) =", CFdialog.zonedrop.String(), domain) 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) log.Log(INFO, "custom dropdown() Config[domain] = nil for domain =", domain)
CFdialog.domainWidget.SetText(domain) CFdialog.domainWidget.SetText(domain)
CFdialog.zoneWidget.SetText("") CFdialog.zoneWidget.SetText("")