manitu api v1
This commit is contained in:
parent
8fc6c4f7de
commit
fd543c4855
26
main.go
26
main.go
@ -97,6 +97,7 @@ type Entry struct {
|
|||||||
Name string `json:"host"`
|
Name string `json:"host"`
|
||||||
TTL int `json:"ttl"`
|
TTL int `json:"ttl"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
ClassType string `json:"classtype"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
ZoneID string `json:"zone"`
|
ZoneID string `json:"zone"`
|
||||||
}
|
}
|
||||||
@ -139,17 +140,17 @@ func (c *manituDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
|
|||||||
// Display Results
|
// Display Results
|
||||||
fmt.Println("response Status : ", resp.Status)
|
fmt.Println("response Status : ", resp.Status)
|
||||||
fmt.Println("response Headers : ", resp.Header)
|
fmt.Println("response Headers : ", resp.Header)
|
||||||
fmt.Println("response Body : ", respBody.Zone.ZoneID)
|
fmt.Println("response Body : ", respBody.ZoneID)
|
||||||
|
|
||||||
// Create DNS
|
// Create DNS
|
||||||
entry, err := json.Marshal(Entry{"", name, 300, "TXT", ch.Key, respBody.Zones[0].ZoneID})
|
entry, err := json.Marshal(Entry{name, 300, "TXT", "IN", ch.Key, respBody.ZoneID})
|
||||||
body := bytes.NewBuffer(entry)
|
body := bytes.NewBuffer(entry)
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
req, err = http.NewRequest("POST", "https://dnsapi.elutions-network.de/api/v1/records", body)
|
req, err = http.NewRequest("POST", "https://dnsapi.elutions-network.de/api/v1/records", body)
|
||||||
// Headers
|
// Headers
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("Auth-API-Token", cfg.APIKey)
|
req.Header.Add("Authorization", cfg.APIKey)
|
||||||
|
|
||||||
// Fetch Request
|
// Fetch Request
|
||||||
resp, err = client.Do(req)
|
resp, err = client.Do(req)
|
||||||
@ -190,9 +191,9 @@ func (c *manituDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
|||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
zReq, err := http.NewRequest("GET", "https://dnsapi.elutions-network.de/api/v1/zones?search_name="+zone, nil)
|
zReq, err := http.NewRequest("GET", "https://dnsapi.elutions-network.de/api/v1/zones/"+zone, nil)
|
||||||
// Headers
|
// Headers
|
||||||
zReq.Header.Add("Auth-API-Token", cfg.APIKey)
|
zReq.Header.Add("Authorization", cfg.APIKey)
|
||||||
|
|
||||||
// Fetch Request
|
// Fetch Request
|
||||||
zResp, err := client.Do(zReq)
|
zResp, err := client.Do(zReq)
|
||||||
@ -201,19 +202,19 @@ func (c *manituDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read Response Body
|
// Read Response Body
|
||||||
zRespBody := Zones{}
|
zRespBody := Zone{}
|
||||||
json.NewDecoder(zResp.Body).Decode(&zRespBody)
|
json.NewDecoder(zResp.Body).Decode(&zRespBody)
|
||||||
|
|
||||||
// Display Results
|
// Display Results
|
||||||
fmt.Println("response Status : ", zResp.Status)
|
fmt.Println("response Status : ", zResp.Status)
|
||||||
fmt.Println("response Headers : ", zResp.Header)
|
fmt.Println("response Headers : ", zResp.Header)
|
||||||
fmt.Println("response Body : ", zRespBody.Zones[0].ZoneID)
|
fmt.Println("response Body : ", zRespBody.ZoneID)
|
||||||
fmt.Println("response Body : ", name)
|
fmt.Println("response Body : ", name)
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
eReq, err := http.NewRequest("GET", "https://dnsapi.elutions-network.de/api/v1/records?zone_id="+zRespBody.Zones[0].ZoneID, nil)
|
eReq, err := http.NewRequest("GET", "https://dnsapi.elutions-network.de/api/v1/zones/"+zRespBody.ZoneID+"/records", nil)
|
||||||
// Headers
|
// Headers
|
||||||
eReq.Header.Add("Auth-API-Token", cfg.APIKey)
|
eReq.Header.Add("Authorization", cfg.APIKey)
|
||||||
|
|
||||||
// Fetch Request
|
// Fetch Request
|
||||||
eResp, err := client.Do(eReq)
|
eResp, err := client.Do(eReq)
|
||||||
@ -226,6 +227,7 @@ func (c *manituDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
|||||||
json.NewDecoder(eResp.Body).Decode(&eRespBody)
|
json.NewDecoder(eResp.Body).Decode(&eRespBody)
|
||||||
|
|
||||||
// Display Results
|
// Display Results
|
||||||
|
|
||||||
fmt.Println("response Status : ", eResp.Status)
|
fmt.Println("response Status : ", eResp.Status)
|
||||||
fmt.Println("response Headers : ", eResp.Header)
|
fmt.Println("response Headers : ", eResp.Header)
|
||||||
fmt.Println("response Body : ", eRespBody)
|
fmt.Println("response Body : ", eRespBody)
|
||||||
@ -233,12 +235,12 @@ func (c *manituDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
|||||||
for _, e := range eRespBody.Records {
|
for _, e := range eRespBody.Records {
|
||||||
if e.Type == "TXT" && e.Name == name && e.Value == ch.Key {
|
if e.Type == "TXT" && e.Name == name && e.Value == ch.Key {
|
||||||
fmt.Println("Found DOMAIN: ", e)
|
fmt.Println("Found DOMAIN: ", e)
|
||||||
// Delete Record (DELETE https://dnsapi.elutions-network.de/api/v1/records/1)
|
// Delete Record
|
||||||
// Create request
|
// Create request
|
||||||
req, err := http.NewRequest("DELETE", "https://dnsapi.elutions-network.de/api/v1/records/"+e.ID, nil)
|
req, err := http.NewRequest("DELETE", "https://dnsapi.elutions-network.de/api/v1/zones/"+zRespBody.ZoneID+"/records?host="+e.Name+"&value="+e.Value+"&type="+e.Type, nil)
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
req.Header.Add("Auth-API-Token", cfg.APIKey)
|
req.Header.Add("Authorization", cfg.APIKey)
|
||||||
|
|
||||||
// Fetch Request
|
// Fetch Request
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user