Updates of Lego.
This commit is contained in:
parent
5f4d440493
commit
2b2cfdfb32
102 changed files with 8355 additions and 902 deletions
373
vendor/github.com/nrdcg/auroradns/LICENSE
generated
vendored
Normal file
373
vendor/github.com/nrdcg/auroradns/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,373 @@
|
|||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
98
vendor/github.com/nrdcg/auroradns/auth.go
generated
vendored
Normal file
98
vendor/github.com/nrdcg/auroradns/auth.go
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
package auroradns
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TokenTransport HTTP transport for API authentication
|
||||
type TokenTransport struct {
|
||||
userID string
|
||||
key string
|
||||
|
||||
// Transport is the underlying HTTP transport to use when making requests.
|
||||
// It will default to http.DefaultTransport if nil.
|
||||
Transport http.RoundTripper
|
||||
}
|
||||
|
||||
// NewTokenTransport Creates a new TokenTransport
|
||||
func NewTokenTransport(userID, key string) (*TokenTransport, error) {
|
||||
if userID == "" || key == "" {
|
||||
return nil, fmt.Errorf("credentials missing")
|
||||
}
|
||||
|
||||
return &TokenTransport{userID: userID, key: key}, nil
|
||||
}
|
||||
|
||||
// RoundTrip executes a single HTTP transaction
|
||||
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
enrichedReq := &http.Request{}
|
||||
*enrichedReq = *req
|
||||
|
||||
enrichedReq.Header = make(http.Header, len(req.Header))
|
||||
for k, s := range req.Header {
|
||||
enrichedReq.Header[k] = append([]string(nil), s...)
|
||||
}
|
||||
|
||||
if t.userID != "" && t.key != "" {
|
||||
timestamp := time.Now().UTC()
|
||||
|
||||
fmtTime := timestamp.Format("20060102T150405Z")
|
||||
req.Header.Set("X-AuroraDNS-Date", fmtTime)
|
||||
|
||||
token, err := newToken(t.userID, t.key, req.Method, req.URL.Path, timestamp)
|
||||
if err == nil {
|
||||
req.Header.Set("Authorization", fmt.Sprintf("AuroraDNSv1 %s", token))
|
||||
}
|
||||
}
|
||||
|
||||
return t.transport().RoundTrip(enrichedReq)
|
||||
}
|
||||
|
||||
// Wrap Wrap a HTTP client Transport with the TokenTransport
|
||||
func (t *TokenTransport) Wrap(client *http.Client) *http.Client {
|
||||
backup := client.Transport
|
||||
t.Transport = backup
|
||||
client.Transport = t
|
||||
return client
|
||||
}
|
||||
|
||||
// Client Creates a new HTTP client
|
||||
func (t *TokenTransport) Client() *http.Client {
|
||||
return &http.Client{
|
||||
Transport: t,
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TokenTransport) transport() http.RoundTripper {
|
||||
if t.Transport != nil {
|
||||
return t.Transport
|
||||
}
|
||||
return http.DefaultTransport
|
||||
}
|
||||
|
||||
// newToken generates a token for accessing a specific method of the API
|
||||
func newToken(userID string, key string, method string, action string, timestamp time.Time) (string, error) {
|
||||
fmtTime := timestamp.Format("20060102T150405Z")
|
||||
message := strings.Join([]string{method, action, fmtTime}, "")
|
||||
|
||||
signatureHmac := hmac.New(sha256.New, []byte(key))
|
||||
_, err := signatureHmac.Write([]byte(message))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
signature := base64.StdEncoding.EncodeToString(signatureHmac.Sum(nil))
|
||||
|
||||
userIDAndSignature := fmt.Sprintf("%s:%s", userID, signature)
|
||||
|
||||
token := base64.StdEncoding.EncodeToString([]byte(userIDAndSignature))
|
||||
|
||||
return token, nil
|
||||
}
|
144
vendor/github.com/nrdcg/auroradns/client.go
generated
vendored
Normal file
144
vendor/github.com/nrdcg/auroradns/client.go
generated
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
package auroradns
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const defaultBaseURL = "https://api.auroradns.eu"
|
||||
|
||||
const (
|
||||
contentTypeHeader = "Content-Type"
|
||||
contentTypeJSON = "application/json"
|
||||
)
|
||||
|
||||
// ErrorResponse A representation of an API error message.
|
||||
type ErrorResponse struct {
|
||||
ErrorCode string `json:"error"`
|
||||
Message string `json:"errormsg"`
|
||||
}
|
||||
|
||||
func (e *ErrorResponse) Error() string {
|
||||
return fmt.Sprintf("%s - %s", e.ErrorCode, e.Message)
|
||||
}
|
||||
|
||||
// Option Type of a client option
|
||||
type Option func(*Client) error
|
||||
|
||||
// Client The API client
|
||||
type Client struct {
|
||||
baseURL *url.URL
|
||||
UserAgent string
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// NewClient Creates a new client
|
||||
func NewClient(httpClient *http.Client, opts ...Option) (*Client, error) {
|
||||
if httpClient == nil {
|
||||
httpClient = http.DefaultClient
|
||||
}
|
||||
|
||||
baseURL, _ := url.Parse(defaultBaseURL)
|
||||
|
||||
client := &Client{
|
||||
baseURL: baseURL,
|
||||
httpClient: httpClient,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
err := opt(client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *Client) newRequest(method, resource string, body io.Reader) (*http.Request, error) {
|
||||
u, err := c.baseURL.Parse(resource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, u.String(), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set(contentTypeHeader, contentTypeJSON)
|
||||
|
||||
if c.UserAgent != "" {
|
||||
req.Header.Set("User-Agent", c.UserAgent)
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (c *Client) do(req *http.Request, v interface{}) (*http.Response, error) {
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if err = checkResponse(resp); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
raw, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return resp, fmt.Errorf("failed to read body: %v", err)
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(raw, v); err != nil {
|
||||
return resp, fmt.Errorf("unmarshaling %T error: %v: %s", err, v, string(raw))
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func checkResponse(resp *http.Response) error {
|
||||
if c := resp.StatusCode; 200 <= c && c <= 299 {
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err == nil && data != nil {
|
||||
errorResponse := new(ErrorResponse)
|
||||
err = json.Unmarshal(data, errorResponse)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshaling ErrorResponse error: %v: %s", err.Error(), string(data))
|
||||
}
|
||||
|
||||
return errorResponse
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithBaseURL Allows to define a custom base URL
|
||||
func WithBaseURL(rawBaseURL string) func(*Client) error {
|
||||
return func(client *Client) error {
|
||||
if len(rawBaseURL) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
baseURL, err := url.Parse(rawBaseURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client.baseURL = baseURL
|
||||
return nil
|
||||
}
|
||||
}
|
91
vendor/github.com/nrdcg/auroradns/records.go
generated
vendored
Normal file
91
vendor/github.com/nrdcg/auroradns/records.go
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
package auroradns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Record types
|
||||
const (
|
||||
RecordTypeA = "A"
|
||||
RecordTypeAAAA = "AAAA"
|
||||
RecordTypeCNAME = "CNAME"
|
||||
RecordTypeMX = "MX"
|
||||
RecordTypeNS = "NS"
|
||||
RecordTypeSOA = "SOA"
|
||||
RecordTypeSRV = "SRV"
|
||||
RecordTypeTXT = "TXT"
|
||||
RecordTypeDS = "DS"
|
||||
RecordTypePTR = "PTR"
|
||||
RecordTypeSSHFP = "SSHFP"
|
||||
RecordTypeTLSA = "TLS"
|
||||
)
|
||||
|
||||
// Record a DNS record
|
||||
type Record struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
RecordType string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Content string `json:"content"`
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRecord Creates a new record.
|
||||
func (c *Client) CreateRecord(zoneID string, record Record) (*Record, *http.Response, error) {
|
||||
body, err := json.Marshal(record)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to marshall request body: %v", err)
|
||||
}
|
||||
|
||||
resource := fmt.Sprintf("/zones/%s/records", zoneID)
|
||||
|
||||
req, err := c.newRequest(http.MethodPost, resource, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
newRecord := new(Record)
|
||||
resp, err := c.do(req, newRecord)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return newRecord, resp, nil
|
||||
}
|
||||
|
||||
// DeleteRecord Delete a record.
|
||||
func (c *Client) DeleteRecord(zoneID string, recordID string) (bool, *http.Response, error) {
|
||||
resource := fmt.Sprintf("/zones/%s/records/%s", zoneID, recordID)
|
||||
|
||||
req, err := c.newRequest(http.MethodDelete, resource, nil)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
resp, err := c.do(req, nil)
|
||||
if err != nil {
|
||||
return false, resp, err
|
||||
}
|
||||
|
||||
return true, resp, nil
|
||||
}
|
||||
|
||||
// ListRecords returns a list of all records in given zone
|
||||
func (c *Client) ListRecords(zoneID string) ([]Record, *http.Response, error) {
|
||||
resource := fmt.Sprintf("/zones/%s/records", zoneID)
|
||||
|
||||
req, err := c.newRequest(http.MethodGet, resource, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var records []Record
|
||||
resp, err := c.do(req, &records)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return records, resp, nil
|
||||
}
|
69
vendor/github.com/nrdcg/auroradns/zones.go
generated
vendored
Normal file
69
vendor/github.com/nrdcg/auroradns/zones.go
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
package auroradns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Zone a DNS zone
|
||||
type Zone struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// CreateZone Creates a zone.
|
||||
func (c *Client) CreateZone(domain string) (*Zone, *http.Response, error) {
|
||||
body, err := json.Marshal(Zone{Name: domain})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to marshall request body: %v", err)
|
||||
}
|
||||
|
||||
req, err := c.newRequest(http.MethodPost, "/zones", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
zone := new(Zone)
|
||||
resp, err := c.do(req, zone)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return zone, resp, nil
|
||||
}
|
||||
|
||||
// DeleteZone Delete a zone.
|
||||
func (c *Client) DeleteZone(zoneID string) (bool, *http.Response, error) {
|
||||
resource := fmt.Sprintf("/zones/%s", zoneID)
|
||||
|
||||
req, err := c.newRequest(http.MethodDelete, resource, nil)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
resp, err := c.do(req, nil)
|
||||
if err != nil {
|
||||
return false, resp, err
|
||||
}
|
||||
|
||||
return true, resp, nil
|
||||
|
||||
}
|
||||
|
||||
// ListZones returns a list of all zones.
|
||||
func (c *Client) ListZones() ([]Zone, *http.Response, error) {
|
||||
req, err := c.newRequest(http.MethodGet, "/zones", nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var zones []Zone
|
||||
resp, err := c.do(req, &zones)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return zones, resp, nil
|
||||
}
|
21
vendor/github.com/nrdcg/goinwx/LICENSE
generated
vendored
Normal file
21
vendor/github.com/nrdcg/goinwx/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Andrew
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
48
vendor/github.com/nrdcg/goinwx/account.go
generated
vendored
Normal file
48
vendor/github.com/nrdcg/goinwx/account.go
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
package goinwx
|
||||
|
||||
const (
|
||||
methodAccountLogin = "account.login"
|
||||
methodAccountLogout = "account.logout"
|
||||
methodAccountLock = "account.lock"
|
||||
methodAccountUnlock = "account.unlock"
|
||||
)
|
||||
|
||||
// AccountService API access to Account.
|
||||
type AccountService service
|
||||
|
||||
// Login Account login.
|
||||
func (s *AccountService) Login() error {
|
||||
req := s.client.NewRequest(methodAccountLogin, map[string]interface{}{
|
||||
"user": s.client.username,
|
||||
"pass": s.client.password,
|
||||
})
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Logout Account logout.
|
||||
func (s *AccountService) Logout() error {
|
||||
req := s.client.NewRequest(methodAccountLogout, nil)
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Lock Account lock.
|
||||
func (s *AccountService) Lock() error {
|
||||
req := s.client.NewRequest(methodAccountLock, nil)
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Unlock Account unlock.
|
||||
func (s *AccountService) Unlock(tan string) error {
|
||||
req := s.client.NewRequest(methodAccountUnlock, map[string]interface{}{
|
||||
"tan": tan,
|
||||
})
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
148
vendor/github.com/nrdcg/goinwx/contact.go
generated
vendored
Normal file
148
vendor/github.com/nrdcg/goinwx/contact.go
generated
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
package goinwx
|
||||
|
||||
import (
|
||||
"github.com/fatih/structs"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
const (
|
||||
methodContactInfo = "contact.info"
|
||||
methodContactList = "contact.list"
|
||||
methodContactCreate = "contact.create"
|
||||
methodContactDelete = "contact.delete"
|
||||
methodContactUpdate = "contact.update"
|
||||
)
|
||||
|
||||
// ContactService API access to Contact.
|
||||
type ContactService service
|
||||
|
||||
// Create Creates a contact.
|
||||
func (s *ContactService) Create(request *ContactCreateRequest) (int, error) {
|
||||
req := s.client.NewRequest(methodContactCreate, structs.Map(request))
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var result map[string]int
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result["id"], nil
|
||||
}
|
||||
|
||||
// Delete Deletes a contact.
|
||||
func (s *ContactService) Delete(roID int) error {
|
||||
req := s.client.NewRequest(methodContactDelete, map[string]interface{}{
|
||||
"id": roID,
|
||||
})
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Update Updates a contact.
|
||||
func (s *ContactService) Update(request *ContactUpdateRequest) error {
|
||||
req := s.client.NewRequest(methodContactUpdate, structs.Map(request))
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Info Get information about a contact.
|
||||
func (s *ContactService) Info(contactID int) (*ContactInfoResponse, error) {
|
||||
var requestMap = make(map[string]interface{})
|
||||
requestMap["wide"] = 1
|
||||
|
||||
if contactID != 0 {
|
||||
requestMap["id"] = contactID
|
||||
}
|
||||
|
||||
req := s.client.NewRequest(methodContactInfo, requestMap)
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result ContactInfoResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// List Search contacts.
|
||||
func (s *ContactService) List(search string) (*ContactListResponse, error) {
|
||||
var requestMap = make(map[string]interface{})
|
||||
|
||||
if search != "" {
|
||||
requestMap["search"] = search
|
||||
}
|
||||
req := s.client.NewRequest(methodContactList, requestMap)
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result ContactListResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// ContactCreateRequest API model.
|
||||
type ContactCreateRequest struct {
|
||||
Type string `structs:"type"`
|
||||
Name string `structs:"name"`
|
||||
Org string `structs:"org,omitempty"`
|
||||
Street string `structs:"street"`
|
||||
City string `structs:"city"`
|
||||
PostalCode string `structs:"pc"`
|
||||
StateProvince string `structs:"sp,omitempty"`
|
||||
CountryCode string `structs:"cc"`
|
||||
Voice string `structs:"voice"`
|
||||
Fax string `structs:"fax,omitempty"`
|
||||
Email string `structs:"email"`
|
||||
Remarks string `structs:"remarks,omitempty"`
|
||||
Protection bool `structs:"protection,omitempty"`
|
||||
Testing bool `structs:"testing,omitempty"`
|
||||
}
|
||||
|
||||
// ContactUpdateRequest API model.
|
||||
type ContactUpdateRequest struct {
|
||||
ID int `structs:"id"`
|
||||
Name string `structs:"name,omitempty"`
|
||||
Org string `structs:"org,omitempty"`
|
||||
Street string `structs:"street,omitempty"`
|
||||
City string `structs:"city,omitempty"`
|
||||
PostalCode string `structs:"pc,omitempty"`
|
||||
StateProvince string `structs:"sp,omitempty"`
|
||||
CountryCode string `structs:"cc,omitempty"`
|
||||
Voice string `structs:"voice,omitempty"`
|
||||
Fax string `structs:"fax,omitempty"`
|
||||
Email string `structs:"email,omitempty"`
|
||||
Remarks string `structs:"remarks,omitempty"`
|
||||
Protection bool `structs:"protection,omitempty"`
|
||||
Testing bool `structs:"testing,omitempty"`
|
||||
}
|
||||
|
||||
// ContactInfoResponse API model.
|
||||
type ContactInfoResponse struct {
|
||||
Contact Contact `mapstructure:"contact"`
|
||||
}
|
||||
|
||||
// ContactListResponse API model.
|
||||
type ContactListResponse struct {
|
||||
Count int
|
||||
Contacts []Contact `mapstructure:"contact"`
|
||||
}
|
307
vendor/github.com/nrdcg/goinwx/domain.go
generated
vendored
Normal file
307
vendor/github.com/nrdcg/goinwx/domain.go
generated
vendored
Normal file
|
@ -0,0 +1,307 @@
|
|||
package goinwx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
const (
|
||||
methodDomainCheck = "domain.check"
|
||||
methodDomainCreate = "domain.create"
|
||||
methodDomainDelete = "domain.delete"
|
||||
methodDomainGetPrices = "domain.getPrices"
|
||||
methodDomainGetRules = "domain.getRules"
|
||||
methodDomainInfo = "domain.info"
|
||||
methodDomainList = "domain.list"
|
||||
methodDomainLog = "domain.log"
|
||||
methodDomainPush = "domain.push"
|
||||
methodDomainRenew = "domain.renew"
|
||||
methodDomainRestore = "domain.restore"
|
||||
methodDomainStats = "domain.stats"
|
||||
methodDomainTrade = "domain.trade"
|
||||
methodDomainTransfer = "domain.transfer"
|
||||
methodDomainTransferOut = "domain.transferOut"
|
||||
methodDomainUpdate = "domain.update"
|
||||
methodDomainWhois = "domain.whois"
|
||||
)
|
||||
|
||||
// DomainService API access to Domain.
|
||||
type DomainService service
|
||||
|
||||
// Check Checks domains.
|
||||
func (s *DomainService) Check(domains []string) ([]DomainCheckResponse, error) {
|
||||
req := s.client.NewRequest(methodDomainCheck, map[string]interface{}{
|
||||
"domain": domains,
|
||||
"wide": "2",
|
||||
})
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
root := new(domainCheckResponseRoot)
|
||||
err = mapstructure.Decode(*resp, &root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return root.Domains, nil
|
||||
}
|
||||
|
||||
// GetPrices Gets TLDS prices.
|
||||
func (s *DomainService) GetPrices(tlds []string) ([]DomainPriceResponse, error) {
|
||||
req := s.client.NewRequest(methodDomainGetPrices, map[string]interface{}{
|
||||
"tld": tlds,
|
||||
"vat": false,
|
||||
})
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
root := new(domainPriceResponseRoot)
|
||||
err = mapstructure.Decode(*resp, &root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return root.Prices, nil
|
||||
}
|
||||
|
||||
// Register Register a domain.
|
||||
func (s *DomainService) Register(request *DomainRegisterRequest) (*DomainRegisterResponse, error) {
|
||||
req := s.client.NewRequest(methodDomainCreate, structs.Map(request))
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result DomainRegisterResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Delete Deletes a domain.
|
||||
func (s *DomainService) Delete(domain string, scheduledDate time.Time) error {
|
||||
req := s.client.NewRequest(methodDomainDelete, map[string]interface{}{
|
||||
"domain": domain,
|
||||
"scDate": scheduledDate.Format(time.RFC3339),
|
||||
})
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
return err
|
||||
}
|
||||
|
||||
// Info Gets information about a domain.
|
||||
func (s *DomainService) Info(domain string, roID int) (*DomainInfoResponse, error) {
|
||||
req := s.client.NewRequest(methodDomainInfo, map[string]interface{}{
|
||||
"domain": domain,
|
||||
"wide": "2",
|
||||
})
|
||||
if roID != 0 {
|
||||
req.Args["roId"] = roID
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result DomainInfoResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("Response", result)
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// List List domains.
|
||||
func (s *DomainService) List(request *DomainListRequest) (*DomainList, error) {
|
||||
if request == nil {
|
||||
return nil, errors.New("request can't be nil")
|
||||
}
|
||||
requestMap := structs.Map(request)
|
||||
requestMap["wide"] = "2"
|
||||
|
||||
req := s.client.NewRequest(methodDomainList, requestMap)
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result DomainList
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Whois Whois about a domains.
|
||||
func (s *DomainService) Whois(domain string) (string, error) {
|
||||
req := s.client.NewRequest(methodDomainWhois, map[string]interface{}{
|
||||
"domain": domain,
|
||||
})
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result map[string]string
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result["whois"], nil
|
||||
}
|
||||
|
||||
type domainCheckResponseRoot struct {
|
||||
Domains []DomainCheckResponse `mapstructure:"domain"`
|
||||
}
|
||||
|
||||
// DomainCheckResponse API model.
|
||||
type DomainCheckResponse struct {
|
||||
Available int `mapstructure:"avail"`
|
||||
Status string `mapstructure:"status"`
|
||||
Name string `mapstructure:"name"`
|
||||
Domain string `mapstructure:"domain"`
|
||||
TLD string `mapstructure:"tld"`
|
||||
CheckMethod string `mapstructure:"checkmethod"`
|
||||
Price float32 `mapstructure:"price"`
|
||||
CheckTime float32 `mapstructure:"checktime"`
|
||||
}
|
||||
|
||||
type domainPriceResponseRoot struct {
|
||||
Prices []DomainPriceResponse `mapstructure:"price"`
|
||||
}
|
||||
|
||||
// DomainPriceResponse API model.
|
||||
type DomainPriceResponse struct {
|
||||
Tld string `mapstructure:"tld"`
|
||||
Currency string `mapstructure:"currency"`
|
||||
CreatePrice float32 `mapstructure:"createPrice"`
|
||||
MonthlyCreatePrice float32 `mapstructure:"monthlyCreatePrice"`
|
||||
TransferPrice float32 `mapstructure:"transferPrice"`
|
||||
RenewalPrice float32 `mapstructure:"renewalPrice"`
|
||||
MonthlyRenewalPrice float32 `mapstructure:"monthlyRenewalPrice"`
|
||||
UpdatePrice float32 `mapstructure:"updatePrice"`
|
||||
TradePrice float32 `mapstructure:"tradePrice"`
|
||||
TrusteePrice float32 `mapstructure:"trusteePrice"`
|
||||
MonthlyTrusteePrice float32 `mapstructure:"monthlyTrusteePrice"`
|
||||
CreatePeriod int `mapstructure:"createPeriod"`
|
||||
TransferPeriod int `mapstructure:"transferPeriod"`
|
||||
RenewalPeriod int `mapstructure:"renewalPeriod"`
|
||||
TradePeriod int `mapstructure:"tradePeriod"`
|
||||
}
|
||||
|
||||
// DomainRegisterRequest API model.
|
||||
type DomainRegisterRequest struct {
|
||||
Domain string `structs:"domain"`
|
||||
Period string `structs:"period,omitempty"`
|
||||
Registrant int `structs:"registrant"`
|
||||
Admin int `structs:"admin"`
|
||||
Tech int `structs:"tech"`
|
||||
Billing int `structs:"billing"`
|
||||
Nameservers []string `structs:"ns,omitempty"`
|
||||
TransferLock string `structs:"transferLock,omitempty"`
|
||||
RenewalMode string `structs:"renewalMode,omitempty"`
|
||||
WhoisProvider string `structs:"whoisProvider,omitempty"`
|
||||
WhoisURL string `structs:"whoisUrl,omitempty"`
|
||||
ScDate string `structs:"scDate,omitempty"`
|
||||
ExtDate string `structs:"extDate,omitempty"`
|
||||
Asynchron string `structs:"asynchron,omitempty"`
|
||||
Voucher string `structs:"voucher,omitempty"`
|
||||
Testing string `structs:"testing,omitempty"`
|
||||
}
|
||||
|
||||
// DomainRegisterResponse API model.
|
||||
type DomainRegisterResponse struct {
|
||||
RoID int `mapstructure:"roId"`
|
||||
Price float32 `mapstructure:"price"`
|
||||
Currency string `mapstructure:"currency"`
|
||||
}
|
||||
|
||||
// DomainInfoResponse API model.
|
||||
type DomainInfoResponse struct {
|
||||
RoID int `mapstructure:"roId"`
|
||||
Domain string `mapstructure:"domain"`
|
||||
DomainAce string `mapstructure:"domainAce"`
|
||||
Period string `mapstructure:"period"`
|
||||
CrDate time.Time `mapstructure:"crDate"`
|
||||
ExDate time.Time `mapstructure:"exDate"`
|
||||
UpDate time.Time `mapstructure:"upDate"`
|
||||
ReDate time.Time `mapstructure:"reDate"`
|
||||
ScDate time.Time `mapstructure:"scDate"`
|
||||
TransferLock int `mapstructure:"transferLock"`
|
||||
Status string `mapstructure:"status"`
|
||||
AuthCode string `mapstructure:"authCode"`
|
||||
RenewalMode string `mapstructure:"renewalMode"`
|
||||
TransferMode string `mapstructure:"transferMode"`
|
||||
Registrant int `mapstructure:"registrant"`
|
||||
Admin int `mapstructure:"admin"`
|
||||
Tech int `mapstructure:"tech"`
|
||||
Billing int `mapstructure:"billing"`
|
||||
Nameservers []string `mapstructure:"ns"`
|
||||
NoDelegation string `mapstructure:"noDelegation"`
|
||||
Contacts map[string]Contact `mapstructure:"contact"`
|
||||
}
|
||||
|
||||
// Contact API model.
|
||||
type Contact struct {
|
||||
RoID int `mapstructure:"roId"`
|
||||
ID string `mapstructure:"id"`
|
||||
Type string `mapstructure:"type"`
|
||||
Name string `mapstructure:"name"`
|
||||
Org string `mapstructure:"org"`
|
||||
Street string `mapstructure:"street"`
|
||||
City string `mapstructure:"city"`
|
||||
PostalCode string `mapstructure:"pc"`
|
||||
StateProvince string `mapstructure:"sp"`
|
||||
Country string `mapstructure:"cc"`
|
||||
Phone string `mapstructure:"voice"`
|
||||
Fax string `mapstructure:"fax"`
|
||||
Email string `mapstructure:"email"`
|
||||
Remarks string `mapstructure:"remarks"`
|
||||
Protection string `mapstructure:"protection"`
|
||||
}
|
||||
|
||||
// DomainListRequest API model.
|
||||
type DomainListRequest struct {
|
||||
Domain string `structs:"domain,omitempty"`
|
||||
RoID int `structs:"roId,omitempty"`
|
||||
Status int `structs:"status,omitempty"`
|
||||
Registrant int `structs:"registrant,omitempty"`
|
||||
Admin int `structs:"admin,omitempty"`
|
||||
Tech int `structs:"tech,omitempty"`
|
||||
Billing int `structs:"billing,omitempty"`
|
||||
RenewalMode int `structs:"renewalMode,omitempty"`
|
||||
TransferLock int `structs:"transferLock,omitempty"`
|
||||
NoDelegation int `structs:"noDelegation,omitempty"`
|
||||
Tag int `structs:"tag,omitempty"`
|
||||
Order int `structs:"order,omitempty"`
|
||||
Page int `structs:"page,omitempty"`
|
||||
PageLimit int `structs:"pagelimit,omitempty"`
|
||||
}
|
||||
|
||||
// DomainList API model.
|
||||
type DomainList struct {
|
||||
Count int
|
||||
Domains []DomainInfoResponse `mapstructure:"domain"`
|
||||
}
|
112
vendor/github.com/nrdcg/goinwx/goinwx.go
generated
vendored
Normal file
112
vendor/github.com/nrdcg/goinwx/goinwx.go
generated
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
package goinwx
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/kolo/xmlrpc"
|
||||
)
|
||||
|
||||
// API information.
|
||||
const (
|
||||
APIBaseURL = "https://api.domrobot.com/xmlrpc/"
|
||||
APISandboxBaseURL = "https://api.ote.domrobot.com/xmlrpc/"
|
||||
APILanguage = "eng"
|
||||
)
|
||||
|
||||
// Client manages communication with INWX API.
|
||||
type Client struct {
|
||||
// HTTP client used to communicate with the INWX API.
|
||||
RPCClient *xmlrpc.Client
|
||||
|
||||
// Base URL for API requests.
|
||||
BaseURL *url.URL
|
||||
|
||||
// API username and password
|
||||
username string
|
||||
password string
|
||||
|
||||
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
||||
|
||||
// Services used for communicating with the API
|
||||
Account *AccountService
|
||||
Domains *DomainService
|
||||
Nameservers *NameserverService
|
||||
Contacts *ContactService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *Client
|
||||
}
|
||||
|
||||
// ClientOptions Options of the API client.
|
||||
type ClientOptions struct {
|
||||
Sandbox bool
|
||||
}
|
||||
|
||||
// Request The representation of an API request.
|
||||
type Request struct {
|
||||
ServiceMethod string
|
||||
Args map[string]interface{}
|
||||
}
|
||||
|
||||
// NewClient returns a new INWX API client.
|
||||
func NewClient(username, password string, opts *ClientOptions) *Client {
|
||||
var useSandbox bool
|
||||
if opts != nil {
|
||||
useSandbox = opts.Sandbox
|
||||
}
|
||||
|
||||
var baseURL *url.URL
|
||||
|
||||
if useSandbox {
|
||||
baseURL, _ = url.Parse(APISandboxBaseURL)
|
||||
} else {
|
||||
baseURL, _ = url.Parse(APIBaseURL)
|
||||
}
|
||||
|
||||
rpcClient, _ := xmlrpc.NewClient(baseURL.String(), nil)
|
||||
|
||||
client := &Client{
|
||||
RPCClient: rpcClient,
|
||||
BaseURL: baseURL,
|
||||
username: username,
|
||||
password: password,
|
||||
}
|
||||
|
||||
client.common.client = client
|
||||
client.Account = (*AccountService)(&client.common)
|
||||
client.Domains = (*DomainService)(&client.common)
|
||||
client.Nameservers = (*NameserverService)(&client.common)
|
||||
client.Contacts = (*ContactService)(&client.common)
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
// NewRequest creates an API request.
|
||||
func (c *Client) NewRequest(serviceMethod string, args map[string]interface{}) *Request {
|
||||
if args != nil {
|
||||
args["lang"] = APILanguage
|
||||
}
|
||||
|
||||
return &Request{ServiceMethod: serviceMethod, Args: args}
|
||||
}
|
||||
|
||||
// Do sends an API request and returns the API response.
|
||||
func (c *Client) Do(req Request) (*map[string]interface{}, error) {
|
||||
var resp Response
|
||||
err := c.RPCClient.Call(req.ServiceMethod, req.Args, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &resp.ResponseData, checkResponse(&resp)
|
||||
}
|
||||
|
||||
// checkResponse checks the API response for errors, and returns them if present.
|
||||
func checkResponse(r *Response) error {
|
||||
if c := r.Code; c >= 1000 && c <= 1500 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &ErrorResponse{Code: r.Code, Message: r.Message, Reason: r.Reason, ReasonCode: r.ReasonCode}
|
||||
}
|
283
vendor/github.com/nrdcg/goinwx/nameserver.go
generated
vendored
Normal file
283
vendor/github.com/nrdcg/goinwx/nameserver.go
generated
vendored
Normal file
|
@ -0,0 +1,283 @@
|
|||
package goinwx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
const (
|
||||
methodNameserverCheck = "nameserver.check"
|
||||
methodNameserverCreate = "nameserver.create"
|
||||
methodNameserverCreateRecord = "nameserver.createRecord"
|
||||
methodNameserverDelete = "nameserver.delete"
|
||||
methodNameserverDeleteRecord = "nameserver.deleteRecord"
|
||||
methodNameserverInfo = "nameserver.info"
|
||||
methodNameserverList = "nameserver.list"
|
||||
methodNameserverUpdate = "nameserver.update"
|
||||
methodNameserverUpdateRecord = "nameserver.updateRecord"
|
||||
)
|
||||
|
||||
// NameserverService API access to Nameservers.
|
||||
type NameserverService service
|
||||
|
||||
// Check Checks a domain on nameservers.
|
||||
func (s *NameserverService) Check(domain string, nameservers []string) (*NameserverCheckResponse, error) {
|
||||
req := s.client.NewRequest(methodNameserverCheck, map[string]interface{}{
|
||||
"domain": domain,
|
||||
"ns": nameservers,
|
||||
})
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result NameserverCheckResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Info Gets informations.
|
||||
func (s *NameserverService) Info(request *NameserverInfoRequest) (*NamserverInfoResponse, error) {
|
||||
req := s.client.NewRequest(methodNameserverInfo, structs.Map(request))
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result NamserverInfoResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// List List nameservers for a domain.
|
||||
func (s *NameserverService) List(domain string) (*NamserverListResponse, error) {
|
||||
requestMap := map[string]interface{}{
|
||||
"domain": "*",
|
||||
"wide": 2,
|
||||
}
|
||||
if domain != "" {
|
||||
requestMap["domain"] = domain
|
||||
}
|
||||
req := s.client.NewRequest(methodNameserverList, requestMap)
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result NamserverListResponse
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Create Creates a namesever.
|
||||
func (s *NameserverService) Create(request *NameserverCreateRequest) (int, error) {
|
||||
req := s.client.NewRequest(methodNameserverCreate, structs.Map(request))
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var result map[string]int
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result["roId"], nil
|
||||
}
|
||||
|
||||
// CreateRecord Creates a DNS record.
|
||||
func (s *NameserverService) CreateRecord(request *NameserverRecordRequest) (int, error) {
|
||||
req := s.client.NewRequest(methodNameserverCreateRecord, structs.Map(request))
|
||||
|
||||
resp, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var result map[string]int
|
||||
err = mapstructure.Decode(*resp, &result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result["id"], nil
|
||||
}
|
||||
|
||||
// UpdateRecord Updates a DNS record.
|
||||
func (s *NameserverService) UpdateRecord(recID int, request *NameserverRecordRequest) error {
|
||||
if request == nil {
|
||||
return errors.New("request can't be nil")
|
||||
}
|
||||
requestMap := structs.Map(request)
|
||||
requestMap["id"] = recID
|
||||
|
||||
req := s.client.NewRequest(methodNameserverUpdateRecord, requestMap)
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteRecord Deletes a DNS record.
|
||||
func (s *NameserverService) DeleteRecord(recID int) error {
|
||||
req := s.client.NewRequest(methodNameserverDeleteRecord, map[string]interface{}{
|
||||
"id": recID,
|
||||
})
|
||||
|
||||
_, err := s.client.Do(*req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindRecordByID Search a DNS record by ID.
|
||||
func (s *NameserverService) FindRecordByID(recID int) (*NameserverRecord, *NameserverDomain, error) {
|
||||
listResp, err := s.client.Nameservers.List("")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
for _, domainItem := range listResp.Domains {
|
||||
resp, err := s.client.Nameservers.Info(&NameserverInfoRequest{RoID: domainItem.RoID})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
for _, record := range resp.Records {
|
||||
if record.ID == recID {
|
||||
return &record, &domainItem, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil, fmt.Errorf("couldn't find INWX Record for id %d", recID)
|
||||
|
||||
}
|
||||
|
||||
// NameserverCheckResponse API model.
|
||||
type NameserverCheckResponse struct {
|
||||
Details []string
|
||||
Status string
|
||||
}
|
||||
|
||||
// NameserverRecordRequest API model.
|
||||
type NameserverRecordRequest struct {
|
||||
RoID int `structs:"roId,omitempty"`
|
||||
Domain string `structs:"domain,omitempty"`
|
||||
Type string `structs:"type"`
|
||||
Content string `structs:"content"`
|
||||
Name string `structs:"name,omitempty"`
|
||||
TTL int `structs:"ttl,omitempty"`
|
||||
Priority int `structs:"prio,omitempty"`
|
||||
URLRedirectType string `structs:"urlRedirectType,omitempty"`
|
||||
URLRedirectTitle string `structs:"urlRedirectTitle,omitempty"`
|
||||
URLRedirectDescription string `structs:"urlRedirectDescription,omitempty"`
|
||||
URLRedirectFavIcon string `structs:"urlRedirectFavIcon,omitempty"`
|
||||
URLRedirectKeywords string `structs:"urlRedirectKeywords,omitempty"`
|
||||
}
|
||||
|
||||
// NameserverCreateRequest API model.
|
||||
type NameserverCreateRequest struct {
|
||||
Domain string `structs:"domain"`
|
||||
Type string `structs:"type"`
|
||||
Nameservers []string `structs:"ns,omitempty"`
|
||||
MasterIP string `structs:"masterIp,omitempty"`
|
||||
Web string `structs:"web,omitempty"`
|
||||
Mail string `structs:"mail,omitempty"`
|
||||
SoaEmail string `structs:"soaEmail,omitempty"`
|
||||
URLRedirectType string `structs:"urlRedirectType,omitempty"`
|
||||
URLRedirectTitle string `structs:"urlRedirectTitle,omitempty"`
|
||||
URLRedirectDescription string `structs:"urlRedirectDescription,omitempty"`
|
||||
URLRedirectFavIcon string `structs:"urlRedirectFavIcon,omitempty"`
|
||||
URLRedirectKeywords string `structs:"urlRedirectKeywords,omitempty"`
|
||||
Testing bool `structs:"testing,omitempty"`
|
||||
}
|
||||
|
||||
// NameserverInfoRequest API model.
|
||||
type NameserverInfoRequest struct {
|
||||
Domain string `structs:"domain,omitempty"`
|
||||
RoID int `structs:"roId,omitempty"`
|
||||
RecordID int `structs:"recordId,omitempty"`
|
||||
Type string `structs:"type,omitempty"`
|
||||
Name string `structs:"name,omitempty"`
|
||||
Content string `structs:"content,omitempty"`
|
||||
TTL int `structs:"ttl,omitempty"`
|
||||
Priority int `structs:"prio,omitempty"`
|
||||
}
|
||||
|
||||
// NamserverInfoResponse API model.
|
||||
type NamserverInfoResponse struct {
|
||||
RoID int `mapstructure:"roId"`
|
||||
Domain string `mapstructure:"domain"`
|
||||
Type string `mapstructure:"type"`
|
||||
MasterIP string `mapstructure:"masterIp"`
|
||||
LastZoneCheck time.Time `mapstructure:"lastZoneCheck"`
|
||||
SlaveDNS []SlaveInfo `mapstructure:"slaveDns"`
|
||||
SOASerial string `mapstructure:"SOAserial"`
|
||||
Count int `mapstructure:"count"`
|
||||
Records []NameserverRecord `mapstructure:"record"`
|
||||
}
|
||||
|
||||
// SlaveInfo API model.
|
||||
type SlaveInfo struct {
|
||||
Name string `mapstructure:"name"`
|
||||
IP string `mapstructure:"ip"`
|
||||
}
|
||||
|
||||
// NameserverRecord API model.
|
||||
type NameserverRecord struct {
|
||||
ID int `mapstructure:"id"`
|
||||
Name string `mapstructure:"name"`
|
||||
Type string `mapstructure:"type"`
|
||||
Content string `mapstructure:"content"`
|
||||
TTL int `mapstructure:"TTL"`
|
||||
Priority int `mapstructure:"prio"`
|
||||
URLRedirectType string `mapstructure:"urlRedirectType"`
|
||||
URLRedirectTitle string `mapstructure:"urlRedirectTitle"`
|
||||
URLRedirectDescription string `mapstructure:"urlRedirectDescription"`
|
||||
URLRedirectKeywords string `mapstructure:"urlRedirectKeywords"`
|
||||
URLRedirectFavIcon string `mapstructure:"urlRedirectFavIcon"`
|
||||
}
|
||||
|
||||
// NamserverListResponse API model.
|
||||
type NamserverListResponse struct {
|
||||
Count int
|
||||
Domains []NameserverDomain `mapstructure:"domains"`
|
||||
}
|
||||
|
||||
// NameserverDomain API model.
|
||||
type NameserverDomain struct {
|
||||
RoID int `mapstructure:"roId"`
|
||||
Domain string `mapstructure:"domain"`
|
||||
Type string `mapstructure:"type"`
|
||||
MasterIP string `mapstructure:"masterIp"`
|
||||
Mail string `mapstructure:"mail"`
|
||||
Web string `mapstructure:"web"`
|
||||
URL string `mapstructure:"url"`
|
||||
Ipv4 string `mapstructure:"ipv4"`
|
||||
Ipv6 string `mapstructure:"ipv6"`
|
||||
}
|
28
vendor/github.com/nrdcg/goinwx/response.go
generated
vendored
Normal file
28
vendor/github.com/nrdcg/goinwx/response.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
package goinwx
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response is a INWX API response. This wraps the standard http.Response returned from INWX.
|
||||
type Response struct {
|
||||
Code int `xmlrpc:"code"`
|
||||
Message string `xmlrpc:"msg"`
|
||||
ReasonCode string `xmlrpc:"reasonCode"`
|
||||
Reason string `xmlrpc:"reason"`
|
||||
ResponseData map[string]interface{} `xmlrpc:"resData"`
|
||||
}
|
||||
|
||||
// An ErrorResponse reports the error caused by an API request
|
||||
type ErrorResponse struct {
|
||||
Code int `xmlrpc:"code"`
|
||||
Message string `xmlrpc:"msg"`
|
||||
ReasonCode string `xmlrpc:"reasonCode"`
|
||||
Reason string `xmlrpc:"reason"`
|
||||
}
|
||||
|
||||
func (r *ErrorResponse) Error() string {
|
||||
if r.Reason != "" {
|
||||
return fmt.Sprintf("(%d) %s. Reason: (%s) %s",
|
||||
r.Code, r.Message, r.ReasonCode, r.Reason)
|
||||
}
|
||||
return fmt.Sprintf("(%d) %s", r.Code, r.Message)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue