Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DNS provider for Internet.bs #1431

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[linters-settings.misspell]
locale = "US"
ignore-words = ["internetbs"]

[linters-settings.depguard]
list-type = "blacklist"
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
| [Gandi Live DNS (v5)](https://go-acme.github.io/lego/dns/gandiv5/) | [Gandi](https://go-acme.github.io/lego/dns/gandi/) | [Glesys](https://go-acme.github.io/lego/dns/glesys/) | [Go Daddy](https://go-acme.github.io/lego/dns/godaddy/) |
| [Google Cloud](https://go-acme.github.io/lego/dns/gcloud/) | [Hetzner](https://go-acme.github.io/lego/dns/hetzner/) | [Hosting.de](https://go-acme.github.io/lego/dns/hostingde/) | [HTTP request](https://go-acme.github.io/lego/dns/httpreq/) |
| [Hurricane Electric DNS](https://go-acme.github.io/lego/dns/hurricane/) | [HyperOne](https://go-acme.github.io/lego/dns/hyperone/) | [Infoblox](https://go-acme.github.io/lego/dns/infoblox/) | [Infomaniak](https://go-acme.github.io/lego/dns/infomaniak/) |
| [Internet Initiative Japan](https://go-acme.github.io/lego/dns/iij/) | [INWX](https://go-acme.github.io/lego/dns/inwx/) | [Ionos](https://go-acme.github.io/lego/dns/ionos/) | [Joker](https://go-acme.github.io/lego/dns/joker/) |
| [Joohoi's ACME-DNS](https://go-acme.github.io/lego/dns/acme-dns/) | [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) | [Loopia](https://go-acme.github.io/lego/dns/loopia/) |
| [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | [Manual](https://go-acme.github.io/lego/dns/manual/) | [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) | [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) |
| [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) | [Netcup](https://go-acme.github.io/lego/dns/netcup/) |
| [Netlify](https://go-acme.github.io/lego/dns/netlify/) | [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) | [NS1](https://go-acme.github.io/lego/dns/ns1/) |
| [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | [OVH](https://go-acme.github.io/lego/dns/ovh/) | [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) |
| [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | [reg.ru](https://go-acme.github.io/lego/dns/regru/) | [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) |
| [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) | [Selectel](https://go-acme.github.io/lego/dns/selectel/) |
| [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | [Sonic](https://go-acme.github.io/lego/dns/sonic/) | [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) |
| [TransIP](https://go-acme.github.io/lego/dns/transip/) | [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) | [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) |
| [Vscale](https://go-acme.github.io/lego/dns/vscale/) | [Vultr](https://go-acme.github.io/lego/dns/vultr/) | [WEDOS](https://go-acme.github.io/lego/dns/wedos/) | [Yandex](https://go-acme.github.io/lego/dns/yandex/) |
| [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | | |
| [Internet Initiative Japan](https://go-acme.github.io/lego/dns/iij/) | [Internet.bs](https://go-acme.github.io/lego/dns/internetbs/) | [INWX](https://go-acme.github.io/lego/dns/inwx/) | [Ionos](https://go-acme.github.io/lego/dns/ionos/) |
| [Joker](https://go-acme.github.io/lego/dns/joker/) | [Joohoi's ACME-DNS](https://go-acme.github.io/lego/dns/acme-dns/) | [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) |
| [Loopia](https://go-acme.github.io/lego/dns/loopia/) | [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | [Manual](https://go-acme.github.io/lego/dns/manual/) | [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) |
| [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) | [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) |
| [Netcup](https://go-acme.github.io/lego/dns/netcup/) | [Netlify](https://go-acme.github.io/lego/dns/netlify/) | [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) |
| [NS1](https://go-acme.github.io/lego/dns/ns1/) | [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | [OVH](https://go-acme.github.io/lego/dns/ovh/) |
| [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) | [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | [reg.ru](https://go-acme.github.io/lego/dns/regru/) |
| [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) | [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) |
| [Selectel](https://go-acme.github.io/lego/dns/selectel/) | [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | [Sonic](https://go-acme.github.io/lego/dns/sonic/) |
| [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) | [TransIP](https://go-acme.github.io/lego/dns/transip/) | [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) |
| [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) | [Vscale](https://go-acme.github.io/lego/dns/vscale/) | [Vultr](https://go-acme.github.io/lego/dns/vultr/) | [WEDOS](https://go-acme.github.io/lego/dns/wedos/) |
| [Yandex](https://go-acme.github.io/lego/dns/yandex/) | [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | |

<!-- END DNS PROVIDERS LIST -->

Expand Down
22 changes: 22 additions & 0 deletions cmd/zz_gen_cmd_dnshelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func allDNSCodes() string {
"iij",
"infoblox",
"infomaniak",
"internetbs",
"inwx",
"ionos",
"joker",
Expand Down Expand Up @@ -1041,6 +1042,27 @@ func displayDNSHelp(name string) error {
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/infomaniak`)

case "internetbs":
// generated from: providers/dns/internetbs/internetbs.toml
ew.writeln(`Configuration for Internet.bs.`)
ew.writeln(`Code: 'internetbs'`)
ew.writeln(`Since: 'v4.5.0'`)
ew.writeln()

ew.writeln(`Credentials:`)
ew.writeln(` - "INTERNET_BS_API_KEY": API key`)
ew.writeln(` - "INTERNET_BS_PASSWORD": API password`)
ew.writeln()

ew.writeln(`Additional Configuration:`)
ew.writeln(` - "INTERNET_BS_HTTP_TIMEOUT": API request timeout`)
ew.writeln(` - "INTERNET_BS_POLLING_INTERVAL": Time between DNS propagation check`)
ew.writeln(` - "INTERNET_BS_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
ew.writeln(` - "INTERNET_BS_TTL": The TTL of the TXT record used for the DNS challenge`)

ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/internetbs`)

case "inwx":
// generated from: providers/dns/inwx/inwx.toml
ew.writeln(`Configuration for INWX.`)
Expand Down
64 changes: 64 additions & 0 deletions docs/content/dns/zz_gen_internetbs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: "Internet.bs"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: internetbs
---

<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/internetbs/internetbs.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->

Since: v4.5.0

Configuration for [Internet.bs](https://internetbs.net).


<!--more-->

- Code: `internetbs`

Here is an example bash command using the Internet.bs provider:

```bash
INTERNET_BS_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxx \
INTERNET_BS_PASSWORD=yyyyyyyyyyyyyyyyyyyyyyyyyy \
lego --email myemail@example.com --dns internetbs --domains my.example.org run
```




## Credentials

| Environment Variable Name | Description |
|-----------------------|-------------|
| `INTERNET_BS_API_KEY` | API key |
| `INTERNET_BS_PASSWORD` | API password |

The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
More information [here](/lego/dns/#configuration-and-credentials).


## Additional Configuration

| Environment Variable Name | Description |
|--------------------------------|-------------|
| `INTERNET_BS_HTTP_TIMEOUT` | API request timeout |
| `INTERNET_BS_POLLING_INTERVAL` | Time between DNS propagation check |
| `INTERNET_BS_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
| `INTERNET_BS_TTL` | The TTL of the TXT record used for the DNS challenge |

The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
More information [here](/lego/dns/#configuration-and-credentials).




## More information

- [API documentation](https://internetbs.net/internet-bs-api.pdf)

<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/internetbs/internetbs.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
3 changes: 3 additions & 0 deletions providers/dns/dns_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/iij"
"github.com/go-acme/lego/v4/providers/dns/infoblox"
"github.com/go-acme/lego/v4/providers/dns/infomaniak"
"github.com/go-acme/lego/v4/providers/dns/internetbs"
"github.com/go-acme/lego/v4/providers/dns/inwx"
"github.com/go-acme/lego/v4/providers/dns/ionos"
"github.com/go-acme/lego/v4/providers/dns/joker"
Expand Down Expand Up @@ -187,6 +188,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return infoblox.NewDNSProvider()
case "infomaniak":
return infomaniak.NewDNSProvider()
case "internetbs":
return internetbs.NewDNSProvider()
case "inwx":
return inwx.NewDNSProvider()
case "ionos":
Expand Down
140 changes: 140 additions & 0 deletions providers/dns/internetbs/internal/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package internal

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"path"
"path/filepath"
"strings"
"time"
"unicode"

querystring "github.com/google/go-querystring/query"
)

const baseURL = "https://api.internet.bs"

// status SUCCESS, PENDING, FAILURE.
const statusSuccess = "SUCCESS"

// Client is the API client.
type Client struct {
HTTPClient *http.Client
baseURL *url.URL
debug bool

apiKey string
password string
}

// NewClient creates a new Client.
func NewClient(apiKey string, password string) *Client {
baseURL, _ := url.Parse(baseURL)

return &Client{
HTTPClient: &http.Client{Timeout: 10 * time.Second},
baseURL: baseURL,
apiKey: apiKey,
password: password,
}
}

// AddRecord The command is intended to add a new DNS record to a specific zone (domain).
func (c Client) AddRecord(query RecordQuery) error {
var r APIResponse
err := c.do("Add", query, &r)
if err != nil {
return err
}

if r.Status != statusSuccess {
return r
}

return nil
}

// RemoveRecord The command is intended to remove a DNS record from a specific zone.
func (c Client) RemoveRecord(query RecordQuery) error {
var r APIResponse
err := c.do("Remove", query, &r)
if err != nil {
return err
}

if r.Status != statusSuccess {
return r
}

return nil
}

// ListRecords The command is intended to retrieve the list of DNS records for a specific domain.
func (c Client) ListRecords(query ListRecordQuery) ([]Record, error) {
var l ListResponse
err := c.do("List", query, &l)
if err != nil {
return nil, err
}

if l.Status != statusSuccess {
return nil, l.APIResponse
}

return l.Records, nil
}

func (c Client) do(action string, params interface{}, response interface{}) error {
endpoint, err := c.baseURL.Parse(path.Join(c.baseURL.Path, "Domain", "DnsRecord", action))
if err != nil {
return fmt.Errorf("create endpoint: %w", err)
}

values, err := querystring.Values(params)
if err != nil {
return fmt.Errorf("parse query parameters: %w", err)
}

values.Set("apiKey", c.apiKey)
values.Set("password", c.password)
values.Set("ResponseFormat", "JSON")

resp, err := c.HTTPClient.PostForm(endpoint.String(), values)
if err != nil {
return fmt.Errorf("post request: %w", err)
}

defer func() { _ = resp.Body.Close() }()

if resp.StatusCode/100 != 2 {
data, _ := ioutil.ReadAll(resp.Body)
return fmt.Errorf("status code: %d, %s", resp.StatusCode, string(data))
}

if c.debug {
return dump(endpoint, resp, response)
}

return json.NewDecoder(resp.Body).Decode(response)
}

func dump(endpoint *url.URL, resp *http.Response, response interface{}) error {
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}

fields := strings.FieldsFunc(endpoint.Path, func(r rune) bool {
return !unicode.IsLetter(r) && !unicode.IsNumber(r)
})

err = ioutil.WriteFile(filepath.Join("fixtures", strings.Join(fields, "_")+".json"), data, 0o666)
if err != nil {
return err
}

return json.Unmarshal(data, response)
}
Loading