parent
586494505b
commit
f0b712faf8
54
api.go
54
api.go
|
@ -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
|
||||
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
|
||||
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,7 +162,7 @@ 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 += `}`
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
|
2
args.go
2
args.go
|
@ -18,7 +18,7 @@ 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")
|
||||
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
14
delete.go
14
delete.go
|
@ -7,8 +7,8 @@
|
|||
package cloudflare
|
||||
|
||||
import (
|
||||
"os"
|
||||
"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)
|
||||
|
|
14
http.go
14
http.go
|
@ -2,9 +2,9 @@
|
|||
package cloudflare
|
||||
|
||||
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)
|
||||
|
|
|
@ -4,9 +4,9 @@ package cloudflare
|
|||
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) {
|
||||
if record.TTL == 1 {
|
||||
ttl = "Auto"
|
||||
} else {
|
||||
ttl = strconv.Itoa(record.TTL)
|
||||
|
@ -72,7 +72,7 @@ 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)
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ package cloudflare
|
|||
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()
|
||||
|
|
24
rr.go
24
rr.go
|
@ -9,9 +9,9 @@ package cloudflare
|
|||
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
|
||||
|
|
18
structs.go
18
structs.go
|
@ -3,7 +3,7 @@ package cloudflare
|
|||
|
||||
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/"
|
||||
|
@ -80,16 +80,16 @@ type RRT struct {
|
|||
}
|
||||
|
||||
/*
|
||||
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 test@wit.com
|
||||
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 test@wit.com
|
||||
test.wit.com TXT phone 212-555-1212
|
||||
test.wit.com CNAME real.wit.com
|
||||
*/
|
||||
type hostT struct {
|
||||
hostname string
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
package cloudflare
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
"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("")
|
||||
|
|
Loading…
Reference in New Issue