repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
go-acme/lego | providers/dns/pdns/pdns.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("pdns: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, fmt.Errorf("pdns: API key missing")
}
if config.Host == nil || config.Host.Host == "" {
return nil, fmt.Errorf("pdns: API URL missing")
}
d := &DNSProvider{config: config}
apiVersion, err := d.getAPIVersion()
if err != nil {
log.Warnf("pdns: failed to get API version %v", err)
}
d.apiVersion = apiVersion
return d, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("pdns: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, fmt.Errorf("pdns: API key missing")
}
if config.Host == nil || config.Host.Host == "" {
return nil, fmt.Errorf("pdns: API URL missing")
}
d := &DNSProvider{config: config}
apiVersion, err := d.getAPIVersion()
if err != nil {
log.Warnf("pdns: failed to get API version %v", err)
}
d.apiVersion = apiVersion
return d, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Host",
"==",
"nil",
"||",
"config",
".",
"Host",
".",
"Host",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"d",
":=",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
"}",
"\n\n",
"apiVersion",
",",
"err",
":=",
"d",
".",
"getAPIVersion",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"d",
".",
"apiVersion",
"=",
"apiVersion",
"\n\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for pdns. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"pdns",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/pdns/pdns.go#L68-L90 | train |
go-acme/lego | providers/dns/bluecat/client.go | login | func (d *DNSProvider) login() error {
queryArgs := map[string]string{
"username": d.config.UserName,
"password": d.config.Password,
}
resp, err := d.sendRequest(http.MethodGet, "login", nil, queryArgs)
if err != nil {
return err
}
defer resp.Body.Close()
authBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("bluecat: %v", err)
}
authResp := string(authBytes)
if strings.Contains(authResp, "Authentication Error") {
msg := strings.Trim(authResp, "\"")
return fmt.Errorf("bluecat: request failed: %s", msg)
}
// Upon success, API responds with "Session Token-> BAMAuthToken: dQfuRMTUxNjc3MjcyNDg1ODppcGFybXM= <- for User : username"
d.token = regexp.MustCompile("BAMAuthToken: [^ ]+").FindString(authResp)
return nil
} | go | func (d *DNSProvider) login() error {
queryArgs := map[string]string{
"username": d.config.UserName,
"password": d.config.Password,
}
resp, err := d.sendRequest(http.MethodGet, "login", nil, queryArgs)
if err != nil {
return err
}
defer resp.Body.Close()
authBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("bluecat: %v", err)
}
authResp := string(authBytes)
if strings.Contains(authResp, "Authentication Error") {
msg := strings.Trim(authResp, "\"")
return fmt.Errorf("bluecat: request failed: %s", msg)
}
// Upon success, API responds with "Session Token-> BAMAuthToken: dQfuRMTUxNjc3MjcyNDg1ODppcGFybXM= <- for User : username"
d.token = regexp.MustCompile("BAMAuthToken: [^ ]+").FindString(authResp)
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"login",
"(",
")",
"error",
"{",
"queryArgs",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"d",
".",
"config",
".",
"UserName",
",",
"\"",
"\"",
":",
"d",
".",
"config",
".",
"Password",
",",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
",",
"queryArgs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"authBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"authResp",
":=",
"string",
"(",
"authBytes",
")",
"\n\n",
"if",
"strings",
".",
"Contains",
"(",
"authResp",
",",
"\"",
"\"",
")",
"{",
"msg",
":=",
"strings",
".",
"Trim",
"(",
"authResp",
",",
"\"",
"\\\"",
"\"",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"msg",
")",
"\n",
"}",
"\n\n",
"// Upon success, API responds with \"Session Token-> BAMAuthToken: dQfuRMTUxNjc3MjcyNDg1ODppcGFybXM= <- for User : username\"",
"d",
".",
"token",
"=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
".",
"FindString",
"(",
"authResp",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Starts a new Bluecat API Session. Authenticates using customerName, userName,
// password and receives a token to be used in for subsequent requests. | [
"Starts",
"a",
"new",
"Bluecat",
"API",
"Session",
".",
"Authenticates",
"using",
"customerName",
"userName",
"password",
"and",
"receives",
"a",
"token",
"to",
"be",
"used",
"in",
"for",
"subsequent",
"requests",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L31-L57 | train |
go-acme/lego | providers/dns/bluecat/client.go | logout | func (d *DNSProvider) logout() error {
if len(d.token) == 0 {
// nothing to do
return nil
}
resp, err := d.sendRequest(http.MethodGet, "logout", nil, nil)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("bluecat: request failed to delete session with HTTP status code %d", resp.StatusCode)
}
authBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
authResp := string(authBytes)
if !strings.Contains(authResp, "successfully") {
msg := strings.Trim(authResp, "\"")
return fmt.Errorf("bluecat: request failed to delete session: %s", msg)
}
d.token = ""
return nil
} | go | func (d *DNSProvider) logout() error {
if len(d.token) == 0 {
// nothing to do
return nil
}
resp, err := d.sendRequest(http.MethodGet, "logout", nil, nil)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("bluecat: request failed to delete session with HTTP status code %d", resp.StatusCode)
}
authBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
authResp := string(authBytes)
if !strings.Contains(authResp, "successfully") {
msg := strings.Trim(authResp, "\"")
return fmt.Errorf("bluecat: request failed to delete session: %s", msg)
}
d.token = ""
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"logout",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"d",
".",
"token",
")",
"==",
"0",
"{",
"// nothing to do",
"return",
"nil",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"if",
"resp",
".",
"StatusCode",
"!=",
"200",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"StatusCode",
")",
"\n",
"}",
"\n\n",
"authBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"authResp",
":=",
"string",
"(",
"authBytes",
")",
"\n\n",
"if",
"!",
"strings",
".",
"Contains",
"(",
"authResp",
",",
"\"",
"\"",
")",
"{",
"msg",
":=",
"strings",
".",
"Trim",
"(",
"authResp",
",",
"\"",
"\\\"",
"\"",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"msg",
")",
"\n",
"}",
"\n\n",
"d",
".",
"token",
"=",
"\"",
"\"",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Destroys Bluecat Session | [
"Destroys",
"Bluecat",
"Session"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L60-L90 | train |
go-acme/lego | providers/dns/bluecat/client.go | lookupConfID | func (d *DNSProvider) lookupConfID() (uint, error) {
queryArgs := map[string]string{
"parentId": strconv.Itoa(0),
"name": d.config.ConfigName,
"type": configType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
if err != nil {
return 0, err
}
defer resp.Body.Close()
var conf entityResponse
err = json.NewDecoder(resp.Body).Decode(&conf)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return conf.ID, nil
} | go | func (d *DNSProvider) lookupConfID() (uint, error) {
queryArgs := map[string]string{
"parentId": strconv.Itoa(0),
"name": d.config.ConfigName,
"type": configType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
if err != nil {
return 0, err
}
defer resp.Body.Close()
var conf entityResponse
err = json.NewDecoder(resp.Body).Decode(&conf)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return conf.ID, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"lookupConfID",
"(",
")",
"(",
"uint",
",",
"error",
")",
"{",
"queryArgs",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strconv",
".",
"Itoa",
"(",
"0",
")",
",",
"\"",
"\"",
":",
"d",
".",
"config",
".",
"ConfigName",
",",
"\"",
"\"",
":",
"configType",
",",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
",",
"queryArgs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"var",
"conf",
"entityResponse",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"conf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"conf",
".",
"ID",
",",
"nil",
"\n",
"}"
] | // Lookup the entity ID of the configuration named in our properties | [
"Lookup",
"the",
"entity",
"ID",
"of",
"the",
"configuration",
"named",
"in",
"our",
"properties"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L93-L112 | train |
go-acme/lego | providers/dns/bluecat/client.go | lookupViewID | func (d *DNSProvider) lookupViewID(viewName string) (uint, error) {
confID, err := d.lookupConfID()
if err != nil {
return 0, err
}
queryArgs := map[string]string{
"parentId": strconv.FormatUint(uint64(confID), 10),
"name": viewName,
"type": viewType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
if err != nil {
return 0, err
}
defer resp.Body.Close()
var view entityResponse
err = json.NewDecoder(resp.Body).Decode(&view)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return view.ID, nil
} | go | func (d *DNSProvider) lookupViewID(viewName string) (uint, error) {
confID, err := d.lookupConfID()
if err != nil {
return 0, err
}
queryArgs := map[string]string{
"parentId": strconv.FormatUint(uint64(confID), 10),
"name": viewName,
"type": viewType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
if err != nil {
return 0, err
}
defer resp.Body.Close()
var view entityResponse
err = json.NewDecoder(resp.Body).Decode(&view)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return view.ID, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"lookupViewID",
"(",
"viewName",
"string",
")",
"(",
"uint",
",",
"error",
")",
"{",
"confID",
",",
"err",
":=",
"d",
".",
"lookupConfID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"queryArgs",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"confID",
")",
",",
"10",
")",
",",
"\"",
"\"",
":",
"viewName",
",",
"\"",
"\"",
":",
"viewType",
",",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
",",
"queryArgs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"var",
"view",
"entityResponse",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"view",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"view",
".",
"ID",
",",
"nil",
"\n",
"}"
] | // Find the DNS view with the given name within | [
"Find",
"the",
"DNS",
"view",
"with",
"the",
"given",
"name",
"within"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L115-L140 | train |
go-acme/lego | providers/dns/bluecat/client.go | lookupParentZoneID | func (d *DNSProvider) lookupParentZoneID(viewID uint, fqdn string) (uint, string, error) {
parentViewID := viewID
name := ""
if fqdn != "" {
zones := strings.Split(strings.Trim(fqdn, "."), ".")
last := len(zones) - 1
name = zones[0]
for i := last; i > -1; i-- {
zoneID, err := d.getZone(parentViewID, zones[i])
if err != nil || zoneID == 0 {
return parentViewID, name, err
}
if i > 0 {
name = strings.Join(zones[0:i], ".")
}
parentViewID = zoneID
}
}
return parentViewID, name, nil
} | go | func (d *DNSProvider) lookupParentZoneID(viewID uint, fqdn string) (uint, string, error) {
parentViewID := viewID
name := ""
if fqdn != "" {
zones := strings.Split(strings.Trim(fqdn, "."), ".")
last := len(zones) - 1
name = zones[0]
for i := last; i > -1; i-- {
zoneID, err := d.getZone(parentViewID, zones[i])
if err != nil || zoneID == 0 {
return parentViewID, name, err
}
if i > 0 {
name = strings.Join(zones[0:i], ".")
}
parentViewID = zoneID
}
}
return parentViewID, name, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"lookupParentZoneID",
"(",
"viewID",
"uint",
",",
"fqdn",
"string",
")",
"(",
"uint",
",",
"string",
",",
"error",
")",
"{",
"parentViewID",
":=",
"viewID",
"\n",
"name",
":=",
"\"",
"\"",
"\n\n",
"if",
"fqdn",
"!=",
"\"",
"\"",
"{",
"zones",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"Trim",
"(",
"fqdn",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"last",
":=",
"len",
"(",
"zones",
")",
"-",
"1",
"\n",
"name",
"=",
"zones",
"[",
"0",
"]",
"\n\n",
"for",
"i",
":=",
"last",
";",
"i",
">",
"-",
"1",
";",
"i",
"--",
"{",
"zoneID",
",",
"err",
":=",
"d",
".",
"getZone",
"(",
"parentViewID",
",",
"zones",
"[",
"i",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"zoneID",
"==",
"0",
"{",
"return",
"parentViewID",
",",
"name",
",",
"err",
"\n",
"}",
"\n",
"if",
"i",
">",
"0",
"{",
"name",
"=",
"strings",
".",
"Join",
"(",
"zones",
"[",
"0",
":",
"i",
"]",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"parentViewID",
"=",
"zoneID",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"parentViewID",
",",
"name",
",",
"nil",
"\n",
"}"
] | // Return the entityId of the parent zone by recursing from the root view
// Also return the simple name of the host | [
"Return",
"the",
"entityId",
"of",
"the",
"parent",
"zone",
"by",
"recursing",
"from",
"the",
"root",
"view",
"Also",
"return",
"the",
"simple",
"name",
"of",
"the",
"host"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L144-L166 | train |
go-acme/lego | providers/dns/bluecat/client.go | getZone | func (d *DNSProvider) getZone(parentID uint, name string) (uint, error) {
queryArgs := map[string]string{
"parentId": strconv.FormatUint(uint64(parentID), 10),
"name": name,
"type": zoneType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
// Return an empty zone if the named zone doesn't exist
if resp != nil && resp.StatusCode == http.StatusNotFound {
return 0, fmt.Errorf("bluecat: could not find zone named %s", name)
}
if err != nil {
return 0, err
}
defer resp.Body.Close()
var zone entityResponse
err = json.NewDecoder(resp.Body).Decode(&zone)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return zone.ID, nil
} | go | func (d *DNSProvider) getZone(parentID uint, name string) (uint, error) {
queryArgs := map[string]string{
"parentId": strconv.FormatUint(uint64(parentID), 10),
"name": name,
"type": zoneType,
}
resp, err := d.sendRequest(http.MethodGet, "getEntityByName", nil, queryArgs)
// Return an empty zone if the named zone doesn't exist
if resp != nil && resp.StatusCode == http.StatusNotFound {
return 0, fmt.Errorf("bluecat: could not find zone named %s", name)
}
if err != nil {
return 0, err
}
defer resp.Body.Close()
var zone entityResponse
err = json.NewDecoder(resp.Body).Decode(&zone)
if err != nil {
return 0, fmt.Errorf("bluecat: %v", err)
}
return zone.ID, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"getZone",
"(",
"parentID",
"uint",
",",
"name",
"string",
")",
"(",
"uint",
",",
"error",
")",
"{",
"queryArgs",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"parentID",
")",
",",
"10",
")",
",",
"\"",
"\"",
":",
"name",
",",
"\"",
"\"",
":",
"zoneType",
",",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
",",
"queryArgs",
")",
"\n\n",
"// Return an empty zone if the named zone doesn't exist",
"if",
"resp",
"!=",
"nil",
"&&",
"resp",
".",
"StatusCode",
"==",
"http",
".",
"StatusNotFound",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"var",
"zone",
"entityResponse",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"zone",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"zone",
".",
"ID",
",",
"nil",
"\n",
"}"
] | // Get the DNS zone with the specified name under the parentId | [
"Get",
"the",
"DNS",
"zone",
"with",
"the",
"specified",
"name",
"under",
"the",
"parentId"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L169-L194 | train |
go-acme/lego | providers/dns/bluecat/client.go | deploy | func (d *DNSProvider) deploy(entityID uint) error {
queryArgs := map[string]string{
"entityId": strconv.FormatUint(uint64(entityID), 10),
}
resp, err := d.sendRequest(http.MethodPost, "quickDeploy", nil, queryArgs)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | go | func (d *DNSProvider) deploy(entityID uint) error {
queryArgs := map[string]string{
"entityId": strconv.FormatUint(uint64(entityID), 10),
}
resp, err := d.sendRequest(http.MethodPost, "quickDeploy", nil, queryArgs)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"deploy",
"(",
"entityID",
"uint",
")",
"error",
"{",
"queryArgs",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"entityID",
")",
",",
"10",
")",
",",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"d",
".",
"sendRequest",
"(",
"http",
".",
"MethodPost",
",",
"\"",
"\"",
",",
"nil",
",",
"queryArgs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Deploy the DNS config for the specified entity to the authoritative servers | [
"Deploy",
"the",
"DNS",
"config",
"for",
"the",
"specified",
"entity",
"to",
"the",
"authoritative",
"servers"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L197-L209 | train |
go-acme/lego | providers/dns/bluecat/client.go | sendRequest | func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, queryArgs map[string]string) (*http.Response, error) {
url := fmt.Sprintf("%s/Services/REST/v1/%s", d.config.BaseURL, resource)
body, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
req, err := http.NewRequest(method, url, bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
req.Header.Set("Content-Type", "application/json")
if len(d.token) > 0 {
req.Header.Set("Authorization", d.token)
}
// Add all query parameters
q := req.URL.Query()
for argName, argVal := range queryArgs {
q.Add(argName, argVal)
}
req.URL.RawQuery = q.Encode()
resp, err := d.config.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
if resp.StatusCode >= 400 {
errBytes, _ := ioutil.ReadAll(resp.Body)
errResp := string(errBytes)
return nil, fmt.Errorf("bluecat: request failed with HTTP status code %d\n Full message: %s",
resp.StatusCode, errResp)
}
return resp, nil
} | go | func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, queryArgs map[string]string) (*http.Response, error) {
url := fmt.Sprintf("%s/Services/REST/v1/%s", d.config.BaseURL, resource)
body, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
req, err := http.NewRequest(method, url, bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
req.Header.Set("Content-Type", "application/json")
if len(d.token) > 0 {
req.Header.Set("Authorization", d.token)
}
// Add all query parameters
q := req.URL.Query()
for argName, argVal := range queryArgs {
q.Add(argName, argVal)
}
req.URL.RawQuery = q.Encode()
resp, err := d.config.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("bluecat: %v", err)
}
if resp.StatusCode >= 400 {
errBytes, _ := ioutil.ReadAll(resp.Body)
errResp := string(errBytes)
return nil, fmt.Errorf("bluecat: request failed with HTTP status code %d\n Full message: %s",
resp.StatusCode, errResp)
}
return resp, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"sendRequest",
"(",
"method",
",",
"resource",
"string",
",",
"payload",
"interface",
"{",
"}",
",",
"queryArgs",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"config",
".",
"BaseURL",
",",
"resource",
")",
"\n\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"payload",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"url",
",",
"bytes",
".",
"NewReader",
"(",
"body",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"d",
".",
"token",
")",
">",
"0",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"d",
".",
"token",
")",
"\n",
"}",
"\n\n",
"// Add all query parameters",
"q",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
"\n",
"for",
"argName",
",",
"argVal",
":=",
"range",
"queryArgs",
"{",
"q",
".",
"Add",
"(",
"argName",
",",
"argVal",
")",
"\n",
"}",
"\n",
"req",
".",
"URL",
".",
"RawQuery",
"=",
"q",
".",
"Encode",
"(",
")",
"\n",
"resp",
",",
"err",
":=",
"d",
".",
"config",
".",
"HTTPClient",
".",
"Do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"resp",
".",
"StatusCode",
">=",
"400",
"{",
"errBytes",
",",
"_",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"errResp",
":=",
"string",
"(",
"errBytes",
")",
"\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"resp",
".",
"StatusCode",
",",
"errResp",
")",
"\n",
"}",
"\n\n",
"return",
"resp",
",",
"nil",
"\n",
"}"
] | // Send a REST request, using query parameters specified. The Authorization
// header will be set if we have an active auth token | [
"Send",
"a",
"REST",
"request",
"using",
"query",
"parameters",
"specified",
".",
"The",
"Authorization",
"header",
"will",
"be",
"set",
"if",
"we",
"have",
"an",
"active",
"auth",
"token"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/bluecat/client.go#L213-L249 | train |
go-acme/lego | acme/api/internal/sender/sender.go | NewDoer | func NewDoer(client *http.Client, userAgent string) *Doer {
return &Doer{
httpClient: client,
userAgent: userAgent,
}
} | go | func NewDoer(client *http.Client, userAgent string) *Doer {
return &Doer{
httpClient: client,
userAgent: userAgent,
}
} | [
"func",
"NewDoer",
"(",
"client",
"*",
"http",
".",
"Client",
",",
"userAgent",
"string",
")",
"*",
"Doer",
"{",
"return",
"&",
"Doer",
"{",
"httpClient",
":",
"client",
",",
"userAgent",
":",
"userAgent",
",",
"}",
"\n",
"}"
] | // NewDoer Creates a new Doer. | [
"NewDoer",
"Creates",
"a",
"new",
"Doer",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/sender/sender.go#L30-L35 | train |
go-acme/lego | acme/api/internal/sender/sender.go | Get | func (d *Doer) Get(url string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodGet, url, nil)
if err != nil {
return nil, err
}
return d.do(req, response)
} | go | func (d *Doer) Get(url string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodGet, url, nil)
if err != nil {
return nil, err
}
return d.do(req, response)
} | [
"func",
"(",
"d",
"*",
"Doer",
")",
"Get",
"(",
"url",
"string",
",",
"response",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"d",
".",
"newRequest",
"(",
"http",
".",
"MethodGet",
",",
"url",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"d",
".",
"do",
"(",
"req",
",",
"response",
")",
"\n",
"}"
] | // Get performs a GET request with a proper User-Agent string.
// If "response" is not provided, callers should close resp.Body when done reading from it. | [
"Get",
"performs",
"a",
"GET",
"request",
"with",
"a",
"proper",
"User",
"-",
"Agent",
"string",
".",
"If",
"response",
"is",
"not",
"provided",
"callers",
"should",
"close",
"resp",
".",
"Body",
"when",
"done",
"reading",
"from",
"it",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/sender/sender.go#L39-L46 | train |
go-acme/lego | acme/api/internal/sender/sender.go | Post | func (d *Doer) Post(url string, body io.Reader, bodyType string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodPost, url, body, contentType(bodyType))
if err != nil {
return nil, err
}
return d.do(req, response)
} | go | func (d *Doer) Post(url string, body io.Reader, bodyType string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodPost, url, body, contentType(bodyType))
if err != nil {
return nil, err
}
return d.do(req, response)
} | [
"func",
"(",
"d",
"*",
"Doer",
")",
"Post",
"(",
"url",
"string",
",",
"body",
"io",
".",
"Reader",
",",
"bodyType",
"string",
",",
"response",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"d",
".",
"newRequest",
"(",
"http",
".",
"MethodPost",
",",
"url",
",",
"body",
",",
"contentType",
"(",
"bodyType",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"d",
".",
"do",
"(",
"req",
",",
"response",
")",
"\n",
"}"
] | // Post performs a POST request with a proper User-Agent string.
// If "response" is not provided, callers should close resp.Body when done reading from it. | [
"Post",
"performs",
"a",
"POST",
"request",
"with",
"a",
"proper",
"User",
"-",
"Agent",
"string",
".",
"If",
"response",
"is",
"not",
"provided",
"callers",
"should",
"close",
"resp",
".",
"Body",
"when",
"done",
"reading",
"from",
"it",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/sender/sender.go#L61-L68 | train |
go-acme/lego | acme/api/internal/sender/sender.go | formatUserAgent | func (d *Doer) formatUserAgent() string {
ua := fmt.Sprintf("%s %s (%s; %s; %s)", d.userAgent, ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH)
return strings.TrimSpace(ua)
} | go | func (d *Doer) formatUserAgent() string {
ua := fmt.Sprintf("%s %s (%s; %s; %s)", d.userAgent, ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH)
return strings.TrimSpace(ua)
} | [
"func",
"(",
"d",
"*",
"Doer",
")",
"formatUserAgent",
"(",
")",
"string",
"{",
"ua",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"userAgent",
",",
"ourUserAgent",
",",
"ourUserAgentComment",
",",
"runtime",
".",
"GOOS",
",",
"runtime",
".",
"GOARCH",
")",
"\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"ua",
")",
"\n",
"}"
] | // formatUserAgent builds and returns the User-Agent string to use in requests. | [
"formatUserAgent",
"builds",
"and",
"returns",
"the",
"User",
"-",
"Agent",
"string",
"to",
"use",
"in",
"requests",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/sender/sender.go#L116-L119 | train |
go-acme/lego | providers/dns/dode/dode.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("do.de: the configuration of the DNS provider is nil")
}
if config.Token == "" {
return nil, errors.New("do.de: credentials missing")
}
return &DNSProvider{config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("do.de: the configuration of the DNS provider is nil")
}
if config.Token == "" {
return nil, errors.New("do.de: credentials missing")
}
return &DNSProvider{config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Token",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for do.de. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"do",
".",
"de",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dode/dode.go#L55-L65 | train |
go-acme/lego | providers/dns/dode/dode.go | CleanUp | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
return d.updateTxtRecord(fqdn, d.config.Token, "", true)
} | go | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
return d.updateTxtRecord(fqdn, d.config.Token, "", true)
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"CleanUp",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"_",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n",
"return",
"d",
".",
"updateTxtRecord",
"(",
"fqdn",
",",
"d",
".",
"config",
".",
"Token",
",",
"\"",
"\"",
",",
"true",
")",
"\n",
"}"
] | // CleanUp clears TXT record | [
"CleanUp",
"clears",
"TXT",
"record"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dode/dode.go#L74-L77 | train |
go-acme/lego | providers/dns/dnsmadeeasy/internal/client.go | NewClient | func NewClient(apiKey string, apiSecret string) (*Client, error) {
if apiKey == "" {
return nil, fmt.Errorf("credentials missing: API key")
}
if apiSecret == "" {
return nil, fmt.Errorf("credentials missing: API secret")
}
return &Client{
apiKey: apiKey,
apiSecret: apiSecret,
HTTPClient: &http.Client{},
}, nil
} | go | func NewClient(apiKey string, apiSecret string) (*Client, error) {
if apiKey == "" {
return nil, fmt.Errorf("credentials missing: API key")
}
if apiSecret == "" {
return nil, fmt.Errorf("credentials missing: API secret")
}
return &Client{
apiKey: apiKey,
apiSecret: apiSecret,
HTTPClient: &http.Client{},
}, nil
} | [
"func",
"NewClient",
"(",
"apiKey",
"string",
",",
"apiSecret",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"apiKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"apiSecret",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Client",
"{",
"apiKey",
":",
"apiKey",
",",
"apiSecret",
":",
"apiSecret",
",",
"HTTPClient",
":",
"&",
"http",
".",
"Client",
"{",
"}",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewClient creates a DNSMadeEasy client | [
"NewClient",
"creates",
"a",
"DNSMadeEasy",
"client"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/internal/client.go#L44-L58 | train |
go-acme/lego | providers/dns/dnsmadeeasy/internal/client.go | GetDomain | func (c *Client) GetDomain(authZone string) (*Domain, error) {
domainName := authZone[0 : len(authZone)-1]
resource := fmt.Sprintf("%s%s", "/dns/managed/name?domainname=", domainName)
resp, err := c.sendRequest(http.MethodGet, resource, nil)
if err != nil {
return nil, err
}
defer resp.Body.Close()
domain := &Domain{}
err = json.NewDecoder(resp.Body).Decode(&domain)
if err != nil {
return nil, err
}
return domain, nil
} | go | func (c *Client) GetDomain(authZone string) (*Domain, error) {
domainName := authZone[0 : len(authZone)-1]
resource := fmt.Sprintf("%s%s", "/dns/managed/name?domainname=", domainName)
resp, err := c.sendRequest(http.MethodGet, resource, nil)
if err != nil {
return nil, err
}
defer resp.Body.Close()
domain := &Domain{}
err = json.NewDecoder(resp.Body).Decode(&domain)
if err != nil {
return nil, err
}
return domain, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDomain",
"(",
"authZone",
"string",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"domainName",
":=",
"authZone",
"[",
"0",
":",
"len",
"(",
"authZone",
")",
"-",
"1",
"]",
"\n",
"resource",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"domainName",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"resource",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"domain",
":=",
"&",
"Domain",
"{",
"}",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"domain",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"domain",
",",
"nil",
"\n",
"}"
] | // GetDomain gets a domain | [
"GetDomain",
"gets",
"a",
"domain"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/internal/client.go#L61-L78 | train |
go-acme/lego | providers/dns/dnsmadeeasy/internal/client.go | GetRecords | func (c *Client) GetRecords(domain *Domain, recordName, recordType string) (*[]Record, error) {
resource := fmt.Sprintf("%s/%d/%s%s%s%s", "/dns/managed", domain.ID, "records?recordName=", recordName, "&type=", recordType)
resp, err := c.sendRequest(http.MethodGet, resource, nil)
if err != nil {
return nil, err
}
defer resp.Body.Close()
records := &recordsResponse{}
err = json.NewDecoder(resp.Body).Decode(&records)
if err != nil {
return nil, err
}
return records.Records, nil
} | go | func (c *Client) GetRecords(domain *Domain, recordName, recordType string) (*[]Record, error) {
resource := fmt.Sprintf("%s/%d/%s%s%s%s", "/dns/managed", domain.ID, "records?recordName=", recordName, "&type=", recordType)
resp, err := c.sendRequest(http.MethodGet, resource, nil)
if err != nil {
return nil, err
}
defer resp.Body.Close()
records := &recordsResponse{}
err = json.NewDecoder(resp.Body).Decode(&records)
if err != nil {
return nil, err
}
return records.Records, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetRecords",
"(",
"domain",
"*",
"Domain",
",",
"recordName",
",",
"recordType",
"string",
")",
"(",
"*",
"[",
"]",
"Record",
",",
"error",
")",
"{",
"resource",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"domain",
".",
"ID",
",",
"\"",
"\"",
",",
"recordName",
",",
"\"",
"\"",
",",
"recordType",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"http",
".",
"MethodGet",
",",
"resource",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"records",
":=",
"&",
"recordsResponse",
"{",
"}",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"records",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"records",
".",
"Records",
",",
"nil",
"\n",
"}"
] | // GetRecords gets all TXT records | [
"GetRecords",
"gets",
"all",
"TXT",
"records"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/internal/client.go#L81-L97 | train |
go-acme/lego | providers/dns/dnsmadeeasy/internal/client.go | CreateRecord | func (c *Client) CreateRecord(domain *Domain, record *Record) error {
url := fmt.Sprintf("%s/%d/%s", "/dns/managed", domain.ID, "records")
resp, err := c.sendRequest(http.MethodPost, url, record)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | go | func (c *Client) CreateRecord(domain *Domain, record *Record) error {
url := fmt.Sprintf("%s/%d/%s", "/dns/managed", domain.ID, "records")
resp, err := c.sendRequest(http.MethodPost, url, record)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateRecord",
"(",
"domain",
"*",
"Domain",
",",
"record",
"*",
"Record",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"domain",
".",
"ID",
",",
"\"",
"\"",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"http",
".",
"MethodPost",
",",
"url",
",",
"record",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CreateRecord creates a TXT records | [
"CreateRecord",
"creates",
"a",
"TXT",
"records"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/internal/client.go#L100-L110 | train |
go-acme/lego | providers/dns/dnsmadeeasy/internal/client.go | DeleteRecord | func (c *Client) DeleteRecord(record Record) error {
resource := fmt.Sprintf("%s/%d/%s/%d", "/dns/managed", record.SourceID, "records", record.ID)
resp, err := c.sendRequest(http.MethodDelete, resource, nil)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | go | func (c *Client) DeleteRecord(record Record) error {
resource := fmt.Sprintf("%s/%d/%s/%d", "/dns/managed", record.SourceID, "records", record.ID)
resp, err := c.sendRequest(http.MethodDelete, resource, nil)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteRecord",
"(",
"record",
"Record",
")",
"error",
"{",
"resource",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"record",
".",
"SourceID",
",",
"\"",
"\"",
",",
"record",
".",
"ID",
")",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"http",
".",
"MethodDelete",
",",
"resource",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // DeleteRecord deletes a TXT records | [
"DeleteRecord",
"deletes",
"a",
"TXT",
"records"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/internal/client.go#L113-L123 | train |
go-acme/lego | challenge/dns01/cname.go | updateDomainWithCName | func updateDomainWithCName(r *dns.Msg, fqdn string) string {
for _, rr := range r.Answer {
if cn, ok := rr.(*dns.CNAME); ok {
if cn.Hdr.Name == fqdn {
return cn.Target
}
}
}
return fqdn
} | go | func updateDomainWithCName(r *dns.Msg, fqdn string) string {
for _, rr := range r.Answer {
if cn, ok := rr.(*dns.CNAME); ok {
if cn.Hdr.Name == fqdn {
return cn.Target
}
}
}
return fqdn
} | [
"func",
"updateDomainWithCName",
"(",
"r",
"*",
"dns",
".",
"Msg",
",",
"fqdn",
"string",
")",
"string",
"{",
"for",
"_",
",",
"rr",
":=",
"range",
"r",
".",
"Answer",
"{",
"if",
"cn",
",",
"ok",
":=",
"rr",
".",
"(",
"*",
"dns",
".",
"CNAME",
")",
";",
"ok",
"{",
"if",
"cn",
".",
"Hdr",
".",
"Name",
"==",
"fqdn",
"{",
"return",
"cn",
".",
"Target",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"fqdn",
"\n",
"}"
] | // Update FQDN with CNAME if any | [
"Update",
"FQDN",
"with",
"CNAME",
"if",
"any"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/dns01/cname.go#L6-L16 | train |
go-acme/lego | acme/api/service.go | getLink | func getLink(header http.Header, rel string) string {
var linkExpr = regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`)
for _, link := range header["Link"] {
for _, m := range linkExpr.FindAllStringSubmatch(link, -1) {
if len(m) != 3 {
continue
}
if m[2] == rel {
return m[1]
}
}
}
return ""
} | go | func getLink(header http.Header, rel string) string {
var linkExpr = regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`)
for _, link := range header["Link"] {
for _, m := range linkExpr.FindAllStringSubmatch(link, -1) {
if len(m) != 3 {
continue
}
if m[2] == rel {
return m[1]
}
}
}
return ""
} | [
"func",
"getLink",
"(",
"header",
"http",
".",
"Header",
",",
"rel",
"string",
")",
"string",
"{",
"var",
"linkExpr",
"=",
"regexp",
".",
"MustCompile",
"(",
"`<(.+?)>;\\s*rel=\"(.+?)\"`",
")",
"\n\n",
"for",
"_",
",",
"link",
":=",
"range",
"header",
"[",
"\"",
"\"",
"]",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"linkExpr",
".",
"FindAllStringSubmatch",
"(",
"link",
",",
"-",
"1",
")",
"{",
"if",
"len",
"(",
"m",
")",
"!=",
"3",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"m",
"[",
"2",
"]",
"==",
"rel",
"{",
"return",
"m",
"[",
"1",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // getLink get a rel into the Link header | [
"getLink",
"get",
"a",
"rel",
"into",
"the",
"Link",
"header"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/service.go#L13-L27 | train |
go-acme/lego | acme/api/service.go | getLocation | func getLocation(resp *http.Response) string {
if resp == nil {
return ""
}
return resp.Header.Get("Location")
} | go | func getLocation(resp *http.Response) string {
if resp == nil {
return ""
}
return resp.Header.Get("Location")
} | [
"func",
"getLocation",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"string",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // getLocation get the value of the header Location | [
"getLocation",
"get",
"the",
"value",
"of",
"the",
"header",
"Location"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/service.go#L30-L36 | train |
go-acme/lego | acme/api/service.go | getRetryAfter | func getRetryAfter(resp *http.Response) string {
if resp == nil {
return ""
}
return resp.Header.Get("Retry-After")
} | go | func getRetryAfter(resp *http.Response) string {
if resp == nil {
return ""
}
return resp.Header.Get("Retry-After")
} | [
"func",
"getRetryAfter",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"string",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // getRetryAfter get the value of the header Retry-After | [
"getRetryAfter",
"get",
"the",
"value",
"of",
"the",
"header",
"Retry",
"-",
"After"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/service.go#L39-L45 | train |
go-acme/lego | providers/http/webroot/webroot.go | NewHTTPProvider | func NewHTTPProvider(path string) (*HTTPProvider, error) {
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, fmt.Errorf("webroot path does not exist")
}
return &HTTPProvider{path: path}, nil
} | go | func NewHTTPProvider(path string) (*HTTPProvider, error) {
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, fmt.Errorf("webroot path does not exist")
}
return &HTTPProvider{path: path}, nil
} | [
"func",
"NewHTTPProvider",
"(",
"path",
"string",
")",
"(",
"*",
"HTTPProvider",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
";",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"HTTPProvider",
"{",
"path",
":",
"path",
"}",
",",
"nil",
"\n",
"}"
] | // NewHTTPProvider returns a HTTPProvider instance with a configured webroot path | [
"NewHTTPProvider",
"returns",
"a",
"HTTPProvider",
"instance",
"with",
"a",
"configured",
"webroot",
"path"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/http/webroot/webroot.go#L19-L25 | train |
go-acme/lego | providers/http/webroot/webroot.go | CleanUp | func (w *HTTPProvider) CleanUp(domain, token, keyAuth string) error {
err := os.Remove(filepath.Join(w.path, http01.ChallengePath(token)))
if err != nil {
return fmt.Errorf("could not remove file in webroot after HTTP challenge -> %v", err)
}
return nil
} | go | func (w *HTTPProvider) CleanUp(domain, token, keyAuth string) error {
err := os.Remove(filepath.Join(w.path, http01.ChallengePath(token)))
if err != nil {
return fmt.Errorf("could not remove file in webroot after HTTP challenge -> %v", err)
}
return nil
} | [
"func",
"(",
"w",
"*",
"HTTPProvider",
")",
"CleanUp",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"err",
":=",
"os",
".",
"Remove",
"(",
"filepath",
".",
"Join",
"(",
"w",
".",
"path",
",",
"http01",
".",
"ChallengePath",
"(",
"token",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CleanUp removes the file created for the challenge | [
"CleanUp",
"removes",
"the",
"file",
"created",
"for",
"the",
"challenge"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/http/webroot/webroot.go#L46-L53 | train |
go-acme/lego | providers/dns/netcup/netcup.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("netcup: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.Customer, config.Key, config.Password)
if err != nil {
return nil, fmt.Errorf("netcup: %v", err)
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("netcup: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.Customer, config.Key, config.Password)
if err != nil {
return nil, fmt.Errorf("netcup: %v", err)
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"internal",
".",
"NewClient",
"(",
"config",
".",
"Customer",
",",
"config",
".",
"Key",
",",
"config",
".",
"Password",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"client",
".",
"HTTPClient",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for netcup. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"netcup",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/netcup/netcup.go#L65-L78 | train |
go-acme/lego | providers/dns/stackpath/stackpath.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("stackpath: the configuration of the DNS provider is nil")
}
if len(config.ClientID) == 0 || len(config.ClientSecret) == 0 {
return nil, errors.New("stackpath: credentials missing")
}
if len(config.StackID) == 0 {
return nil, errors.New("stackpath: stack id missing")
}
baseURL, _ := url.Parse(defaultBaseURL)
return &DNSProvider{
BaseURL: baseURL,
client: getOathClient(config),
config: config,
}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("stackpath: the configuration of the DNS provider is nil")
}
if len(config.ClientID) == 0 || len(config.ClientSecret) == 0 {
return nil, errors.New("stackpath: credentials missing")
}
if len(config.StackID) == 0 {
return nil, errors.New("stackpath: stack id missing")
}
baseURL, _ := url.Parse(defaultBaseURL)
return &DNSProvider{
BaseURL: baseURL,
client: getOathClient(config),
config: config,
}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"config",
".",
"ClientID",
")",
"==",
"0",
"||",
"len",
"(",
"config",
".",
"ClientSecret",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"config",
".",
"StackID",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"baseURL",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"defaultBaseURL",
")",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"BaseURL",
":",
"baseURL",
",",
"client",
":",
"getOathClient",
"(",
"config",
")",
",",
"config",
":",
"config",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for Stackpath. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Stackpath",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/stackpath/stackpath.go#L69-L89 | train |
go-acme/lego | providers/dns/ovh/ovh.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ovh: the configuration of the DNS provider is nil")
}
if config.APIEndpoint == "" || config.ApplicationKey == "" || config.ApplicationSecret == "" || config.ConsumerKey == "" {
return nil, fmt.Errorf("ovh: credentials missing")
}
client, err := ovh.NewClient(
config.APIEndpoint,
config.ApplicationKey,
config.ApplicationSecret,
config.ConsumerKey,
)
if err != nil {
return nil, fmt.Errorf("ovh: %v", err)
}
client.Client = config.HTTPClient
return &DNSProvider{
config: config,
client: client,
recordIDs: make(map[string]int),
}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ovh: the configuration of the DNS provider is nil")
}
if config.APIEndpoint == "" || config.ApplicationKey == "" || config.ApplicationSecret == "" || config.ConsumerKey == "" {
return nil, fmt.Errorf("ovh: credentials missing")
}
client, err := ovh.NewClient(
config.APIEndpoint,
config.ApplicationKey,
config.ApplicationSecret,
config.ConsumerKey,
)
if err != nil {
return nil, fmt.Errorf("ovh: %v", err)
}
client.Client = config.HTTPClient
return &DNSProvider{
config: config,
client: client,
recordIDs: make(map[string]int),
}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIEndpoint",
"==",
"\"",
"\"",
"||",
"config",
".",
"ApplicationKey",
"==",
"\"",
"\"",
"||",
"config",
".",
"ApplicationSecret",
"==",
"\"",
"\"",
"||",
"config",
".",
"ConsumerKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"ovh",
".",
"NewClient",
"(",
"config",
".",
"APIEndpoint",
",",
"config",
".",
"ApplicationKey",
",",
"config",
".",
"ApplicationSecret",
",",
"config",
".",
"ConsumerKey",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"client",
".",
"Client",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"client",
",",
"recordIDs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for OVH. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"OVH",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/ovh/ovh.go#L85-L111 | train |
go-acme/lego | providers/dns/auroradns/auroradns.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("aurora: the configuration of the DNS provider is nil")
}
if config.UserID == "" || config.Key == "" {
return nil, errors.New("aurora: some credentials information are missing")
}
if config.BaseURL == "" {
config.BaseURL = defaultBaseURL
}
tr, err := auroradns.NewTokenTransport(config.UserID, config.Key)
if err != nil {
return nil, fmt.Errorf("aurora: %v", err)
}
client, err := auroradns.NewClient(tr.Client(), auroradns.WithBaseURL(config.BaseURL))
if err != nil {
return nil, fmt.Errorf("aurora: %v", err)
}
return &DNSProvider{
config: config,
client: client,
recordIDs: make(map[string]string),
}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("aurora: the configuration of the DNS provider is nil")
}
if config.UserID == "" || config.Key == "" {
return nil, errors.New("aurora: some credentials information are missing")
}
if config.BaseURL == "" {
config.BaseURL = defaultBaseURL
}
tr, err := auroradns.NewTokenTransport(config.UserID, config.Key)
if err != nil {
return nil, fmt.Errorf("aurora: %v", err)
}
client, err := auroradns.NewClient(tr.Client(), auroradns.WithBaseURL(config.BaseURL))
if err != nil {
return nil, fmt.Errorf("aurora: %v", err)
}
return &DNSProvider{
config: config,
client: client,
recordIDs: make(map[string]string),
}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"UserID",
"==",
"\"",
"\"",
"||",
"config",
".",
"Key",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"BaseURL",
"==",
"\"",
"\"",
"{",
"config",
".",
"BaseURL",
"=",
"defaultBaseURL",
"\n",
"}",
"\n\n",
"tr",
",",
"err",
":=",
"auroradns",
".",
"NewTokenTransport",
"(",
"config",
".",
"UserID",
",",
"config",
".",
"Key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"auroradns",
".",
"NewClient",
"(",
"tr",
".",
"Client",
"(",
")",
",",
"auroradns",
".",
"WithBaseURL",
"(",
"config",
".",
"BaseURL",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"client",
",",
"recordIDs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for AuroraDNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"AuroraDNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/auroradns/auroradns.go#L62-L90 | train |
go-acme/lego | providers/dns/auroradns/auroradns.go | Present | func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return fmt.Errorf("aurora: could not determine zone for domain: '%s'. %s", domain, err)
}
// 1. Aurora will happily create the TXT record when it is provided a fqdn,
// but it will only appear in the control panel and will not be
// propagated to DNS servers. Extract and use subdomain instead.
// 2. A trailing dot in the fqdn will cause Aurora to add a trailing dot to
// the subdomain, resulting in _acme-challenge..<domain> rather
// than _acme-challenge.<domain>
subdomain := fqdn[0 : len(fqdn)-len(authZone)-1]
authZone = dns01.UnFqdn(authZone)
zone, err := d.getZoneInformationByName(authZone)
if err != nil {
return fmt.Errorf("aurora: could not create record: %v", err)
}
record := auroradns.Record{
RecordType: "TXT",
Name: subdomain,
Content: value,
TTL: d.config.TTL,
}
newRecord, _, err := d.client.CreateRecord(zone.ID, record)
if err != nil {
return fmt.Errorf("aurora: could not create record: %v", err)
}
d.recordIDsMu.Lock()
d.recordIDs[fqdn] = newRecord.ID
d.recordIDsMu.Unlock()
return nil
} | go | func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return fmt.Errorf("aurora: could not determine zone for domain: '%s'. %s", domain, err)
}
// 1. Aurora will happily create the TXT record when it is provided a fqdn,
// but it will only appear in the control panel and will not be
// propagated to DNS servers. Extract and use subdomain instead.
// 2. A trailing dot in the fqdn will cause Aurora to add a trailing dot to
// the subdomain, resulting in _acme-challenge..<domain> rather
// than _acme-challenge.<domain>
subdomain := fqdn[0 : len(fqdn)-len(authZone)-1]
authZone = dns01.UnFqdn(authZone)
zone, err := d.getZoneInformationByName(authZone)
if err != nil {
return fmt.Errorf("aurora: could not create record: %v", err)
}
record := auroradns.Record{
RecordType: "TXT",
Name: subdomain,
Content: value,
TTL: d.config.TTL,
}
newRecord, _, err := d.client.CreateRecord(zone.ID, record)
if err != nil {
return fmt.Errorf("aurora: could not create record: %v", err)
}
d.recordIDsMu.Lock()
d.recordIDs[fqdn] = newRecord.ID
d.recordIDsMu.Unlock()
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"Present",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"value",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"dns01",
".",
"ToFqdn",
"(",
"domain",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"domain",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// 1. Aurora will happily create the TXT record when it is provided a fqdn,",
"// but it will only appear in the control panel and will not be",
"// propagated to DNS servers. Extract and use subdomain instead.",
"// 2. A trailing dot in the fqdn will cause Aurora to add a trailing dot to",
"// the subdomain, resulting in _acme-challenge..<domain> rather",
"// than _acme-challenge.<domain>",
"subdomain",
":=",
"fqdn",
"[",
"0",
":",
"len",
"(",
"fqdn",
")",
"-",
"len",
"(",
"authZone",
")",
"-",
"1",
"]",
"\n\n",
"authZone",
"=",
"dns01",
".",
"UnFqdn",
"(",
"authZone",
")",
"\n\n",
"zone",
",",
"err",
":=",
"d",
".",
"getZoneInformationByName",
"(",
"authZone",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"record",
":=",
"auroradns",
".",
"Record",
"{",
"RecordType",
":",
"\"",
"\"",
",",
"Name",
":",
"subdomain",
",",
"Content",
":",
"value",
",",
"TTL",
":",
"d",
".",
"config",
".",
"TTL",
",",
"}",
"\n\n",
"newRecord",
",",
"_",
",",
"err",
":=",
"d",
".",
"client",
".",
"CreateRecord",
"(",
"zone",
".",
"ID",
",",
"record",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"d",
".",
"recordIDsMu",
".",
"Lock",
"(",
")",
"\n",
"d",
".",
"recordIDs",
"[",
"fqdn",
"]",
"=",
"newRecord",
".",
"ID",
"\n",
"d",
".",
"recordIDsMu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Present creates a record with a secret | [
"Present",
"creates",
"a",
"record",
"with",
"a",
"secret"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/auroradns/auroradns.go#L93-L134 | train |
go-acme/lego | providers/dns/auroradns/auroradns.go | CleanUp | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
d.recordIDsMu.Lock()
recordID, ok := d.recordIDs[fqdn]
d.recordIDsMu.Unlock()
if !ok {
return fmt.Errorf("unknown recordID for %q", fqdn)
}
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return fmt.Errorf("could not determine zone for domain: %q. %v", domain, err)
}
authZone = dns01.UnFqdn(authZone)
zone, err := d.getZoneInformationByName(authZone)
if err != nil {
return err
}
_, _, err = d.client.DeleteRecord(zone.ID, recordID)
if err != nil {
return err
}
d.recordIDsMu.Lock()
delete(d.recordIDs, fqdn)
d.recordIDsMu.Unlock()
return nil
} | go | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
d.recordIDsMu.Lock()
recordID, ok := d.recordIDs[fqdn]
d.recordIDsMu.Unlock()
if !ok {
return fmt.Errorf("unknown recordID for %q", fqdn)
}
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return fmt.Errorf("could not determine zone for domain: %q. %v", domain, err)
}
authZone = dns01.UnFqdn(authZone)
zone, err := d.getZoneInformationByName(authZone)
if err != nil {
return err
}
_, _, err = d.client.DeleteRecord(zone.ID, recordID)
if err != nil {
return err
}
d.recordIDsMu.Lock()
delete(d.recordIDs, fqdn)
d.recordIDsMu.Unlock()
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"CleanUp",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"_",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"d",
".",
"recordIDsMu",
".",
"Lock",
"(",
")",
"\n",
"recordID",
",",
"ok",
":=",
"d",
".",
"recordIDs",
"[",
"fqdn",
"]",
"\n",
"d",
".",
"recordIDsMu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fqdn",
")",
"\n",
"}",
"\n\n",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"dns01",
".",
"ToFqdn",
"(",
"domain",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"domain",
",",
"err",
")",
"\n",
"}",
"\n\n",
"authZone",
"=",
"dns01",
".",
"UnFqdn",
"(",
"authZone",
")",
"\n\n",
"zone",
",",
"err",
":=",
"d",
".",
"getZoneInformationByName",
"(",
"authZone",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"_",
",",
"err",
"=",
"d",
".",
"client",
".",
"DeleteRecord",
"(",
"zone",
".",
"ID",
",",
"recordID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"d",
".",
"recordIDsMu",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"d",
".",
"recordIDs",
",",
"fqdn",
")",
"\n",
"d",
".",
"recordIDsMu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CleanUp removes a given record that was generated by Present | [
"CleanUp",
"removes",
"a",
"given",
"record",
"that",
"was",
"generated",
"by",
"Present"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/auroradns/auroradns.go#L137-L170 | train |
go-acme/lego | providers/dns/namedotcom/namedotcom.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("namedotcom: the configuration of the DNS provider is nil")
}
if config.Username == "" {
return nil, fmt.Errorf("namedotcom: username is required")
}
if config.APIToken == "" {
return nil, fmt.Errorf("namedotcom: API token is required")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("namedotcom: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
client := namecom.New(config.Username, config.APIToken)
client.Client = config.HTTPClient
if config.Server != "" {
client.Server = config.Server
}
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("namedotcom: the configuration of the DNS provider is nil")
}
if config.Username == "" {
return nil, fmt.Errorf("namedotcom: username is required")
}
if config.APIToken == "" {
return nil, fmt.Errorf("namedotcom: API token is required")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("namedotcom: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
client := namecom.New(config.Username, config.APIToken)
client.Client = config.HTTPClient
if config.Server != "" {
client.Server = config.Server
}
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Username",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIToken",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"TTL",
"<",
"minTTL",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"config",
".",
"TTL",
",",
"minTTL",
")",
"\n",
"}",
"\n\n",
"client",
":=",
"namecom",
".",
"New",
"(",
"config",
".",
"Username",
",",
"config",
".",
"APIToken",
")",
"\n",
"client",
".",
"Client",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"if",
"config",
".",
"Server",
"!=",
"\"",
"\"",
"{",
"client",
".",
"Server",
"=",
"config",
".",
"Server",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for namedotcom. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"namedotcom",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/namedotcom/namedotcom.go#L66-L91 | train |
go-acme/lego | providers/dns/azure/azure.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("azure: the configuration of the DNS provider is nil")
}
if config.HTTPClient == nil {
config.HTTPClient = http.DefaultClient
}
authorizer, err := getAuthorizer(config)
if err != nil {
return nil, err
}
if config.SubscriptionID == "" {
subsID, err := getMetadata(config, "subscriptionId")
if err != nil {
return nil, fmt.Errorf("azure: %v", err)
}
if subsID == "" {
return nil, errors.New("azure: SubscriptionID is missing")
}
config.SubscriptionID = subsID
}
if config.ResourceGroup == "" {
resGroup, err := getMetadata(config, "resourceGroupName")
if err != nil {
return nil, fmt.Errorf("azure: %v", err)
}
if resGroup == "" {
return nil, errors.New("azure: ResourceGroup is missing")
}
config.ResourceGroup = resGroup
}
return &DNSProvider{config: config, authorizer: authorizer}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("azure: the configuration of the DNS provider is nil")
}
if config.HTTPClient == nil {
config.HTTPClient = http.DefaultClient
}
authorizer, err := getAuthorizer(config)
if err != nil {
return nil, err
}
if config.SubscriptionID == "" {
subsID, err := getMetadata(config, "subscriptionId")
if err != nil {
return nil, fmt.Errorf("azure: %v", err)
}
if subsID == "" {
return nil, errors.New("azure: SubscriptionID is missing")
}
config.SubscriptionID = subsID
}
if config.ResourceGroup == "" {
resGroup, err := getMetadata(config, "resourceGroupName")
if err != nil {
return nil, fmt.Errorf("azure: %v", err)
}
if resGroup == "" {
return nil, errors.New("azure: ResourceGroup is missing")
}
config.ResourceGroup = resGroup
}
return &DNSProvider{config: config, authorizer: authorizer}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"HTTPClient",
"==",
"nil",
"{",
"config",
".",
"HTTPClient",
"=",
"http",
".",
"DefaultClient",
"\n",
"}",
"\n\n",
"authorizer",
",",
"err",
":=",
"getAuthorizer",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"SubscriptionID",
"==",
"\"",
"\"",
"{",
"subsID",
",",
"err",
":=",
"getMetadata",
"(",
"config",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"subsID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"config",
".",
"SubscriptionID",
"=",
"subsID",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"ResourceGroup",
"==",
"\"",
"\"",
"{",
"resGroup",
",",
"err",
":=",
"getMetadata",
"(",
"config",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"resGroup",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"config",
".",
"ResourceGroup",
"=",
"resGroup",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"authorizer",
":",
"authorizer",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for Azure. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Azure",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/azure/azure.go#L75-L114 | train |
go-acme/lego | providers/dns/azure/azure.go | getHostedZoneID | func (d *DNSProvider) getHostedZoneID(ctx context.Context, fqdn string) (string, error) {
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return "", err
}
dc := dns.NewZonesClient(d.config.SubscriptionID)
dc.Authorizer = d.authorizer
zone, err := dc.Get(ctx, d.config.ResourceGroup, dns01.UnFqdn(authZone))
if err != nil {
return "", err
}
// zone.Name shouldn't have a trailing dot(.)
return to.String(zone.Name), nil
} | go | func (d *DNSProvider) getHostedZoneID(ctx context.Context, fqdn string) (string, error) {
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return "", err
}
dc := dns.NewZonesClient(d.config.SubscriptionID)
dc.Authorizer = d.authorizer
zone, err := dc.Get(ctx, d.config.ResourceGroup, dns01.UnFqdn(authZone))
if err != nil {
return "", err
}
// zone.Name shouldn't have a trailing dot(.)
return to.String(zone.Name), nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"getHostedZoneID",
"(",
"ctx",
"context",
".",
"Context",
",",
"fqdn",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"fqdn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"dc",
":=",
"dns",
".",
"NewZonesClient",
"(",
"d",
".",
"config",
".",
"SubscriptionID",
")",
"\n",
"dc",
".",
"Authorizer",
"=",
"d",
".",
"authorizer",
"\n\n",
"zone",
",",
"err",
":=",
"dc",
".",
"Get",
"(",
"ctx",
",",
"d",
".",
"config",
".",
"ResourceGroup",
",",
"dns01",
".",
"UnFqdn",
"(",
"authZone",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"// zone.Name shouldn't have a trailing dot(.)",
"return",
"to",
".",
"String",
"(",
"zone",
".",
"Name",
")",
",",
"nil",
"\n",
"}"
] | // Checks that azure has a zone for this domain name. | [
"Checks",
"that",
"azure",
"has",
"a",
"zone",
"for",
"this",
"domain",
"name",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/azure/azure.go#L199-L215 | train |
go-acme/lego | providers/dns/azure/azure.go | toRelativeRecord | func toRelativeRecord(domain, zone string) string {
return dns01.UnFqdn(strings.TrimSuffix(domain, zone))
} | go | func toRelativeRecord(domain, zone string) string {
return dns01.UnFqdn(strings.TrimSuffix(domain, zone))
} | [
"func",
"toRelativeRecord",
"(",
"domain",
",",
"zone",
"string",
")",
"string",
"{",
"return",
"dns01",
".",
"UnFqdn",
"(",
"strings",
".",
"TrimSuffix",
"(",
"domain",
",",
"zone",
")",
")",
"\n",
"}"
] | // Returns the relative record to the domain | [
"Returns",
"the",
"relative",
"record",
"to",
"the",
"domain"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/azure/azure.go#L218-L220 | train |
go-acme/lego | acme/api/account.go | New | func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) {
var account acme.Account
resp, err := a.core.post(a.core.GetDirectory().NewAccountURL, req, &account)
location := getLocation(resp)
if len(location) > 0 {
a.core.jws.SetKid(location)
}
if err != nil {
return acme.ExtendedAccount{Location: location}, err
}
return acme.ExtendedAccount{Account: account, Location: location}, nil
} | go | func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) {
var account acme.Account
resp, err := a.core.post(a.core.GetDirectory().NewAccountURL, req, &account)
location := getLocation(resp)
if len(location) > 0 {
a.core.jws.SetKid(location)
}
if err != nil {
return acme.ExtendedAccount{Location: location}, err
}
return acme.ExtendedAccount{Account: account, Location: location}, nil
} | [
"func",
"(",
"a",
"*",
"AccountService",
")",
"New",
"(",
"req",
"acme",
".",
"Account",
")",
"(",
"acme",
".",
"ExtendedAccount",
",",
"error",
")",
"{",
"var",
"account",
"acme",
".",
"Account",
"\n",
"resp",
",",
"err",
":=",
"a",
".",
"core",
".",
"post",
"(",
"a",
".",
"core",
".",
"GetDirectory",
"(",
")",
".",
"NewAccountURL",
",",
"req",
",",
"&",
"account",
")",
"\n",
"location",
":=",
"getLocation",
"(",
"resp",
")",
"\n\n",
"if",
"len",
"(",
"location",
")",
">",
"0",
"{",
"a",
".",
"core",
".",
"jws",
".",
"SetKid",
"(",
"location",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"ExtendedAccount",
"{",
"Location",
":",
"location",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"acme",
".",
"ExtendedAccount",
"{",
"Account",
":",
"account",
",",
"Location",
":",
"location",
"}",
",",
"nil",
"\n",
"}"
] | // New Creates a new account. | [
"New",
"Creates",
"a",
"new",
"account",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/account.go#L14-L28 | train |
go-acme/lego | acme/api/account.go | NewEAB | func (a *AccountService) NewEAB(accMsg acme.Account, kid string, hmacEncoded string) (acme.ExtendedAccount, error) {
hmac, err := base64.RawURLEncoding.DecodeString(hmacEncoded)
if err != nil {
return acme.ExtendedAccount{}, fmt.Errorf("acme: could not decode hmac key: %v", err)
}
eabJWS, err := a.core.signEABContent(a.core.GetDirectory().NewAccountURL, kid, hmac)
if err != nil {
return acme.ExtendedAccount{}, fmt.Errorf("acme: error signing eab content: %v", err)
}
accMsg.ExternalAccountBinding = eabJWS
return a.New(accMsg)
} | go | func (a *AccountService) NewEAB(accMsg acme.Account, kid string, hmacEncoded string) (acme.ExtendedAccount, error) {
hmac, err := base64.RawURLEncoding.DecodeString(hmacEncoded)
if err != nil {
return acme.ExtendedAccount{}, fmt.Errorf("acme: could not decode hmac key: %v", err)
}
eabJWS, err := a.core.signEABContent(a.core.GetDirectory().NewAccountURL, kid, hmac)
if err != nil {
return acme.ExtendedAccount{}, fmt.Errorf("acme: error signing eab content: %v", err)
}
accMsg.ExternalAccountBinding = eabJWS
return a.New(accMsg)
} | [
"func",
"(",
"a",
"*",
"AccountService",
")",
"NewEAB",
"(",
"accMsg",
"acme",
".",
"Account",
",",
"kid",
"string",
",",
"hmacEncoded",
"string",
")",
"(",
"acme",
".",
"ExtendedAccount",
",",
"error",
")",
"{",
"hmac",
",",
"err",
":=",
"base64",
".",
"RawURLEncoding",
".",
"DecodeString",
"(",
"hmacEncoded",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"ExtendedAccount",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"eabJWS",
",",
"err",
":=",
"a",
".",
"core",
".",
"signEABContent",
"(",
"a",
".",
"core",
".",
"GetDirectory",
"(",
")",
".",
"NewAccountURL",
",",
"kid",
",",
"hmac",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"ExtendedAccount",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"accMsg",
".",
"ExternalAccountBinding",
"=",
"eabJWS",
"\n\n",
"return",
"a",
".",
"New",
"(",
"accMsg",
")",
"\n",
"}"
] | // NewEAB Creates a new account with an External Account Binding. | [
"NewEAB",
"Creates",
"a",
"new",
"account",
"with",
"an",
"External",
"Account",
"Binding",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/account.go#L31-L44 | train |
go-acme/lego | acme/api/account.go | Get | func (a *AccountService) Get(accountURL string) (acme.Account, error) {
if len(accountURL) == 0 {
return acme.Account{}, errors.New("account[get]: empty URL")
}
var account acme.Account
_, err := a.core.post(accountURL, acme.Account{}, &account)
if err != nil {
return acme.Account{}, err
}
return account, nil
} | go | func (a *AccountService) Get(accountURL string) (acme.Account, error) {
if len(accountURL) == 0 {
return acme.Account{}, errors.New("account[get]: empty URL")
}
var account acme.Account
_, err := a.core.post(accountURL, acme.Account{}, &account)
if err != nil {
return acme.Account{}, err
}
return account, nil
} | [
"func",
"(",
"a",
"*",
"AccountService",
")",
"Get",
"(",
"accountURL",
"string",
")",
"(",
"acme",
".",
"Account",
",",
"error",
")",
"{",
"if",
"len",
"(",
"accountURL",
")",
"==",
"0",
"{",
"return",
"acme",
".",
"Account",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"account",
"acme",
".",
"Account",
"\n",
"_",
",",
"err",
":=",
"a",
".",
"core",
".",
"post",
"(",
"accountURL",
",",
"acme",
".",
"Account",
"{",
"}",
",",
"&",
"account",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"Account",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"account",
",",
"nil",
"\n",
"}"
] | // Get Retrieves an account. | [
"Get",
"Retrieves",
"an",
"account",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/account.go#L47-L58 | train |
go-acme/lego | acme/api/account.go | Deactivate | func (a *AccountService) Deactivate(accountURL string) error {
if len(accountURL) == 0 {
return errors.New("account[deactivate]: empty URL")
}
req := acme.Account{Status: acme.StatusDeactivated}
_, err := a.core.post(accountURL, req, nil)
return err
} | go | func (a *AccountService) Deactivate(accountURL string) error {
if len(accountURL) == 0 {
return errors.New("account[deactivate]: empty URL")
}
req := acme.Account{Status: acme.StatusDeactivated}
_, err := a.core.post(accountURL, req, nil)
return err
} | [
"func",
"(",
"a",
"*",
"AccountService",
")",
"Deactivate",
"(",
"accountURL",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"accountURL",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"req",
":=",
"acme",
".",
"Account",
"{",
"Status",
":",
"acme",
".",
"StatusDeactivated",
"}",
"\n",
"_",
",",
"err",
":=",
"a",
".",
"core",
".",
"post",
"(",
"accountURL",
",",
"req",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Deactivate Deactivates an account. | [
"Deactivate",
"Deactivates",
"an",
"account",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/account.go#L61-L69 | train |
go-acme/lego | acme/api/certificate.go | Get | func (c *CertificateService) Get(certURL string, bundle bool) ([]byte, []byte, error) {
cert, up, err := c.get(certURL)
if err != nil {
return nil, nil, err
}
// Get issuerCert from bundled response from Let's Encrypt
// See https://community.letsencrypt.org/t/acme-v2-no-up-link-in-response/64962
_, issuer := pem.Decode(cert)
if issuer != nil {
return cert, issuer, nil
}
issuer, err = c.getIssuerFromLink(up)
if err != nil {
// If we fail to acquire the issuer cert, return the issued certificate - do not fail.
log.Warnf("acme: Could not bundle issuer certificate [%s]: %v", certURL, err)
} else if len(issuer) > 0 {
// If bundle is true, we want to return a certificate bundle.
// To do this, we append the issuer cert to the issued cert.
if bundle {
cert = append(cert, issuer...)
}
}
return cert, issuer, nil
} | go | func (c *CertificateService) Get(certURL string, bundle bool) ([]byte, []byte, error) {
cert, up, err := c.get(certURL)
if err != nil {
return nil, nil, err
}
// Get issuerCert from bundled response from Let's Encrypt
// See https://community.letsencrypt.org/t/acme-v2-no-up-link-in-response/64962
_, issuer := pem.Decode(cert)
if issuer != nil {
return cert, issuer, nil
}
issuer, err = c.getIssuerFromLink(up)
if err != nil {
// If we fail to acquire the issuer cert, return the issued certificate - do not fail.
log.Warnf("acme: Could not bundle issuer certificate [%s]: %v", certURL, err)
} else if len(issuer) > 0 {
// If bundle is true, we want to return a certificate bundle.
// To do this, we append the issuer cert to the issued cert.
if bundle {
cert = append(cert, issuer...)
}
}
return cert, issuer, nil
} | [
"func",
"(",
"c",
"*",
"CertificateService",
")",
"Get",
"(",
"certURL",
"string",
",",
"bundle",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cert",
",",
"up",
",",
"err",
":=",
"c",
".",
"get",
"(",
"certURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Get issuerCert from bundled response from Let's Encrypt",
"// See https://community.letsencrypt.org/t/acme-v2-no-up-link-in-response/64962",
"_",
",",
"issuer",
":=",
"pem",
".",
"Decode",
"(",
"cert",
")",
"\n",
"if",
"issuer",
"!=",
"nil",
"{",
"return",
"cert",
",",
"issuer",
",",
"nil",
"\n",
"}",
"\n\n",
"issuer",
",",
"err",
"=",
"c",
".",
"getIssuerFromLink",
"(",
"up",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// If we fail to acquire the issuer cert, return the issued certificate - do not fail.",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"certURL",
",",
"err",
")",
"\n",
"}",
"else",
"if",
"len",
"(",
"issuer",
")",
">",
"0",
"{",
"// If bundle is true, we want to return a certificate bundle.",
"// To do this, we append the issuer cert to the issued cert.",
"if",
"bundle",
"{",
"cert",
"=",
"append",
"(",
"cert",
",",
"issuer",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"cert",
",",
"issuer",
",",
"nil",
"\n",
"}"
] | // Get Returns the certificate and the issuer certificate.
// 'bundle' is only applied if the issuer is provided by the 'up' link. | [
"Get",
"Returns",
"the",
"certificate",
"and",
"the",
"issuer",
"certificate",
".",
"bundle",
"is",
"only",
"applied",
"if",
"the",
"issuer",
"is",
"provided",
"by",
"the",
"up",
"link",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/certificate.go#L22-L48 | train |
go-acme/lego | acme/api/certificate.go | Revoke | func (c *CertificateService) Revoke(req acme.RevokeCertMessage) error {
_, err := c.core.post(c.core.GetDirectory().RevokeCertURL, req, nil)
return err
} | go | func (c *CertificateService) Revoke(req acme.RevokeCertMessage) error {
_, err := c.core.post(c.core.GetDirectory().RevokeCertURL, req, nil)
return err
} | [
"func",
"(",
"c",
"*",
"CertificateService",
")",
"Revoke",
"(",
"req",
"acme",
".",
"RevokeCertMessage",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"core",
".",
"post",
"(",
"c",
".",
"core",
".",
"GetDirectory",
"(",
")",
".",
"RevokeCertURL",
",",
"req",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Revoke Revokes a certificate. | [
"Revoke",
"Revokes",
"a",
"certificate",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/certificate.go#L51-L54 | train |
go-acme/lego | acme/api/certificate.go | get | func (c *CertificateService) get(certURL string) ([]byte, string, error) {
if len(certURL) == 0 {
return nil, "", errors.New("certificate[get]: empty URL")
}
resp, err := c.core.postAsGet(certURL, nil)
if err != nil {
return nil, "", err
}
cert, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil {
return nil, "", err
}
// The issuer certificate link may be supplied via an "up" link
// in the response headers of a new certificate.
// See https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.4.2
up := getLink(resp.Header, "up")
return cert, up, err
} | go | func (c *CertificateService) get(certURL string) ([]byte, string, error) {
if len(certURL) == 0 {
return nil, "", errors.New("certificate[get]: empty URL")
}
resp, err := c.core.postAsGet(certURL, nil)
if err != nil {
return nil, "", err
}
cert, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil {
return nil, "", err
}
// The issuer certificate link may be supplied via an "up" link
// in the response headers of a new certificate.
// See https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.4.2
up := getLink(resp.Header, "up")
return cert, up, err
} | [
"func",
"(",
"c",
"*",
"CertificateService",
")",
"get",
"(",
"certURL",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"certURL",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"c",
".",
"core",
".",
"postAsGet",
"(",
"certURL",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"cert",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"http",
".",
"MaxBytesReader",
"(",
"nil",
",",
"resp",
".",
"Body",
",",
"maxBodySize",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"// The issuer certificate link may be supplied via an \"up\" link",
"// in the response headers of a new certificate.",
"// See https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.4.2",
"up",
":=",
"getLink",
"(",
"resp",
".",
"Header",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"cert",
",",
"up",
",",
"err",
"\n",
"}"
] | // get Returns the certificate and the "up" link. | [
"get",
"Returns",
"the",
"certificate",
"and",
"the",
"up",
"link",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/certificate.go#L57-L78 | train |
go-acme/lego | acme/api/certificate.go | getIssuerFromLink | func (c *CertificateService) getIssuerFromLink(up string) ([]byte, error) {
if len(up) == 0 {
return nil, nil
}
log.Infof("acme: Requesting issuer cert from %s", up)
cert, _, err := c.get(up)
if err != nil {
return nil, err
}
_, err = x509.ParseCertificate(cert)
if err != nil {
return nil, err
}
return certcrypto.PEMEncode(certcrypto.DERCertificateBytes(cert)), nil
} | go | func (c *CertificateService) getIssuerFromLink(up string) ([]byte, error) {
if len(up) == 0 {
return nil, nil
}
log.Infof("acme: Requesting issuer cert from %s", up)
cert, _, err := c.get(up)
if err != nil {
return nil, err
}
_, err = x509.ParseCertificate(cert)
if err != nil {
return nil, err
}
return certcrypto.PEMEncode(certcrypto.DERCertificateBytes(cert)), nil
} | [
"func",
"(",
"c",
"*",
"CertificateService",
")",
"getIssuerFromLink",
"(",
"up",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"up",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"up",
")",
"\n\n",
"cert",
",",
"_",
",",
"err",
":=",
"c",
".",
"get",
"(",
"up",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"x509",
".",
"ParseCertificate",
"(",
"cert",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"certcrypto",
".",
"PEMEncode",
"(",
"certcrypto",
".",
"DERCertificateBytes",
"(",
"cert",
")",
")",
",",
"nil",
"\n",
"}"
] | // getIssuerFromLink requests the issuer certificate | [
"getIssuerFromLink",
"requests",
"the",
"issuer",
"certificate"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/certificate.go#L81-L99 | train |
go-acme/lego | providers/dns/cloudns/cloudns.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ClouDNS: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.AuthID, config.AuthPassword)
if err != nil {
return nil, fmt.Errorf("ClouDNS: %v", err)
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ClouDNS: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.AuthID, config.AuthPassword)
if err != nil {
return nil, fmt.Errorf("ClouDNS: %v", err)
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"internal",
".",
"NewClient",
"(",
"config",
".",
"AuthID",
",",
"config",
".",
"AuthPassword",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"client",
".",
"HTTPClient",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for ClouDNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"ClouDNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/cloudns/cloudns.go#L60-L73 | train |
go-acme/lego | providers/dns/vscale/vscale.go | NewDefaultConfig | func NewDefaultConfig() *Config {
return &Config{
BaseURL: env.GetOrDefaultString(baseURLEnvVar, defaultBaseURL),
TTL: env.GetOrDefaultInt(ttlEnvVar, minTTL),
PropagationTimeout: env.GetOrDefaultSecond(propagationTimeoutEnvVar, 120*time.Second),
PollingInterval: env.GetOrDefaultSecond(pollingIntervalEnvVar, 2*time.Second),
HTTPClient: &http.Client{
Timeout: env.GetOrDefaultSecond(httpTimeoutEnvVar, 30*time.Second),
},
}
} | go | func NewDefaultConfig() *Config {
return &Config{
BaseURL: env.GetOrDefaultString(baseURLEnvVar, defaultBaseURL),
TTL: env.GetOrDefaultInt(ttlEnvVar, minTTL),
PropagationTimeout: env.GetOrDefaultSecond(propagationTimeoutEnvVar, 120*time.Second),
PollingInterval: env.GetOrDefaultSecond(pollingIntervalEnvVar, 2*time.Second),
HTTPClient: &http.Client{
Timeout: env.GetOrDefaultSecond(httpTimeoutEnvVar, 30*time.Second),
},
}
} | [
"func",
"NewDefaultConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"BaseURL",
":",
"env",
".",
"GetOrDefaultString",
"(",
"baseURLEnvVar",
",",
"defaultBaseURL",
")",
",",
"TTL",
":",
"env",
".",
"GetOrDefaultInt",
"(",
"ttlEnvVar",
",",
"minTTL",
")",
",",
"PropagationTimeout",
":",
"env",
".",
"GetOrDefaultSecond",
"(",
"propagationTimeoutEnvVar",
",",
"120",
"*",
"time",
".",
"Second",
")",
",",
"PollingInterval",
":",
"env",
".",
"GetOrDefaultSecond",
"(",
"pollingIntervalEnvVar",
",",
"2",
"*",
"time",
".",
"Second",
")",
",",
"HTTPClient",
":",
"&",
"http",
".",
"Client",
"{",
"Timeout",
":",
"env",
".",
"GetOrDefaultSecond",
"(",
"httpTimeoutEnvVar",
",",
"30",
"*",
"time",
".",
"Second",
")",
",",
"}",
",",
"}",
"\n",
"}"
] | // NewDefaultConfig returns a default configuration for the DNSProvider. | [
"NewDefaultConfig",
"returns",
"a",
"default",
"configuration",
"for",
"the",
"DNSProvider",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/vscale/vscale.go#L44-L54 | train |
go-acme/lego | providers/dns/vscale/vscale.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("vscale: the configuration of the DNS provider is nil")
}
if config.Token == "" {
return nil, errors.New("vscale: credentials missing")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("vscale: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
client := internal.NewClient(internal.ClientOpts{
BaseURL: config.BaseURL,
Token: config.Token,
HTTPClient: config.HTTPClient,
})
return &DNSProvider{config: config, client: client}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("vscale: the configuration of the DNS provider is nil")
}
if config.Token == "" {
return nil, errors.New("vscale: credentials missing")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("vscale: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
client := internal.NewClient(internal.ClientOpts{
BaseURL: config.BaseURL,
Token: config.Token,
HTTPClient: config.HTTPClient,
})
return &DNSProvider{config: config, client: client}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Token",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"TTL",
"<",
"minTTL",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"config",
".",
"TTL",
",",
"minTTL",
")",
"\n",
"}",
"\n\n",
"client",
":=",
"internal",
".",
"NewClient",
"(",
"internal",
".",
"ClientOpts",
"{",
"BaseURL",
":",
"config",
".",
"BaseURL",
",",
"Token",
":",
"config",
".",
"Token",
",",
"HTTPClient",
":",
"config",
".",
"HTTPClient",
",",
"}",
")",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"client",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for Vscale. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Vscale",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/vscale/vscale.go#L77-L97 | train |
go-acme/lego | providers/dns/vscale/vscale.go | Present | func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
domainObj, err := d.client.GetDomainByName(domain)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
txtRecord := internal.Record{
Type: "TXT",
TTL: d.config.TTL,
Name: fqdn,
Content: value,
}
_, err = d.client.AddRecord(domainObj.ID, txtRecord)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
return nil
} | go | func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
domainObj, err := d.client.GetDomainByName(domain)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
txtRecord := internal.Record{
Type: "TXT",
TTL: d.config.TTL,
Name: fqdn,
Content: value,
}
_, err = d.client.AddRecord(domainObj.ID, txtRecord)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"Present",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"value",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"domainObj",
",",
"err",
":=",
"d",
".",
"client",
".",
"GetDomainByName",
"(",
"domain",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"txtRecord",
":=",
"internal",
".",
"Record",
"{",
"Type",
":",
"\"",
"\"",
",",
"TTL",
":",
"d",
".",
"config",
".",
"TTL",
",",
"Name",
":",
"fqdn",
",",
"Content",
":",
"value",
",",
"}",
"\n",
"_",
",",
"err",
"=",
"d",
".",
"client",
".",
"AddRecord",
"(",
"domainObj",
".",
"ID",
",",
"txtRecord",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Present creates a TXT record to fulfill DNS-01 challenge. | [
"Present",
"creates",
"a",
"TXT",
"record",
"to",
"fulfill",
"DNS",
"-",
"01",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/vscale/vscale.go#L106-L126 | train |
go-acme/lego | providers/dns/vscale/vscale.go | CleanUp | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
recordName := dns01.UnFqdn(fqdn)
domainObj, err := d.client.GetDomainByName(domain)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
records, err := d.client.ListRecords(domainObj.ID)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
// Delete records with specific FQDN
var lastErr error
for _, record := range records {
if record.Name == recordName {
err = d.client.DeleteRecord(domainObj.ID, record.ID)
if err != nil {
lastErr = fmt.Errorf("vscale: %v", err)
}
}
}
return lastErr
} | go | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)
recordName := dns01.UnFqdn(fqdn)
domainObj, err := d.client.GetDomainByName(domain)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
records, err := d.client.ListRecords(domainObj.ID)
if err != nil {
return fmt.Errorf("vscale: %v", err)
}
// Delete records with specific FQDN
var lastErr error
for _, record := range records {
if record.Name == recordName {
err = d.client.DeleteRecord(domainObj.ID, record.ID)
if err != nil {
lastErr = fmt.Errorf("vscale: %v", err)
}
}
}
return lastErr
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"CleanUp",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"_",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n",
"recordName",
":=",
"dns01",
".",
"UnFqdn",
"(",
"fqdn",
")",
"\n\n",
"domainObj",
",",
"err",
":=",
"d",
".",
"client",
".",
"GetDomainByName",
"(",
"domain",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"records",
",",
"err",
":=",
"d",
".",
"client",
".",
"ListRecords",
"(",
"domainObj",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Delete records with specific FQDN",
"var",
"lastErr",
"error",
"\n",
"for",
"_",
",",
"record",
":=",
"range",
"records",
"{",
"if",
"record",
".",
"Name",
"==",
"recordName",
"{",
"err",
"=",
"d",
".",
"client",
".",
"DeleteRecord",
"(",
"domainObj",
".",
"ID",
",",
"record",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"lastErr",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"lastErr",
"\n",
"}"
] | // CleanUp removes a TXT record used for DNS-01 challenge. | [
"CleanUp",
"removes",
"a",
"TXT",
"record",
"used",
"for",
"DNS",
"-",
"01",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/vscale/vscale.go#L129-L155 | train |
go-acme/lego | providers/dns/alidns/alidns.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("alicloud: the configuration of the DNS provider is nil")
}
if config.APIKey == "" || config.SecretKey == "" {
return nil, fmt.Errorf("alicloud: credentials missing")
}
if len(config.RegionID) == 0 {
config.RegionID = defaultRegionID
}
conf := sdk.NewConfig().WithTimeout(config.HTTPTimeout)
credential := credentials.NewAccessKeyCredential(config.APIKey, config.SecretKey)
client, err := alidns.NewClientWithOptions(config.RegionID, conf, credential)
if err != nil {
return nil, fmt.Errorf("alicloud: credentials failed: %v", err)
}
return &DNSProvider{config: config, client: client}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("alicloud: the configuration of the DNS provider is nil")
}
if config.APIKey == "" || config.SecretKey == "" {
return nil, fmt.Errorf("alicloud: credentials missing")
}
if len(config.RegionID) == 0 {
config.RegionID = defaultRegionID
}
conf := sdk.NewConfig().WithTimeout(config.HTTPTimeout)
credential := credentials.NewAccessKeyCredential(config.APIKey, config.SecretKey)
client, err := alidns.NewClientWithOptions(config.RegionID, conf, credential)
if err != nil {
return nil, fmt.Errorf("alicloud: credentials failed: %v", err)
}
return &DNSProvider{config: config, client: client}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"||",
"config",
".",
"SecretKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"config",
".",
"RegionID",
")",
"==",
"0",
"{",
"config",
".",
"RegionID",
"=",
"defaultRegionID",
"\n",
"}",
"\n\n",
"conf",
":=",
"sdk",
".",
"NewConfig",
"(",
")",
".",
"WithTimeout",
"(",
"config",
".",
"HTTPTimeout",
")",
"\n",
"credential",
":=",
"credentials",
".",
"NewAccessKeyCredential",
"(",
"config",
".",
"APIKey",
",",
"config",
".",
"SecretKey",
")",
"\n\n",
"client",
",",
"err",
":=",
"alidns",
".",
"NewClientWithOptions",
"(",
"config",
".",
"RegionID",
",",
"conf",
",",
"credential",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"client",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for alidns. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"alidns",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/alidns/alidns.go#L64-L86 | train |
go-acme/lego | providers/dns/cloudxns/cloudxns.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("CloudXNS: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.APIKey, config.SecretKey)
if err != nil {
return nil, err
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("CloudXNS: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.APIKey, config.SecretKey)
if err != nil {
return nil, err
}
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"internal",
".",
"NewClient",
"(",
"config",
".",
"APIKey",
",",
"config",
".",
"SecretKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"client",
".",
"HTTPClient",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for CloudXNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"CloudXNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/cloudxns/cloudxns.go#L60-L73 | train |
go-acme/lego | acme/api/internal/nonces/nonce_manager.go | NewManager | func NewManager(do *sender.Doer, nonceURL string) *Manager {
return &Manager{
do: do,
nonceURL: nonceURL,
}
} | go | func NewManager(do *sender.Doer, nonceURL string) *Manager {
return &Manager{
do: do,
nonceURL: nonceURL,
}
} | [
"func",
"NewManager",
"(",
"do",
"*",
"sender",
".",
"Doer",
",",
"nonceURL",
"string",
")",
"*",
"Manager",
"{",
"return",
"&",
"Manager",
"{",
"do",
":",
"do",
",",
"nonceURL",
":",
"nonceURL",
",",
"}",
"\n",
"}"
] | // NewManager Creates a new Manager. | [
"NewManager",
"Creates",
"a",
"new",
"Manager",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/nonces/nonce_manager.go#L21-L26 | train |
go-acme/lego | acme/api/internal/nonces/nonce_manager.go | Pop | func (n *Manager) Pop() (string, bool) {
n.Lock()
defer n.Unlock()
if len(n.nonces) == 0 {
return "", false
}
nonce := n.nonces[len(n.nonces)-1]
n.nonces = n.nonces[:len(n.nonces)-1]
return nonce, true
} | go | func (n *Manager) Pop() (string, bool) {
n.Lock()
defer n.Unlock()
if len(n.nonces) == 0 {
return "", false
}
nonce := n.nonces[len(n.nonces)-1]
n.nonces = n.nonces[:len(n.nonces)-1]
return nonce, true
} | [
"func",
"(",
"n",
"*",
"Manager",
")",
"Pop",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"n",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"len",
"(",
"n",
".",
"nonces",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n\n",
"nonce",
":=",
"n",
".",
"nonces",
"[",
"len",
"(",
"n",
".",
"nonces",
")",
"-",
"1",
"]",
"\n",
"n",
".",
"nonces",
"=",
"n",
".",
"nonces",
"[",
":",
"len",
"(",
"n",
".",
"nonces",
")",
"-",
"1",
"]",
"\n",
"return",
"nonce",
",",
"true",
"\n",
"}"
] | // Pop Pops a nonce. | [
"Pop",
"Pops",
"a",
"nonce",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/nonces/nonce_manager.go#L29-L40 | train |
go-acme/lego | acme/api/internal/nonces/nonce_manager.go | Push | func (n *Manager) Push(nonce string) {
n.Lock()
defer n.Unlock()
n.nonces = append(n.nonces, nonce)
} | go | func (n *Manager) Push(nonce string) {
n.Lock()
defer n.Unlock()
n.nonces = append(n.nonces, nonce)
} | [
"func",
"(",
"n",
"*",
"Manager",
")",
"Push",
"(",
"nonce",
"string",
")",
"{",
"n",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"Unlock",
"(",
")",
"\n",
"n",
".",
"nonces",
"=",
"append",
"(",
"n",
".",
"nonces",
",",
"nonce",
")",
"\n",
"}"
] | // Push Pushes a nonce. | [
"Push",
"Pushes",
"a",
"nonce",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/nonces/nonce_manager.go#L43-L47 | train |
go-acme/lego | acme/api/internal/nonces/nonce_manager.go | Nonce | func (n *Manager) Nonce() (string, error) {
if nonce, ok := n.Pop(); ok {
return nonce, nil
}
return n.getNonce()
} | go | func (n *Manager) Nonce() (string, error) {
if nonce, ok := n.Pop(); ok {
return nonce, nil
}
return n.getNonce()
} | [
"func",
"(",
"n",
"*",
"Manager",
")",
"Nonce",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"nonce",
",",
"ok",
":=",
"n",
".",
"Pop",
"(",
")",
";",
"ok",
"{",
"return",
"nonce",
",",
"nil",
"\n",
"}",
"\n",
"return",
"n",
".",
"getNonce",
"(",
")",
"\n",
"}"
] | // Nonce implement jose.NonceSource | [
"Nonce",
"implement",
"jose",
".",
"NonceSource"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/nonces/nonce_manager.go#L50-L55 | train |
go-acme/lego | acme/api/internal/nonces/nonce_manager.go | GetFromResponse | func GetFromResponse(resp *http.Response) (string, error) {
if resp == nil {
return "", errors.New("nil response")
}
nonce := resp.Header.Get("Replay-Nonce")
if nonce == "" {
return "", fmt.Errorf("server did not respond with a proper nonce header")
}
return nonce, nil
} | go | func GetFromResponse(resp *http.Response) (string, error) {
if resp == nil {
return "", errors.New("nil response")
}
nonce := resp.Header.Get("Replay-Nonce")
if nonce == "" {
return "", fmt.Errorf("server did not respond with a proper nonce header")
}
return nonce, nil
} | [
"func",
"GetFromResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"nonce",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"nonce",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nonce",
",",
"nil",
"\n",
"}"
] | // GetFromResponse Extracts a nonce from a HTTP response. | [
"GetFromResponse",
"Extracts",
"a",
"nonce",
"from",
"a",
"HTTP",
"response",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/internal/nonces/nonce_manager.go#L67-L78 | train |
go-acme/lego | providers/dns/acmedns/acmedns.go | NewDNSProvider | func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(apiBaseEnvVar, storagePathEnvVar)
if err != nil {
return nil, fmt.Errorf("acme-dns: %v", err)
}
client := goacmedns.NewClient(values[apiBaseEnvVar])
storage := goacmedns.NewFileStorage(values[storagePathEnvVar], 0600)
return NewDNSProviderClient(client, storage)
} | go | func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(apiBaseEnvVar, storagePathEnvVar)
if err != nil {
return nil, fmt.Errorf("acme-dns: %v", err)
}
client := goacmedns.NewClient(values[apiBaseEnvVar])
storage := goacmedns.NewFileStorage(values[storagePathEnvVar], 0600)
return NewDNSProviderClient(client, storage)
} | [
"func",
"NewDNSProvider",
"(",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"values",
",",
"err",
":=",
"env",
".",
"Get",
"(",
"apiBaseEnvVar",
",",
"storagePathEnvVar",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"client",
":=",
"goacmedns",
".",
"NewClient",
"(",
"values",
"[",
"apiBaseEnvVar",
"]",
")",
"\n",
"storage",
":=",
"goacmedns",
".",
"NewFileStorage",
"(",
"values",
"[",
"storagePathEnvVar",
"]",
",",
"0600",
")",
"\n",
"return",
"NewDNSProviderClient",
"(",
"client",
",",
"storage",
")",
"\n",
"}"
] | // NewDNSProvider creates an ACME-DNS provider using file based account storage.
// Its configuration is loaded from the environment by reading apiBaseEnvVar and storagePathEnvVar. | [
"NewDNSProvider",
"creates",
"an",
"ACME",
"-",
"DNS",
"provider",
"using",
"file",
"based",
"account",
"storage",
".",
"Its",
"configuration",
"is",
"loaded",
"from",
"the",
"environment",
"by",
"reading",
"apiBaseEnvVar",
"and",
"storagePathEnvVar",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/acmedns/acmedns.go#L45-L54 | train |
go-acme/lego | providers/dns/acmedns/acmedns.go | NewDNSProviderClient | func NewDNSProviderClient(client acmeDNSClient, storage goacmedns.Storage) (*DNSProvider, error) {
if client == nil {
return nil, errors.New("ACME-DNS Client must be not nil")
}
if storage == nil {
return nil, errors.New("ACME-DNS Storage must be not nil")
}
return &DNSProvider{
client: client,
storage: storage,
}, nil
} | go | func NewDNSProviderClient(client acmeDNSClient, storage goacmedns.Storage) (*DNSProvider, error) {
if client == nil {
return nil, errors.New("ACME-DNS Client must be not nil")
}
if storage == nil {
return nil, errors.New("ACME-DNS Storage must be not nil")
}
return &DNSProvider{
client: client,
storage: storage,
}, nil
} | [
"func",
"NewDNSProviderClient",
"(",
"client",
"acmeDNSClient",
",",
"storage",
"goacmedns",
".",
"Storage",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"client",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"storage",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"storage",
":",
"storage",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderClient creates an ACME-DNS DNSProvider with the given acmeDNSClient and goacmedns.Storage. | [
"NewDNSProviderClient",
"creates",
"an",
"ACME",
"-",
"DNS",
"DNSProvider",
"with",
"the",
"given",
"acmeDNSClient",
"and",
"goacmedns",
".",
"Storage",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/acmedns/acmedns.go#L57-L70 | train |
go-acme/lego | providers/dns/acmedns/acmedns.go | Present | func (d *DNSProvider) Present(domain, _, keyAuth string) error {
// Compute the challenge response FQDN and TXT value for the domain based
// on the keyAuth.
fqdn, value := dns01.GetRecord(domain, keyAuth)
// Check if credentials were previously saved for this domain.
account, err := d.storage.Fetch(domain)
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
if err != nil && err != goacmedns.ErrDomainNotFound {
return err
}
if err == goacmedns.ErrDomainNotFound {
// The account did not exist. Create a new one and return an error
// indicating the required one-time manual CNAME setup.
return d.register(domain, fqdn)
}
// Update the acme-dns TXT record.
return d.client.UpdateTXTRecord(account, value)
} | go | func (d *DNSProvider) Present(domain, _, keyAuth string) error {
// Compute the challenge response FQDN and TXT value for the domain based
// on the keyAuth.
fqdn, value := dns01.GetRecord(domain, keyAuth)
// Check if credentials were previously saved for this domain.
account, err := d.storage.Fetch(domain)
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
if err != nil && err != goacmedns.ErrDomainNotFound {
return err
}
if err == goacmedns.ErrDomainNotFound {
// The account did not exist. Create a new one and return an error
// indicating the required one-time manual CNAME setup.
return d.register(domain, fqdn)
}
// Update the acme-dns TXT record.
return d.client.UpdateTXTRecord(account, value)
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"Present",
"(",
"domain",
",",
"_",
",",
"keyAuth",
"string",
")",
"error",
"{",
"// Compute the challenge response FQDN and TXT value for the domain based",
"// on the keyAuth.",
"fqdn",
",",
"value",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"// Check if credentials were previously saved for this domain.",
"account",
",",
"err",
":=",
"d",
".",
"storage",
".",
"Fetch",
"(",
"domain",
")",
"\n",
"// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"goacmedns",
".",
"ErrDomainNotFound",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
"==",
"goacmedns",
".",
"ErrDomainNotFound",
"{",
"// The account did not exist. Create a new one and return an error",
"// indicating the required one-time manual CNAME setup.",
"return",
"d",
".",
"register",
"(",
"domain",
",",
"fqdn",
")",
"\n",
"}",
"\n\n",
"// Update the acme-dns TXT record.",
"return",
"d",
".",
"client",
".",
"UpdateTXTRecord",
"(",
"account",
",",
"value",
")",
"\n",
"}"
] | // Present creates a TXT record to fulfill the DNS-01 challenge.
// If there is an existing account for the domain in the provider's storage
// then it will be used to set the challenge response TXT record with the ACME-DNS server and issuance will continue.
// If there is not an account for the given domain present in the DNSProvider storage
// one will be created and registered with the ACME DNS server and an ErrCNAMERequired error is returned.
// This will halt issuance and indicate to the user that a one-time manual setup is required for the domain. | [
"Present",
"creates",
"a",
"TXT",
"record",
"to",
"fulfill",
"the",
"DNS",
"-",
"01",
"challenge",
".",
"If",
"there",
"is",
"an",
"existing",
"account",
"for",
"the",
"domain",
"in",
"the",
"provider",
"s",
"storage",
"then",
"it",
"will",
"be",
"used",
"to",
"set",
"the",
"challenge",
"response",
"TXT",
"record",
"with",
"the",
"ACME",
"-",
"DNS",
"server",
"and",
"issuance",
"will",
"continue",
".",
"If",
"there",
"is",
"not",
"an",
"account",
"for",
"the",
"given",
"domain",
"present",
"in",
"the",
"DNSProvider",
"storage",
"one",
"will",
"be",
"created",
"and",
"registered",
"with",
"the",
"ACME",
"DNS",
"server",
"and",
"an",
"ErrCNAMERequired",
"error",
"is",
"returned",
".",
"This",
"will",
"halt",
"issuance",
"and",
"indicate",
"to",
"the",
"user",
"that",
"a",
"one",
"-",
"time",
"manual",
"setup",
"is",
"required",
"for",
"the",
"domain",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/acmedns/acmedns.go#L104-L123 | train |
go-acme/lego | providers/dns/acmedns/acmedns.go | register | func (d *DNSProvider) register(domain, fqdn string) error {
// TODO(@cpu): Read CIDR whitelists from the environment
newAcct, err := d.client.RegisterAccount(nil)
if err != nil {
return err
}
// Store the new account in the storage and call save to persist the data.
err = d.storage.Put(domain, newAcct)
if err != nil {
return err
}
err = d.storage.Save()
if err != nil {
return err
}
// Stop issuance by returning an error.
// The user needs to perform a manual one-time CNAME setup in their DNS zone
// to complete the setup of the new account we created.
return ErrCNAMERequired{
Domain: domain,
FQDN: fqdn,
Target: newAcct.FullDomain,
}
} | go | func (d *DNSProvider) register(domain, fqdn string) error {
// TODO(@cpu): Read CIDR whitelists from the environment
newAcct, err := d.client.RegisterAccount(nil)
if err != nil {
return err
}
// Store the new account in the storage and call save to persist the data.
err = d.storage.Put(domain, newAcct)
if err != nil {
return err
}
err = d.storage.Save()
if err != nil {
return err
}
// Stop issuance by returning an error.
// The user needs to perform a manual one-time CNAME setup in their DNS zone
// to complete the setup of the new account we created.
return ErrCNAMERequired{
Domain: domain,
FQDN: fqdn,
Target: newAcct.FullDomain,
}
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"register",
"(",
"domain",
",",
"fqdn",
"string",
")",
"error",
"{",
"// TODO(@cpu): Read CIDR whitelists from the environment",
"newAcct",
",",
"err",
":=",
"d",
".",
"client",
".",
"RegisterAccount",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Store the new account in the storage and call save to persist the data.",
"err",
"=",
"d",
".",
"storage",
".",
"Put",
"(",
"domain",
",",
"newAcct",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"d",
".",
"storage",
".",
"Save",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Stop issuance by returning an error.",
"// The user needs to perform a manual one-time CNAME setup in their DNS zone",
"// to complete the setup of the new account we created.",
"return",
"ErrCNAMERequired",
"{",
"Domain",
":",
"domain",
",",
"FQDN",
":",
"fqdn",
",",
"Target",
":",
"newAcct",
".",
"FullDomain",
",",
"}",
"\n",
"}"
] | // register creates a new ACME-DNS account for the given domain.
// If account creation works as expected a ErrCNAMERequired error is returned describing
// the one-time manual CNAME setup required to complete setup of the ACME-DNS hook for the domain.
// If any other error occurs it is returned as-is. | [
"register",
"creates",
"a",
"new",
"ACME",
"-",
"DNS",
"account",
"for",
"the",
"given",
"domain",
".",
"If",
"account",
"creation",
"works",
"as",
"expected",
"a",
"ErrCNAMERequired",
"error",
"is",
"returned",
"describing",
"the",
"one",
"-",
"time",
"manual",
"CNAME",
"setup",
"required",
"to",
"complete",
"setup",
"of",
"the",
"ACME",
"-",
"DNS",
"hook",
"for",
"the",
"domain",
".",
"If",
"any",
"other",
"error",
"occurs",
"it",
"is",
"returned",
"as",
"-",
"is",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/acmedns/acmedns.go#L137-L162 | train |
go-acme/lego | registration/registar.go | Register | func (r *Registrar) Register(options RegisterOptions) (*Resource, error) {
if r == nil || r.user == nil {
return nil, errors.New("acme: cannot register a nil client or user")
}
accMsg := acme.Account{
TermsOfServiceAgreed: options.TermsOfServiceAgreed,
Contact: []string{},
}
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.New(accMsg)
if err != nil {
// FIXME seems impossible
errorDetails, ok := err.(acme.ProblemDetails)
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
}
return &Resource{URI: account.Location, Body: account.Account}, nil
} | go | func (r *Registrar) Register(options RegisterOptions) (*Resource, error) {
if r == nil || r.user == nil {
return nil, errors.New("acme: cannot register a nil client or user")
}
accMsg := acme.Account{
TermsOfServiceAgreed: options.TermsOfServiceAgreed,
Contact: []string{},
}
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.New(accMsg)
if err != nil {
// FIXME seems impossible
errorDetails, ok := err.(acme.ProblemDetails)
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
}
return &Resource{URI: account.Location, Body: account.Account}, nil
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"Register",
"(",
"options",
"RegisterOptions",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"user",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"accMsg",
":=",
"acme",
".",
"Account",
"{",
"TermsOfServiceAgreed",
":",
"options",
".",
"TermsOfServiceAgreed",
",",
"Contact",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
"if",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
"!=",
"\"",
"\"",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
")",
"\n",
"accMsg",
".",
"Contact",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"+",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
"}",
"\n",
"}",
"\n\n",
"account",
",",
"err",
":=",
"r",
".",
"core",
".",
"Accounts",
".",
"New",
"(",
"accMsg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// FIXME seems impossible",
"errorDetails",
",",
"ok",
":=",
"err",
".",
"(",
"acme",
".",
"ProblemDetails",
")",
"\n",
"if",
"!",
"ok",
"||",
"errorDetails",
".",
"HTTPStatus",
"!=",
"http",
".",
"StatusConflict",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"Resource",
"{",
"URI",
":",
"account",
".",
"Location",
",",
"Body",
":",
"account",
".",
"Account",
"}",
",",
"nil",
"\n",
"}"
] | // Register the current account to the ACME server. | [
"Register",
"the",
"current",
"account",
"to",
"the",
"ACME",
"server",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/registration/registar.go#L43-L68 | train |
go-acme/lego | registration/registar.go | RegisterWithExternalAccountBinding | func (r *Registrar) RegisterWithExternalAccountBinding(options RegisterEABOptions) (*Resource, error) {
accMsg := acme.Account{
TermsOfServiceAgreed: options.TermsOfServiceAgreed,
Contact: []string{},
}
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.NewEAB(accMsg, options.Kid, options.HmacEncoded)
if err != nil {
errorDetails, ok := err.(acme.ProblemDetails)
// FIXME seems impossible
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
}
return &Resource{URI: account.Location, Body: account.Account}, nil
} | go | func (r *Registrar) RegisterWithExternalAccountBinding(options RegisterEABOptions) (*Resource, error) {
accMsg := acme.Account{
TermsOfServiceAgreed: options.TermsOfServiceAgreed,
Contact: []string{},
}
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.NewEAB(accMsg, options.Kid, options.HmacEncoded)
if err != nil {
errorDetails, ok := err.(acme.ProblemDetails)
// FIXME seems impossible
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
}
return &Resource{URI: account.Location, Body: account.Account}, nil
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"RegisterWithExternalAccountBinding",
"(",
"options",
"RegisterEABOptions",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"accMsg",
":=",
"acme",
".",
"Account",
"{",
"TermsOfServiceAgreed",
":",
"options",
".",
"TermsOfServiceAgreed",
",",
"Contact",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
"if",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
"!=",
"\"",
"\"",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
")",
"\n",
"accMsg",
".",
"Contact",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"+",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
"}",
"\n",
"}",
"\n\n",
"account",
",",
"err",
":=",
"r",
".",
"core",
".",
"Accounts",
".",
"NewEAB",
"(",
"accMsg",
",",
"options",
".",
"Kid",
",",
"options",
".",
"HmacEncoded",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"errorDetails",
",",
"ok",
":=",
"err",
".",
"(",
"acme",
".",
"ProblemDetails",
")",
"\n",
"// FIXME seems impossible",
"if",
"!",
"ok",
"||",
"errorDetails",
".",
"HTTPStatus",
"!=",
"http",
".",
"StatusConflict",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"Resource",
"{",
"URI",
":",
"account",
".",
"Location",
",",
"Body",
":",
"account",
".",
"Account",
"}",
",",
"nil",
"\n",
"}"
] | // RegisterWithExternalAccountBinding Register the current account to the ACME server. | [
"RegisterWithExternalAccountBinding",
"Register",
"the",
"current",
"account",
"to",
"the",
"ACME",
"server",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/registration/registar.go#L71-L92 | train |
go-acme/lego | registration/registar.go | QueryRegistration | func (r *Registrar) QueryRegistration() (*Resource, error) {
if r == nil || r.user == nil {
return nil, errors.New("acme: cannot query the registration of a nil client or user")
}
// Log the URL here instead of the email as the email may not be set
log.Infof("acme: Querying account for %s", r.user.GetRegistration().URI)
account, err := r.core.Accounts.Get(r.user.GetRegistration().URI)
if err != nil {
return nil, err
}
return &Resource{
Body: account,
// Location: header is not returned so this needs to be populated off of existing URI
URI: r.user.GetRegistration().URI,
}, nil
} | go | func (r *Registrar) QueryRegistration() (*Resource, error) {
if r == nil || r.user == nil {
return nil, errors.New("acme: cannot query the registration of a nil client or user")
}
// Log the URL here instead of the email as the email may not be set
log.Infof("acme: Querying account for %s", r.user.GetRegistration().URI)
account, err := r.core.Accounts.Get(r.user.GetRegistration().URI)
if err != nil {
return nil, err
}
return &Resource{
Body: account,
// Location: header is not returned so this needs to be populated off of existing URI
URI: r.user.GetRegistration().URI,
}, nil
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"QueryRegistration",
"(",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"user",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Log the URL here instead of the email as the email may not be set",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"r",
".",
"user",
".",
"GetRegistration",
"(",
")",
".",
"URI",
")",
"\n\n",
"account",
",",
"err",
":=",
"r",
".",
"core",
".",
"Accounts",
".",
"Get",
"(",
"r",
".",
"user",
".",
"GetRegistration",
"(",
")",
".",
"URI",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Resource",
"{",
"Body",
":",
"account",
",",
"// Location: header is not returned so this needs to be populated off of existing URI",
"URI",
":",
"r",
".",
"user",
".",
"GetRegistration",
"(",
")",
".",
"URI",
",",
"}",
",",
"nil",
"\n",
"}"
] | // QueryRegistration runs a POST request on the client's registration and returns the result.
//
// This is similar to the Register function,
// but acting on an existing registration link and resource. | [
"QueryRegistration",
"runs",
"a",
"POST",
"request",
"on",
"the",
"client",
"s",
"registration",
"and",
"returns",
"the",
"result",
".",
"This",
"is",
"similar",
"to",
"the",
"Register",
"function",
"but",
"acting",
"on",
"an",
"existing",
"registration",
"link",
"and",
"resource",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/registration/registar.go#L98-L116 | train |
go-acme/lego | registration/registar.go | DeleteRegistration | func (r *Registrar) DeleteRegistration() error {
if r == nil || r.user == nil {
return errors.New("acme: cannot unregister a nil client or user")
}
log.Infof("acme: Deleting account for %s", r.user.GetEmail())
return r.core.Accounts.Deactivate(r.user.GetRegistration().URI)
} | go | func (r *Registrar) DeleteRegistration() error {
if r == nil || r.user == nil {
return errors.New("acme: cannot unregister a nil client or user")
}
log.Infof("acme: Deleting account for %s", r.user.GetEmail())
return r.core.Accounts.Deactivate(r.user.GetRegistration().URI)
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"DeleteRegistration",
"(",
")",
"error",
"{",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"user",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"r",
".",
"user",
".",
"GetEmail",
"(",
")",
")",
"\n\n",
"return",
"r",
".",
"core",
".",
"Accounts",
".",
"Deactivate",
"(",
"r",
".",
"user",
".",
"GetRegistration",
"(",
")",
".",
"URI",
")",
"\n",
"}"
] | // DeleteRegistration deletes the client's user registration from the ACME server. | [
"DeleteRegistration",
"deletes",
"the",
"client",
"s",
"user",
"registration",
"from",
"the",
"ACME",
"server",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/registration/registar.go#L119-L127 | train |
go-acme/lego | registration/registar.go | ResolveAccountByKey | func (r *Registrar) ResolveAccountByKey() (*Resource, error) {
log.Infof("acme: Trying to resolve account by key")
accMsg := acme.Account{OnlyReturnExisting: true}
accountTransit, err := r.core.Accounts.New(accMsg)
if err != nil {
return nil, err
}
account, err := r.core.Accounts.Get(accountTransit.Location)
if err != nil {
return nil, err
}
return &Resource{URI: accountTransit.Location, Body: account}, nil
} | go | func (r *Registrar) ResolveAccountByKey() (*Resource, error) {
log.Infof("acme: Trying to resolve account by key")
accMsg := acme.Account{OnlyReturnExisting: true}
accountTransit, err := r.core.Accounts.New(accMsg)
if err != nil {
return nil, err
}
account, err := r.core.Accounts.Get(accountTransit.Location)
if err != nil {
return nil, err
}
return &Resource{URI: accountTransit.Location, Body: account}, nil
} | [
"func",
"(",
"r",
"*",
"Registrar",
")",
"ResolveAccountByKey",
"(",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"accMsg",
":=",
"acme",
".",
"Account",
"{",
"OnlyReturnExisting",
":",
"true",
"}",
"\n",
"accountTransit",
",",
"err",
":=",
"r",
".",
"core",
".",
"Accounts",
".",
"New",
"(",
"accMsg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"account",
",",
"err",
":=",
"r",
".",
"core",
".",
"Accounts",
".",
"Get",
"(",
"accountTransit",
".",
"Location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Resource",
"{",
"URI",
":",
"accountTransit",
".",
"Location",
",",
"Body",
":",
"account",
"}",
",",
"nil",
"\n",
"}"
] | // ResolveAccountByKey will attempt to look up an account using the given account key
// and return its registration resource. | [
"ResolveAccountByKey",
"will",
"attempt",
"to",
"look",
"up",
"an",
"account",
"using",
"the",
"given",
"account",
"key",
"and",
"return",
"its",
"registration",
"resource",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/registration/registar.go#L131-L146 | train |
go-acme/lego | challenge/resolver/solver_manager.go | SetHTTP01Provider | func (c *SolverManager) SetHTTP01Provider(p challenge.Provider) error {
c.solvers[challenge.HTTP01] = http01.NewChallenge(c.core, validate, p)
return nil
} | go | func (c *SolverManager) SetHTTP01Provider(p challenge.Provider) error {
c.solvers[challenge.HTTP01] = http01.NewChallenge(c.core, validate, p)
return nil
} | [
"func",
"(",
"c",
"*",
"SolverManager",
")",
"SetHTTP01Provider",
"(",
"p",
"challenge",
".",
"Provider",
")",
"error",
"{",
"c",
".",
"solvers",
"[",
"challenge",
".",
"HTTP01",
"]",
"=",
"http01",
".",
"NewChallenge",
"(",
"c",
".",
"core",
",",
"validate",
",",
"p",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetHTTP01Provider specifies a custom provider p that can solve the given HTTP-01 challenge. | [
"SetHTTP01Provider",
"specifies",
"a",
"custom",
"provider",
"p",
"that",
"can",
"solve",
"the",
"given",
"HTTP",
"-",
"01",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/solver_manager.go#L40-L43 | train |
go-acme/lego | challenge/resolver/solver_manager.go | SetTLSALPN01Provider | func (c *SolverManager) SetTLSALPN01Provider(p challenge.Provider) error {
c.solvers[challenge.TLSALPN01] = tlsalpn01.NewChallenge(c.core, validate, p)
return nil
} | go | func (c *SolverManager) SetTLSALPN01Provider(p challenge.Provider) error {
c.solvers[challenge.TLSALPN01] = tlsalpn01.NewChallenge(c.core, validate, p)
return nil
} | [
"func",
"(",
"c",
"*",
"SolverManager",
")",
"SetTLSALPN01Provider",
"(",
"p",
"challenge",
".",
"Provider",
")",
"error",
"{",
"c",
".",
"solvers",
"[",
"challenge",
".",
"TLSALPN01",
"]",
"=",
"tlsalpn01",
".",
"NewChallenge",
"(",
"c",
".",
"core",
",",
"validate",
",",
"p",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetTLSALPN01Provider specifies a custom provider p that can solve the given TLS-ALPN-01 challenge. | [
"SetTLSALPN01Provider",
"specifies",
"a",
"custom",
"provider",
"p",
"that",
"can",
"solve",
"the",
"given",
"TLS",
"-",
"ALPN",
"-",
"01",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/solver_manager.go#L46-L49 | train |
go-acme/lego | challenge/resolver/solver_manager.go | SetDNS01Provider | func (c *SolverManager) SetDNS01Provider(p challenge.Provider, opts ...dns01.ChallengeOption) error {
c.solvers[challenge.DNS01] = dns01.NewChallenge(c.core, validate, p, opts...)
return nil
} | go | func (c *SolverManager) SetDNS01Provider(p challenge.Provider, opts ...dns01.ChallengeOption) error {
c.solvers[challenge.DNS01] = dns01.NewChallenge(c.core, validate, p, opts...)
return nil
} | [
"func",
"(",
"c",
"*",
"SolverManager",
")",
"SetDNS01Provider",
"(",
"p",
"challenge",
".",
"Provider",
",",
"opts",
"...",
"dns01",
".",
"ChallengeOption",
")",
"error",
"{",
"c",
".",
"solvers",
"[",
"challenge",
".",
"DNS01",
"]",
"=",
"dns01",
".",
"NewChallenge",
"(",
"c",
".",
"core",
",",
"validate",
",",
"p",
",",
"opts",
"...",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetDNS01Provider specifies a custom provider p that can solve the given DNS-01 challenge. | [
"SetDNS01Provider",
"specifies",
"a",
"custom",
"provider",
"p",
"that",
"can",
"solve",
"the",
"given",
"DNS",
"-",
"01",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/solver_manager.go#L52-L55 | train |
go-acme/lego | challenge/resolver/solver_manager.go | Remove | func (c *SolverManager) Remove(chlgType challenge.Type) {
delete(c.solvers, chlgType)
} | go | func (c *SolverManager) Remove(chlgType challenge.Type) {
delete(c.solvers, chlgType)
} | [
"func",
"(",
"c",
"*",
"SolverManager",
")",
"Remove",
"(",
"chlgType",
"challenge",
".",
"Type",
")",
"{",
"delete",
"(",
"c",
".",
"solvers",
",",
"chlgType",
")",
"\n",
"}"
] | // Remove Remove a challenge type from the available solvers. | [
"Remove",
"Remove",
"a",
"challenge",
"type",
"from",
"the",
"available",
"solvers",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/solver_manager.go#L58-L60 | train |
go-acme/lego | challenge/resolver/solver_manager.go | chooseSolver | func (c *SolverManager) chooseSolver(authz acme.Authorization) solver {
// Allow to have a deterministic challenge order
sort.Sort(byType(authz.Challenges))
domain := challenge.GetTargetedDomain(authz)
for _, chlg := range authz.Challenges {
if solvr, ok := c.solvers[challenge.Type(chlg.Type)]; ok {
log.Infof("[%s] acme: use %s solver", domain, chlg.Type)
return solvr
}
log.Infof("[%s] acme: Could not find solver for: %s", domain, chlg.Type)
}
return nil
} | go | func (c *SolverManager) chooseSolver(authz acme.Authorization) solver {
// Allow to have a deterministic challenge order
sort.Sort(byType(authz.Challenges))
domain := challenge.GetTargetedDomain(authz)
for _, chlg := range authz.Challenges {
if solvr, ok := c.solvers[challenge.Type(chlg.Type)]; ok {
log.Infof("[%s] acme: use %s solver", domain, chlg.Type)
return solvr
}
log.Infof("[%s] acme: Could not find solver for: %s", domain, chlg.Type)
}
return nil
} | [
"func",
"(",
"c",
"*",
"SolverManager",
")",
"chooseSolver",
"(",
"authz",
"acme",
".",
"Authorization",
")",
"solver",
"{",
"// Allow to have a deterministic challenge order",
"sort",
".",
"Sort",
"(",
"byType",
"(",
"authz",
".",
"Challenges",
")",
")",
"\n\n",
"domain",
":=",
"challenge",
".",
"GetTargetedDomain",
"(",
"authz",
")",
"\n",
"for",
"_",
",",
"chlg",
":=",
"range",
"authz",
".",
"Challenges",
"{",
"if",
"solvr",
",",
"ok",
":=",
"c",
".",
"solvers",
"[",
"challenge",
".",
"Type",
"(",
"chlg",
".",
"Type",
")",
"]",
";",
"ok",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"domain",
",",
"chlg",
".",
"Type",
")",
"\n",
"return",
"solvr",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"domain",
",",
"chlg",
".",
"Type",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Checks all challenges from the server in order and returns the first matching solver. | [
"Checks",
"all",
"challenges",
"from",
"the",
"server",
"in",
"order",
"and",
"returns",
"the",
"first",
"matching",
"solver",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/solver_manager.go#L63-L77 | train |
go-acme/lego | providers/dns/nifcloud/nifcloud.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("nifcloud: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.AccessKey, config.SecretKey)
if err != nil {
return nil, fmt.Errorf("nifcloud: %v", err)
}
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
if len(config.BaseURL) > 0 {
client.BaseURL = config.BaseURL
}
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("nifcloud: the configuration of the DNS provider is nil")
}
client, err := internal.NewClient(config.AccessKey, config.SecretKey)
if err != nil {
return nil, fmt.Errorf("nifcloud: %v", err)
}
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
if len(config.BaseURL) > 0 {
client.BaseURL = config.BaseURL
}
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"internal",
".",
"NewClient",
"(",
"config",
".",
"AccessKey",
",",
"config",
".",
"SecretKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"HTTPClient",
"!=",
"nil",
"{",
"client",
".",
"HTTPClient",
"=",
"config",
".",
"HTTPClient",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"config",
".",
"BaseURL",
")",
">",
"0",
"{",
"client",
".",
"BaseURL",
"=",
"config",
".",
"BaseURL",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for NIFCLOUD. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"NIFCLOUD",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/nifcloud/nifcloud.go#L64-L83 | train |
go-acme/lego | providers/dns/otc/otc.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("otc: the configuration of the DNS provider is nil")
}
if config.DomainName == "" || config.UserName == "" || config.Password == "" || config.ProjectName == "" {
return nil, fmt.Errorf("otc: credentials missing")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("otc: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
if config.IdentityEndpoint == "" {
config.IdentityEndpoint = defaultIdentityEndpoint
}
return &DNSProvider{config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("otc: the configuration of the DNS provider is nil")
}
if config.DomainName == "" || config.UserName == "" || config.Password == "" || config.ProjectName == "" {
return nil, fmt.Errorf("otc: credentials missing")
}
if config.TTL < minTTL {
return nil, fmt.Errorf("otc: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
}
if config.IdentityEndpoint == "" {
config.IdentityEndpoint = defaultIdentityEndpoint
}
return &DNSProvider{config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"DomainName",
"==",
"\"",
"\"",
"||",
"config",
".",
"UserName",
"==",
"\"",
"\"",
"||",
"config",
".",
"Password",
"==",
"\"",
"\"",
"||",
"config",
".",
"ProjectName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"TTL",
"<",
"minTTL",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"config",
".",
"TTL",
",",
"minTTL",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"IdentityEndpoint",
"==",
"\"",
"\"",
"{",
"config",
".",
"IdentityEndpoint",
"=",
"defaultIdentityEndpoint",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for OTC DNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"OTC",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/otc/otc.go#L88-L106 | train |
go-acme/lego | providers/dns/mydnsjp/mydnsjp.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("mydnsjp: the configuration of the DNS provider is nil")
}
if config.MasterID == "" || config.Password == "" {
return nil, errors.New("mydnsjp: some credentials information are missing")
}
return &DNSProvider{config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("mydnsjp: the configuration of the DNS provider is nil")
}
if config.MasterID == "" || config.Password == "" {
return nil, errors.New("mydnsjp: some credentials information are missing")
}
return &DNSProvider{config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"MasterID",
"==",
"\"",
"\"",
"||",
"config",
".",
"Password",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for MyDNS.jp. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"MyDNS",
".",
"jp",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/mydnsjp/mydnsjp.go#L57-L67 | train |
go-acme/lego | certcrypto/crypto.go | ParsePEMBundle | func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
var certificates []*x509.Certificate
var certDERBlock *pem.Block
for {
certDERBlock, bundle = pem.Decode(bundle)
if certDERBlock == nil {
break
}
if certDERBlock.Type == "CERTIFICATE" {
cert, err := x509.ParseCertificate(certDERBlock.Bytes)
if err != nil {
return nil, err
}
certificates = append(certificates, cert)
}
}
if len(certificates) == 0 {
return nil, errors.New("no certificates were found while parsing the bundle")
}
return certificates, nil
} | go | func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
var certificates []*x509.Certificate
var certDERBlock *pem.Block
for {
certDERBlock, bundle = pem.Decode(bundle)
if certDERBlock == nil {
break
}
if certDERBlock.Type == "CERTIFICATE" {
cert, err := x509.ParseCertificate(certDERBlock.Bytes)
if err != nil {
return nil, err
}
certificates = append(certificates, cert)
}
}
if len(certificates) == 0 {
return nil, errors.New("no certificates were found while parsing the bundle")
}
return certificates, nil
} | [
"func",
"ParsePEMBundle",
"(",
"bundle",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"var",
"certificates",
"[",
"]",
"*",
"x509",
".",
"Certificate",
"\n",
"var",
"certDERBlock",
"*",
"pem",
".",
"Block",
"\n\n",
"for",
"{",
"certDERBlock",
",",
"bundle",
"=",
"pem",
".",
"Decode",
"(",
"bundle",
")",
"\n",
"if",
"certDERBlock",
"==",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"if",
"certDERBlock",
".",
"Type",
"==",
"\"",
"\"",
"{",
"cert",
",",
"err",
":=",
"x509",
".",
"ParseCertificate",
"(",
"certDERBlock",
".",
"Bytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"certificates",
"=",
"append",
"(",
"certificates",
",",
"cert",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"certificates",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"certificates",
",",
"nil",
"\n",
"}"
] | // ParsePEMBundle parses a certificate bundle from top to bottom and returns
// a slice of x509 certificates. This function will error if no certificates are found. | [
"ParsePEMBundle",
"parses",
"a",
"certificate",
"bundle",
"from",
"top",
"to",
"bottom",
"and",
"returns",
"a",
"slice",
"of",
"x509",
"certificates",
".",
"This",
"function",
"will",
"error",
"if",
"no",
"certificates",
"are",
"found",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/certcrypto/crypto.go#L54-L78 | train |
go-acme/lego | certcrypto/crypto.go | ParsePEMCertificate | func ParsePEMCertificate(cert []byte) (*x509.Certificate, error) {
pemBlock, err := pemDecode(cert)
if pemBlock == nil {
return nil, err
}
// from a DER encoded certificate
return x509.ParseCertificate(pemBlock.Bytes)
} | go | func ParsePEMCertificate(cert []byte) (*x509.Certificate, error) {
pemBlock, err := pemDecode(cert)
if pemBlock == nil {
return nil, err
}
// from a DER encoded certificate
return x509.ParseCertificate(pemBlock.Bytes)
} | [
"func",
"ParsePEMCertificate",
"(",
"cert",
"[",
"]",
"byte",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"pemBlock",
",",
"err",
":=",
"pemDecode",
"(",
"cert",
")",
"\n",
"if",
"pemBlock",
"==",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// from a DER encoded certificate",
"return",
"x509",
".",
"ParseCertificate",
"(",
"pemBlock",
".",
"Bytes",
")",
"\n",
"}"
] | // ParsePEMCertificate returns Certificate from a PEM encoded certificate.
// The certificate has to be PEM encoded. Any other encodings like DER will fail. | [
"ParsePEMCertificate",
"returns",
"Certificate",
"from",
"a",
"PEM",
"encoded",
"certificate",
".",
"The",
"certificate",
"has",
"to",
"be",
"PEM",
"encoded",
".",
"Any",
"other",
"encodings",
"like",
"DER",
"will",
"fail",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/certcrypto/crypto.go#L171-L179 | train |
go-acme/lego | acme/api/challenge.go | New | func (c *ChallengeService) New(chlgURL string) (acme.ExtendedChallenge, error) {
if len(chlgURL) == 0 {
return acme.ExtendedChallenge{}, errors.New("challenge[new]: empty URL")
}
// Challenge initiation is done by sending a JWS payload containing the trivial JSON object `{}`.
// We use an empty struct instance as the postJSON payload here to achieve this result.
var chlng acme.ExtendedChallenge
resp, err := c.core.post(chlgURL, struct{}{}, &chlng)
if err != nil {
return acme.ExtendedChallenge{}, err
}
chlng.AuthorizationURL = getLink(resp.Header, "up")
chlng.RetryAfter = getRetryAfter(resp)
return chlng, nil
} | go | func (c *ChallengeService) New(chlgURL string) (acme.ExtendedChallenge, error) {
if len(chlgURL) == 0 {
return acme.ExtendedChallenge{}, errors.New("challenge[new]: empty URL")
}
// Challenge initiation is done by sending a JWS payload containing the trivial JSON object `{}`.
// We use an empty struct instance as the postJSON payload here to achieve this result.
var chlng acme.ExtendedChallenge
resp, err := c.core.post(chlgURL, struct{}{}, &chlng)
if err != nil {
return acme.ExtendedChallenge{}, err
}
chlng.AuthorizationURL = getLink(resp.Header, "up")
chlng.RetryAfter = getRetryAfter(resp)
return chlng, nil
} | [
"func",
"(",
"c",
"*",
"ChallengeService",
")",
"New",
"(",
"chlgURL",
"string",
")",
"(",
"acme",
".",
"ExtendedChallenge",
",",
"error",
")",
"{",
"if",
"len",
"(",
"chlgURL",
")",
"==",
"0",
"{",
"return",
"acme",
".",
"ExtendedChallenge",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Challenge initiation is done by sending a JWS payload containing the trivial JSON object `{}`.",
"// We use an empty struct instance as the postJSON payload here to achieve this result.",
"var",
"chlng",
"acme",
".",
"ExtendedChallenge",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"core",
".",
"post",
"(",
"chlgURL",
",",
"struct",
"{",
"}",
"{",
"}",
",",
"&",
"chlng",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"ExtendedChallenge",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"chlng",
".",
"AuthorizationURL",
"=",
"getLink",
"(",
"resp",
".",
"Header",
",",
"\"",
"\"",
")",
"\n",
"chlng",
".",
"RetryAfter",
"=",
"getRetryAfter",
"(",
"resp",
")",
"\n",
"return",
"chlng",
",",
"nil",
"\n",
"}"
] | // New Creates a challenge. | [
"New",
"Creates",
"a",
"challenge",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/challenge.go#L12-L28 | train |
go-acme/lego | providers/dns/lightsail/lightsail.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("lightsail: the configuration of the DNS provider is nil")
}
retryer := customRetryer{}
retryer.NumMaxRetries = maxRetries
conf := aws.NewConfig().WithRegion(config.Region)
sess, err := session.NewSession(request.WithRetryer(conf, retryer))
if err != nil {
return nil, err
}
return &DNSProvider{
config: config,
client: lightsail.New(sess),
}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("lightsail: the configuration of the DNS provider is nil")
}
retryer := customRetryer{}
retryer.NumMaxRetries = maxRetries
conf := aws.NewConfig().WithRegion(config.Region)
sess, err := session.NewSession(request.WithRetryer(conf, retryer))
if err != nil {
return nil, err
}
return &DNSProvider{
config: config,
client: lightsail.New(sess),
}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"retryer",
":=",
"customRetryer",
"{",
"}",
"\n",
"retryer",
".",
"NumMaxRetries",
"=",
"maxRetries",
"\n\n",
"conf",
":=",
"aws",
".",
"NewConfig",
"(",
")",
".",
"WithRegion",
"(",
"config",
".",
"Region",
")",
"\n",
"sess",
",",
"err",
":=",
"session",
".",
"NewSession",
"(",
"request",
".",
"WithRetryer",
"(",
"conf",
",",
"retryer",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"lightsail",
".",
"New",
"(",
"sess",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for AWS Lightsail. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"AWS",
"Lightsail",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/lightsail/lightsail.go#L85-L103 | train |
go-acme/lego | providers/dns/route53/route53.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("route53: the configuration of the Route53 DNS provider is nil")
}
retry := customRetryer{}
retry.NumMaxRetries = config.MaxRetries
sessionCfg := request.WithRetryer(aws.NewConfig(), retry)
sess, err := session.NewSessionWithOptions(session.Options{Config: *sessionCfg})
if err != nil {
return nil, err
}
cl := route53.New(sess)
return &DNSProvider{client: cl, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("route53: the configuration of the Route53 DNS provider is nil")
}
retry := customRetryer{}
retry.NumMaxRetries = config.MaxRetries
sessionCfg := request.WithRetryer(aws.NewConfig(), retry)
sess, err := session.NewSessionWithOptions(session.Options{Config: *sessionCfg})
if err != nil {
return nil, err
}
cl := route53.New(sess)
return &DNSProvider{client: cl, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"retry",
":=",
"customRetryer",
"{",
"}",
"\n",
"retry",
".",
"NumMaxRetries",
"=",
"config",
".",
"MaxRetries",
"\n",
"sessionCfg",
":=",
"request",
".",
"WithRetryer",
"(",
"aws",
".",
"NewConfig",
"(",
")",
",",
"retry",
")",
"\n\n",
"sess",
",",
"err",
":=",
"session",
".",
"NewSessionWithOptions",
"(",
"session",
".",
"Options",
"{",
"Config",
":",
"*",
"sessionCfg",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"cl",
":=",
"route53",
".",
"New",
"(",
"sess",
")",
"\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"cl",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig takes a given config ans returns a custom configured DNSProvider instance | [
"NewDNSProviderConfig",
"takes",
"a",
"given",
"config",
"ans",
"returns",
"a",
"custom",
"configured",
"DNSProvider",
"instance"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/route53/route53.go#L84-L100 | train |
go-acme/lego | providers/dns/cloudxns/internal/client.go | NewClient | func NewClient(apiKey string, secretKey string) (*Client, error) {
if apiKey == "" {
return nil, fmt.Errorf("CloudXNS: credentials missing: apiKey")
}
if secretKey == "" {
return nil, fmt.Errorf("CloudXNS: credentials missing: secretKey")
}
return &Client{
apiKey: apiKey,
secretKey: secretKey,
HTTPClient: &http.Client{},
BaseURL: defaultBaseURL,
}, nil
} | go | func NewClient(apiKey string, secretKey string) (*Client, error) {
if apiKey == "" {
return nil, fmt.Errorf("CloudXNS: credentials missing: apiKey")
}
if secretKey == "" {
return nil, fmt.Errorf("CloudXNS: credentials missing: secretKey")
}
return &Client{
apiKey: apiKey,
secretKey: secretKey,
HTTPClient: &http.Client{},
BaseURL: defaultBaseURL,
}, nil
} | [
"func",
"NewClient",
"(",
"apiKey",
"string",
",",
"secretKey",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"apiKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"secretKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Client",
"{",
"apiKey",
":",
"apiKey",
",",
"secretKey",
":",
"secretKey",
",",
"HTTPClient",
":",
"&",
"http",
".",
"Client",
"{",
"}",
",",
"BaseURL",
":",
"defaultBaseURL",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewClient creates a CloudXNS client | [
"NewClient",
"creates",
"a",
"CloudXNS",
"client"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/cloudxns/internal/client.go#L46-L61 | train |
go-acme/lego | providers/dns/cloudxns/internal/client.go | GetDomainInformation | func (c *Client) GetDomainInformation(fqdn string) (*Data, error) {
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return nil, err
}
result, err := c.doRequest(http.MethodGet, "domain", nil)
if err != nil {
return nil, err
}
var domains []Data
if len(result) > 0 {
err = json.Unmarshal(result, &domains)
if err != nil {
return nil, fmt.Errorf("CloudXNS: domains unmarshaling error: %v", err)
}
}
for _, data := range domains {
if data.Domain == authZone {
return &data, nil
}
}
return nil, fmt.Errorf("CloudXNS: zone %s not found for domain %s", authZone, fqdn)
} | go | func (c *Client) GetDomainInformation(fqdn string) (*Data, error) {
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return nil, err
}
result, err := c.doRequest(http.MethodGet, "domain", nil)
if err != nil {
return nil, err
}
var domains []Data
if len(result) > 0 {
err = json.Unmarshal(result, &domains)
if err != nil {
return nil, fmt.Errorf("CloudXNS: domains unmarshaling error: %v", err)
}
}
for _, data := range domains {
if data.Domain == authZone {
return &data, nil
}
}
return nil, fmt.Errorf("CloudXNS: zone %s not found for domain %s", authZone, fqdn)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetDomainInformation",
"(",
"fqdn",
"string",
")",
"(",
"*",
"Data",
",",
"error",
")",
"{",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"fqdn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"c",
".",
"doRequest",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"domains",
"[",
"]",
"Data",
"\n",
"if",
"len",
"(",
"result",
")",
">",
"0",
"{",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"result",
",",
"&",
"domains",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"data",
":=",
"range",
"domains",
"{",
"if",
"data",
".",
"Domain",
"==",
"authZone",
"{",
"return",
"&",
"data",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"authZone",
",",
"fqdn",
")",
"\n",
"}"
] | // GetDomainInformation Get domain name information for a FQDN | [
"GetDomainInformation",
"Get",
"domain",
"name",
"information",
"for",
"a",
"FQDN"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/cloudxns/internal/client.go#L72-L98 | train |
go-acme/lego | providers/dns/conoha/conoha.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("conoha: the configuration of the DNS provider is nil")
}
if config.TenantID == "" || config.Username == "" || config.Password == "" {
return nil, errors.New("conoha: some credentials information are missing")
}
auth := internal.Auth{
TenantID: config.TenantID,
PasswordCredentials: internal.PasswordCredentials{
Username: config.Username,
Password: config.Password,
},
}
client, err := internal.NewClient(config.Region, auth, config.HTTPClient)
if err != nil {
return nil, fmt.Errorf("conoha: failed to create client: %v", err)
}
return &DNSProvider{config: config, client: client}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("conoha: the configuration of the DNS provider is nil")
}
if config.TenantID == "" || config.Username == "" || config.Password == "" {
return nil, errors.New("conoha: some credentials information are missing")
}
auth := internal.Auth{
TenantID: config.TenantID,
PasswordCredentials: internal.PasswordCredentials{
Username: config.Username,
Password: config.Password,
},
}
client, err := internal.NewClient(config.Region, auth, config.HTTPClient)
if err != nil {
return nil, fmt.Errorf("conoha: failed to create client: %v", err)
}
return &DNSProvider{config: config, client: client}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"TenantID",
"==",
"\"",
"\"",
"||",
"config",
".",
"Username",
"==",
"\"",
"\"",
"||",
"config",
".",
"Password",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"auth",
":=",
"internal",
".",
"Auth",
"{",
"TenantID",
":",
"config",
".",
"TenantID",
",",
"PasswordCredentials",
":",
"internal",
".",
"PasswordCredentials",
"{",
"Username",
":",
"config",
".",
"Username",
",",
"Password",
":",
"config",
".",
"Password",
",",
"}",
",",
"}",
"\n\n",
"client",
",",
"err",
":=",
"internal",
".",
"NewClient",
"(",
"config",
".",
"Region",
",",
"auth",
",",
"config",
".",
"HTTPClient",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"client",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for ConoHa DNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"ConoHa",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/conoha/conoha.go#L63-L86 | train |
go-acme/lego | providers/dns/conoha/conoha.go | CleanUp | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return err
}
domID, err := d.client.GetDomainID(authZone)
if err != nil {
return fmt.Errorf("conoha: failed to get domain ID: %v", err)
}
recID, err := d.client.GetRecordID(domID, fqdn, "TXT", value)
if err != nil {
return fmt.Errorf("conoha: failed to get record ID: %v", err)
}
err = d.client.DeleteRecord(domID, recID)
if err != nil {
return fmt.Errorf("conoha: failed to delete record: %v", err)
}
return nil
} | go | func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return err
}
domID, err := d.client.GetDomainID(authZone)
if err != nil {
return fmt.Errorf("conoha: failed to get domain ID: %v", err)
}
recID, err := d.client.GetRecordID(domID, fqdn, "TXT", value)
if err != nil {
return fmt.Errorf("conoha: failed to get record ID: %v", err)
}
err = d.client.DeleteRecord(domID, recID)
if err != nil {
return fmt.Errorf("conoha: failed to delete record: %v", err)
}
return nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"CleanUp",
"(",
"domain",
",",
"token",
",",
"keyAuth",
"string",
")",
"error",
"{",
"fqdn",
",",
"value",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"fqdn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"domID",
",",
"err",
":=",
"d",
".",
"client",
".",
"GetDomainID",
"(",
"authZone",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"recID",
",",
"err",
":=",
"d",
".",
"client",
".",
"GetRecordID",
"(",
"domID",
",",
"fqdn",
",",
"\"",
"\"",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"d",
".",
"client",
".",
"DeleteRecord",
"(",
"domID",
",",
"recID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CleanUp clears ConoHa DNS TXT record | [
"CleanUp",
"clears",
"ConoHa",
"DNS",
"TXT",
"record"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/conoha/conoha.go#L118-L142 | train |
go-acme/lego | cmd/certs_storage.go | NewCertificatesStorage | func NewCertificatesStorage(ctx *cli.Context) *CertificatesStorage {
return &CertificatesStorage{
rootPath: filepath.Join(ctx.GlobalString("path"), baseCertificatesFolderName),
archivePath: filepath.Join(ctx.GlobalString("path"), baseArchivesFolderName),
pem: ctx.GlobalBool("pem"),
filename: ctx.GlobalString("filename"),
}
} | go | func NewCertificatesStorage(ctx *cli.Context) *CertificatesStorage {
return &CertificatesStorage{
rootPath: filepath.Join(ctx.GlobalString("path"), baseCertificatesFolderName),
archivePath: filepath.Join(ctx.GlobalString("path"), baseArchivesFolderName),
pem: ctx.GlobalBool("pem"),
filename: ctx.GlobalString("filename"),
}
} | [
"func",
"NewCertificatesStorage",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"*",
"CertificatesStorage",
"{",
"return",
"&",
"CertificatesStorage",
"{",
"rootPath",
":",
"filepath",
".",
"Join",
"(",
"ctx",
".",
"GlobalString",
"(",
"\"",
"\"",
")",
",",
"baseCertificatesFolderName",
")",
",",
"archivePath",
":",
"filepath",
".",
"Join",
"(",
"ctx",
".",
"GlobalString",
"(",
"\"",
"\"",
")",
",",
"baseArchivesFolderName",
")",
",",
"pem",
":",
"ctx",
".",
"GlobalBool",
"(",
"\"",
"\"",
")",
",",
"filename",
":",
"ctx",
".",
"GlobalString",
"(",
"\"",
"\"",
")",
",",
"}",
"\n",
"}"
] | // NewCertificatesStorage create a new certificates storage. | [
"NewCertificatesStorage",
"create",
"a",
"new",
"certificates",
"storage",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/cmd/certs_storage.go#L48-L55 | train |
go-acme/lego | acme/api/authorization.go | Get | func (c *AuthorizationService) Get(authzURL string) (acme.Authorization, error) {
if len(authzURL) == 0 {
return acme.Authorization{}, errors.New("authorization[get]: empty URL")
}
var authz acme.Authorization
_, err := c.core.postAsGet(authzURL, &authz)
if err != nil {
return acme.Authorization{}, err
}
return authz, nil
} | go | func (c *AuthorizationService) Get(authzURL string) (acme.Authorization, error) {
if len(authzURL) == 0 {
return acme.Authorization{}, errors.New("authorization[get]: empty URL")
}
var authz acme.Authorization
_, err := c.core.postAsGet(authzURL, &authz)
if err != nil {
return acme.Authorization{}, err
}
return authz, nil
} | [
"func",
"(",
"c",
"*",
"AuthorizationService",
")",
"Get",
"(",
"authzURL",
"string",
")",
"(",
"acme",
".",
"Authorization",
",",
"error",
")",
"{",
"if",
"len",
"(",
"authzURL",
")",
"==",
"0",
"{",
"return",
"acme",
".",
"Authorization",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"authz",
"acme",
".",
"Authorization",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"core",
".",
"postAsGet",
"(",
"authzURL",
",",
"&",
"authz",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"acme",
".",
"Authorization",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"authz",
",",
"nil",
"\n",
"}"
] | // Get Gets an authorization. | [
"Get",
"Gets",
"an",
"authorization",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/authorization.go#L12-L23 | train |
go-acme/lego | acme/api/authorization.go | Deactivate | func (c *AuthorizationService) Deactivate(authzURL string) error {
if len(authzURL) == 0 {
return errors.New("authorization[deactivate]: empty URL")
}
var disabledAuth acme.Authorization
_, err := c.core.post(authzURL, acme.Authorization{Status: acme.StatusDeactivated}, &disabledAuth)
return err
} | go | func (c *AuthorizationService) Deactivate(authzURL string) error {
if len(authzURL) == 0 {
return errors.New("authorization[deactivate]: empty URL")
}
var disabledAuth acme.Authorization
_, err := c.core.post(authzURL, acme.Authorization{Status: acme.StatusDeactivated}, &disabledAuth)
return err
} | [
"func",
"(",
"c",
"*",
"AuthorizationService",
")",
"Deactivate",
"(",
"authzURL",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"authzURL",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"disabledAuth",
"acme",
".",
"Authorization",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"core",
".",
"post",
"(",
"authzURL",
",",
"acme",
".",
"Authorization",
"{",
"Status",
":",
"acme",
".",
"StatusDeactivated",
"}",
",",
"&",
"disabledAuth",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Deactivate Deactivates an authorization. | [
"Deactivate",
"Deactivates",
"an",
"authorization",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/acme/api/authorization.go#L26-L34 | train |
go-acme/lego | providers/dns/hostingde/hostingde.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("hostingde: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, errors.New("hostingde: API key missing")
}
if config.ZoneName == "" {
return nil, errors.New("hostingde: Zone Name missing")
}
return &DNSProvider{
config: config,
recordIDs: make(map[string]string),
}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("hostingde: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, errors.New("hostingde: API key missing")
}
if config.ZoneName == "" {
return nil, errors.New("hostingde: Zone Name missing")
}
return &DNSProvider{
config: config,
recordIDs: make(map[string]string),
}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"ZoneName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"recordIDs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for hosting.de. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"hosting",
".",
"de",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/hostingde/hostingde.go#L61-L78 | train |
go-acme/lego | providers/dns/exoscale/exoscale.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("the configuration of the DNS provider is nil")
}
if config.APIKey == "" || config.APISecret == "" {
return nil, fmt.Errorf("exoscale: credentials missing")
}
if config.Endpoint == "" {
config.Endpoint = defaultBaseURL
}
client := egoscale.NewClient(config.Endpoint, config.APIKey, config.APISecret)
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("the configuration of the DNS provider is nil")
}
if config.APIKey == "" || config.APISecret == "" {
return nil, fmt.Errorf("exoscale: credentials missing")
}
if config.Endpoint == "" {
config.Endpoint = defaultBaseURL
}
client := egoscale.NewClient(config.Endpoint, config.APIKey, config.APISecret)
client.HTTPClient = config.HTTPClient
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"||",
"config",
".",
"APISecret",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Endpoint",
"==",
"\"",
"\"",
"{",
"config",
".",
"Endpoint",
"=",
"defaultBaseURL",
"\n",
"}",
"\n\n",
"client",
":=",
"egoscale",
".",
"NewClient",
"(",
"config",
".",
"Endpoint",
",",
"config",
".",
"APIKey",
",",
"config",
".",
"APISecret",
")",
"\n",
"client",
".",
"HTTPClient",
"=",
"config",
".",
"HTTPClient",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for Exoscale. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Exoscale",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/exoscale/exoscale.go#L64-L81 | train |
go-acme/lego | providers/dns/exoscale/exoscale.go | FindExistingRecordID | func (d *DNSProvider) FindExistingRecordID(zone, recordName string) (int64, error) {
ctx := context.Background()
records, err := d.client.GetRecords(ctx, zone)
if err != nil {
return -1, errors.New("Error while retrievening DNS records: " + err.Error())
}
for _, record := range records {
if record.Name == recordName {
return record.ID, nil
}
}
return 0, nil
} | go | func (d *DNSProvider) FindExistingRecordID(zone, recordName string) (int64, error) {
ctx := context.Background()
records, err := d.client.GetRecords(ctx, zone)
if err != nil {
return -1, errors.New("Error while retrievening DNS records: " + err.Error())
}
for _, record := range records {
if record.Name == recordName {
return record.ID, nil
}
}
return 0, nil
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"FindExistingRecordID",
"(",
"zone",
",",
"recordName",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"records",
",",
"err",
":=",
"d",
".",
"client",
".",
"GetRecords",
"(",
"ctx",
",",
"zone",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"record",
":=",
"range",
"records",
"{",
"if",
"record",
".",
"Name",
"==",
"recordName",
"{",
"return",
"record",
".",
"ID",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"0",
",",
"nil",
"\n",
"}"
] | // FindExistingRecordID Query Exoscale to find an existing record for this name.
// Returns nil if no record could be found | [
"FindExistingRecordID",
"Query",
"Exoscale",
"to",
"find",
"an",
"existing",
"record",
"for",
"this",
"name",
".",
"Returns",
"nil",
"if",
"no",
"record",
"could",
"be",
"found"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/exoscale/exoscale.go#L159-L171 | train |
go-acme/lego | challenge/resolver/prober.go | Solve | func (p *Prober) Solve(authorizations []acme.Authorization) error {
failures := make(obtainError)
var authSolvers []*selectedAuthSolver
var authSolversSequential []*selectedAuthSolver
// Loop through the resources, basically through the domains.
// First pass just selects a solver for each authz.
for _, authz := range authorizations {
domain := challenge.GetTargetedDomain(authz)
if authz.Status == acme.StatusValid {
// Boulder might recycle recent validated authz (see issue #267)
log.Infof("[%s] acme: authorization already valid; skipping challenge", domain)
continue
}
if solvr := p.solverManager.chooseSolver(authz); solvr != nil {
authSolver := &selectedAuthSolver{authz: authz, solver: solvr}
switch s := solvr.(type) {
case sequential:
if ok, _ := s.Sequential(); ok {
authSolversSequential = append(authSolversSequential, authSolver)
} else {
authSolvers = append(authSolvers, authSolver)
}
default:
authSolvers = append(authSolvers, authSolver)
}
} else {
failures[domain] = fmt.Errorf("[%s] acme: could not determine solvers", domain)
}
}
parallelSolve(authSolvers, failures)
sequentialSolve(authSolversSequential, failures)
// Be careful not to return an empty failures map,
// for even an empty obtainError is a non-nil error value
if len(failures) > 0 {
return failures
}
return nil
} | go | func (p *Prober) Solve(authorizations []acme.Authorization) error {
failures := make(obtainError)
var authSolvers []*selectedAuthSolver
var authSolversSequential []*selectedAuthSolver
// Loop through the resources, basically through the domains.
// First pass just selects a solver for each authz.
for _, authz := range authorizations {
domain := challenge.GetTargetedDomain(authz)
if authz.Status == acme.StatusValid {
// Boulder might recycle recent validated authz (see issue #267)
log.Infof("[%s] acme: authorization already valid; skipping challenge", domain)
continue
}
if solvr := p.solverManager.chooseSolver(authz); solvr != nil {
authSolver := &selectedAuthSolver{authz: authz, solver: solvr}
switch s := solvr.(type) {
case sequential:
if ok, _ := s.Sequential(); ok {
authSolversSequential = append(authSolversSequential, authSolver)
} else {
authSolvers = append(authSolvers, authSolver)
}
default:
authSolvers = append(authSolvers, authSolver)
}
} else {
failures[domain] = fmt.Errorf("[%s] acme: could not determine solvers", domain)
}
}
parallelSolve(authSolvers, failures)
sequentialSolve(authSolversSequential, failures)
// Be careful not to return an empty failures map,
// for even an empty obtainError is a non-nil error value
if len(failures) > 0 {
return failures
}
return nil
} | [
"func",
"(",
"p",
"*",
"Prober",
")",
"Solve",
"(",
"authorizations",
"[",
"]",
"acme",
".",
"Authorization",
")",
"error",
"{",
"failures",
":=",
"make",
"(",
"obtainError",
")",
"\n\n",
"var",
"authSolvers",
"[",
"]",
"*",
"selectedAuthSolver",
"\n",
"var",
"authSolversSequential",
"[",
"]",
"*",
"selectedAuthSolver",
"\n\n",
"// Loop through the resources, basically through the domains.",
"// First pass just selects a solver for each authz.",
"for",
"_",
",",
"authz",
":=",
"range",
"authorizations",
"{",
"domain",
":=",
"challenge",
".",
"GetTargetedDomain",
"(",
"authz",
")",
"\n",
"if",
"authz",
".",
"Status",
"==",
"acme",
".",
"StatusValid",
"{",
"// Boulder might recycle recent validated authz (see issue #267)",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"domain",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"solvr",
":=",
"p",
".",
"solverManager",
".",
"chooseSolver",
"(",
"authz",
")",
";",
"solvr",
"!=",
"nil",
"{",
"authSolver",
":=",
"&",
"selectedAuthSolver",
"{",
"authz",
":",
"authz",
",",
"solver",
":",
"solvr",
"}",
"\n\n",
"switch",
"s",
":=",
"solvr",
".",
"(",
"type",
")",
"{",
"case",
"sequential",
":",
"if",
"ok",
",",
"_",
":=",
"s",
".",
"Sequential",
"(",
")",
";",
"ok",
"{",
"authSolversSequential",
"=",
"append",
"(",
"authSolversSequential",
",",
"authSolver",
")",
"\n",
"}",
"else",
"{",
"authSolvers",
"=",
"append",
"(",
"authSolvers",
",",
"authSolver",
")",
"\n",
"}",
"\n",
"default",
":",
"authSolvers",
"=",
"append",
"(",
"authSolvers",
",",
"authSolver",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"failures",
"[",
"domain",
"]",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"domain",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"parallelSolve",
"(",
"authSolvers",
",",
"failures",
")",
"\n\n",
"sequentialSolve",
"(",
"authSolversSequential",
",",
"failures",
")",
"\n\n",
"// Be careful not to return an empty failures map,",
"// for even an empty obtainError is a non-nil error value",
"if",
"len",
"(",
"failures",
")",
">",
"0",
"{",
"return",
"failures",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Solve Looks through the challenge combinations to find a solvable match.
// Then solves the challenges in series and returns. | [
"Solve",
"Looks",
"through",
"the",
"challenge",
"combinations",
"to",
"find",
"a",
"solvable",
"match",
".",
"Then",
"solves",
"the",
"challenges",
"in",
"series",
"and",
"returns",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/resolver/prober.go#L50-L94 | train |
go-acme/lego | providers/dns/ns1/ns1.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ns1: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, fmt.Errorf("ns1: credentials missing")
}
client := rest.NewClient(config.HTTPClient, rest.SetAPIKey(config.APIKey))
return &DNSProvider{client: client, config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ns1: the configuration of the DNS provider is nil")
}
if config.APIKey == "" {
return nil, fmt.Errorf("ns1: credentials missing")
}
client := rest.NewClient(config.HTTPClient, rest.SetAPIKey(config.APIKey))
return &DNSProvider{client: client, config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
":=",
"rest",
".",
"NewClient",
"(",
"config",
".",
"HTTPClient",
",",
"rest",
".",
"SetAPIKey",
"(",
"config",
".",
"APIKey",
")",
")",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"client",
":",
"client",
",",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for NS1. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"NS1",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/ns1/ns1.go#L60-L72 | train |
go-acme/lego | providers/dns/gcloud/googlecloud.go | NewDNSProviderCredentials | func NewDNSProviderCredentials(project string) (*DNSProvider, error) {
if project == "" {
return nil, fmt.Errorf("googlecloud: project name missing")
}
client, err := google.DefaultClient(context.Background(), dns.NdevClouddnsReadwriteScope)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to get Google Cloud client: %v", err)
}
config := NewDefaultConfig()
config.Project = project
config.HTTPClient = client
return NewDNSProviderConfig(config)
} | go | func NewDNSProviderCredentials(project string) (*DNSProvider, error) {
if project == "" {
return nil, fmt.Errorf("googlecloud: project name missing")
}
client, err := google.DefaultClient(context.Background(), dns.NdevClouddnsReadwriteScope)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to get Google Cloud client: %v", err)
}
config := NewDefaultConfig()
config.Project = project
config.HTTPClient = client
return NewDNSProviderConfig(config)
} | [
"func",
"NewDNSProviderCredentials",
"(",
"project",
"string",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"project",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"google",
".",
"DefaultClient",
"(",
"context",
".",
"Background",
"(",
")",
",",
"dns",
".",
"NdevClouddnsReadwriteScope",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"config",
":=",
"NewDefaultConfig",
"(",
")",
"\n",
"config",
".",
"Project",
"=",
"project",
"\n",
"config",
".",
"HTTPClient",
"=",
"client",
"\n\n",
"return",
"NewDNSProviderConfig",
"(",
"config",
")",
"\n",
"}"
] | // NewDNSProviderCredentials uses the supplied credentials
// to return a DNSProvider instance configured for Google Cloud DNS. | [
"NewDNSProviderCredentials",
"uses",
"the",
"supplied",
"credentials",
"to",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Google",
"Cloud",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/gcloud/googlecloud.go#L71-L86 | train |
go-acme/lego | providers/dns/gcloud/googlecloud.go | NewDNSProviderServiceAccountKey | func NewDNSProviderServiceAccountKey(saKey []byte) (*DNSProvider, error) {
if len(saKey) == 0 {
return nil, fmt.Errorf("googlecloud: Service Account is missing")
}
// If GCE_PROJECT is non-empty it overrides the project in the service
// account file.
project := env.GetOrDefaultString("GCE_PROJECT", "")
if project == "" {
// read project id from service account file
var datJSON struct {
ProjectID string `json:"project_id"`
}
err := json.Unmarshal(saKey, &datJSON)
if err != nil || datJSON.ProjectID == "" {
return nil, fmt.Errorf("googlecloud: project ID not found in Google Cloud Service Account file")
}
project = datJSON.ProjectID
}
conf, err := google.JWTConfigFromJSON(saKey, dns.NdevClouddnsReadwriteScope)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to acquire config: %v", err)
}
client := conf.Client(context.Background())
config := NewDefaultConfig()
config.Project = project
config.HTTPClient = client
return NewDNSProviderConfig(config)
} | go | func NewDNSProviderServiceAccountKey(saKey []byte) (*DNSProvider, error) {
if len(saKey) == 0 {
return nil, fmt.Errorf("googlecloud: Service Account is missing")
}
// If GCE_PROJECT is non-empty it overrides the project in the service
// account file.
project := env.GetOrDefaultString("GCE_PROJECT", "")
if project == "" {
// read project id from service account file
var datJSON struct {
ProjectID string `json:"project_id"`
}
err := json.Unmarshal(saKey, &datJSON)
if err != nil || datJSON.ProjectID == "" {
return nil, fmt.Errorf("googlecloud: project ID not found in Google Cloud Service Account file")
}
project = datJSON.ProjectID
}
conf, err := google.JWTConfigFromJSON(saKey, dns.NdevClouddnsReadwriteScope)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to acquire config: %v", err)
}
client := conf.Client(context.Background())
config := NewDefaultConfig()
config.Project = project
config.HTTPClient = client
return NewDNSProviderConfig(config)
} | [
"func",
"NewDNSProviderServiceAccountKey",
"(",
"saKey",
"[",
"]",
"byte",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"len",
"(",
"saKey",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// If GCE_PROJECT is non-empty it overrides the project in the service",
"// account file.",
"project",
":=",
"env",
".",
"GetOrDefaultString",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"project",
"==",
"\"",
"\"",
"{",
"// read project id from service account file",
"var",
"datJSON",
"struct",
"{",
"ProjectID",
"string",
"`json:\"project_id\"`",
"\n",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"saKey",
",",
"&",
"datJSON",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"datJSON",
".",
"ProjectID",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"project",
"=",
"datJSON",
".",
"ProjectID",
"\n",
"}",
"\n\n",
"conf",
",",
"err",
":=",
"google",
".",
"JWTConfigFromJSON",
"(",
"saKey",
",",
"dns",
".",
"NdevClouddnsReadwriteScope",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"client",
":=",
"conf",
".",
"Client",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n\n",
"config",
":=",
"NewDefaultConfig",
"(",
")",
"\n",
"config",
".",
"Project",
"=",
"project",
"\n",
"config",
".",
"HTTPClient",
"=",
"client",
"\n\n",
"return",
"NewDNSProviderConfig",
"(",
"config",
")",
"\n",
"}"
] | // NewDNSProviderServiceAccountKey uses the supplied service account JSON
// to return a DNSProvider instance configured for Google Cloud DNS. | [
"NewDNSProviderServiceAccountKey",
"uses",
"the",
"supplied",
"service",
"account",
"JSON",
"to",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Google",
"Cloud",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/gcloud/googlecloud.go#L90-L121 | train |
go-acme/lego | providers/dns/gcloud/googlecloud.go | NewDNSProviderServiceAccount | func NewDNSProviderServiceAccount(saFile string) (*DNSProvider, error) {
if saFile == "" {
return nil, fmt.Errorf("googlecloud: Service Account file missing")
}
saKey, err := ioutil.ReadFile(saFile)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to read Service Account file: %v", err)
}
return NewDNSProviderServiceAccountKey(saKey)
} | go | func NewDNSProviderServiceAccount(saFile string) (*DNSProvider, error) {
if saFile == "" {
return nil, fmt.Errorf("googlecloud: Service Account file missing")
}
saKey, err := ioutil.ReadFile(saFile)
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to read Service Account file: %v", err)
}
return NewDNSProviderServiceAccountKey(saKey)
} | [
"func",
"NewDNSProviderServiceAccount",
"(",
"saFile",
"string",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"saFile",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"saKey",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"saFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"NewDNSProviderServiceAccountKey",
"(",
"saKey",
")",
"\n",
"}"
] | // NewDNSProviderServiceAccount uses the supplied service account JSON file
// to return a DNSProvider instance configured for Google Cloud DNS. | [
"NewDNSProviderServiceAccount",
"uses",
"the",
"supplied",
"service",
"account",
"JSON",
"file",
"to",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Google",
"Cloud",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/gcloud/googlecloud.go#L125-L136 | train |
go-acme/lego | providers/dns/gcloud/googlecloud.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("googlecloud: the configuration of the DNS provider is nil")
}
if config.HTTPClient == nil {
return nil, fmt.Errorf("googlecloud: unable to create Google Cloud DNS service: client is nil")
}
svc, err := dns.NewService(context.Background(), option.WithHTTPClient(config.HTTPClient))
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to create Google Cloud DNS service: %v", err)
}
return &DNSProvider{config: config, client: svc}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("googlecloud: the configuration of the DNS provider is nil")
}
if config.HTTPClient == nil {
return nil, fmt.Errorf("googlecloud: unable to create Google Cloud DNS service: client is nil")
}
svc, err := dns.NewService(context.Background(), option.WithHTTPClient(config.HTTPClient))
if err != nil {
return nil, fmt.Errorf("googlecloud: unable to create Google Cloud DNS service: %v", err)
}
return &DNSProvider{config: config, client: svc}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"config",
".",
"HTTPClient",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"svc",
",",
"err",
":=",
"dns",
".",
"NewService",
"(",
"context",
".",
"Background",
"(",
")",
",",
"option",
".",
"WithHTTPClient",
"(",
"config",
".",
"HTTPClient",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
",",
"client",
":",
"svc",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for Google Cloud DNS. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"Google",
"Cloud",
"DNS",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/gcloud/googlecloud.go#L139-L153 | train |
go-acme/lego | providers/dns/gcloud/googlecloud.go | getHostedZone | func (d *DNSProvider) getHostedZone(domain string) (string, error) {
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return "", err
}
zones, err := d.client.ManagedZones.
List(d.config.Project).
DnsName(authZone).
Do()
if err != nil {
return "", fmt.Errorf("API call failed: %v", err)
}
if len(zones.ManagedZones) == 0 {
return "", fmt.Errorf("no matching domain found for domain %s", authZone)
}
for _, z := range zones.ManagedZones {
if z.Visibility == "public" || z.Visibility == "" {
return z.Name, nil
}
}
return "", fmt.Errorf("no public zone found for domain %s", authZone)
} | go | func (d *DNSProvider) getHostedZone(domain string) (string, error) {
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
return "", err
}
zones, err := d.client.ManagedZones.
List(d.config.Project).
DnsName(authZone).
Do()
if err != nil {
return "", fmt.Errorf("API call failed: %v", err)
}
if len(zones.ManagedZones) == 0 {
return "", fmt.Errorf("no matching domain found for domain %s", authZone)
}
for _, z := range zones.ManagedZones {
if z.Visibility == "public" || z.Visibility == "" {
return z.Name, nil
}
}
return "", fmt.Errorf("no public zone found for domain %s", authZone)
} | [
"func",
"(",
"d",
"*",
"DNSProvider",
")",
"getHostedZone",
"(",
"domain",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"authZone",
",",
"err",
":=",
"dns01",
".",
"FindZoneByFqdn",
"(",
"dns01",
".",
"ToFqdn",
"(",
"domain",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"zones",
",",
"err",
":=",
"d",
".",
"client",
".",
"ManagedZones",
".",
"List",
"(",
"d",
".",
"config",
".",
"Project",
")",
".",
"DnsName",
"(",
"authZone",
")",
".",
"Do",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"zones",
".",
"ManagedZones",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"authZone",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"z",
":=",
"range",
"zones",
".",
"ManagedZones",
"{",
"if",
"z",
".",
"Visibility",
"==",
"\"",
"\"",
"||",
"z",
".",
"Visibility",
"==",
"\"",
"\"",
"{",
"return",
"z",
".",
"Name",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"authZone",
")",
"\n",
"}"
] | // getHostedZone returns the managed-zone | [
"getHostedZone",
"returns",
"the",
"managed",
"-",
"zone"
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/gcloud/googlecloud.go#L295-L320 | train |
go-acme/lego | providers/dns/namecheap/namecheap.go | NewDNSProviderConfig | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("namecheap: the configuration of the DNS provider is nil")
}
if config.APIUser == "" || config.APIKey == "" {
return nil, fmt.Errorf("namecheap: credentials missing")
}
if len(config.ClientIP) == 0 {
clientIP, err := getClientIP(config.HTTPClient, config.Debug)
if err != nil {
return nil, fmt.Errorf("namecheap: %v", err)
}
config.ClientIP = clientIP
}
return &DNSProvider{config: config}, nil
} | go | func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("namecheap: the configuration of the DNS provider is nil")
}
if config.APIUser == "" || config.APIKey == "" {
return nil, fmt.Errorf("namecheap: credentials missing")
}
if len(config.ClientIP) == 0 {
clientIP, err := getClientIP(config.HTTPClient, config.Debug)
if err != nil {
return nil, fmt.Errorf("namecheap: %v", err)
}
config.ClientIP = clientIP
}
return &DNSProvider{config: config}, nil
} | [
"func",
"NewDNSProviderConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"DNSProvider",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"APIUser",
"==",
"\"",
"\"",
"||",
"config",
".",
"APIKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"config",
".",
"ClientIP",
")",
"==",
"0",
"{",
"clientIP",
",",
"err",
":=",
"getClientIP",
"(",
"config",
".",
"HTTPClient",
",",
"config",
".",
"Debug",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"config",
".",
"ClientIP",
"=",
"clientIP",
"\n",
"}",
"\n\n",
"return",
"&",
"DNSProvider",
"{",
"config",
":",
"config",
"}",
",",
"nil",
"\n",
"}"
] | // NewDNSProviderConfig return a DNSProvider instance configured for namecheap. | [
"NewDNSProviderConfig",
"return",
"a",
"DNSProvider",
"instance",
"configured",
"for",
"namecheap",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/namecheap/namecheap.go#L98-L116 | train |
go-acme/lego | providers/dns/namecheap/namecheap.go | getClientIP | func getClientIP(client *http.Client, debug bool) (addr string, err error) {
resp, err := client.Get(getIPURL)
if err != nil {
return "", err
}
defer resp.Body.Close()
clientIP, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
if debug {
log.Println("Client IP:", string(clientIP))
}
return string(clientIP), nil
} | go | func getClientIP(client *http.Client, debug bool) (addr string, err error) {
resp, err := client.Get(getIPURL)
if err != nil {
return "", err
}
defer resp.Body.Close()
clientIP, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
if debug {
log.Println("Client IP:", string(clientIP))
}
return string(clientIP), nil
} | [
"func",
"getClientIP",
"(",
"client",
"*",
"http",
".",
"Client",
",",
"debug",
"bool",
")",
"(",
"addr",
"string",
",",
"err",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"Get",
"(",
"getIPURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"clientIP",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"debug",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"string",
"(",
"clientIP",
")",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"clientIP",
")",
",",
"nil",
"\n",
"}"
] | // getClientIP returns the client's public IP address.
// It uses namecheap's IP discovery service to perform the lookup. | [
"getClientIP",
"returns",
"the",
"client",
"s",
"public",
"IP",
"address",
".",
"It",
"uses",
"namecheap",
"s",
"IP",
"discovery",
"service",
"to",
"perform",
"the",
"lookup",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/namecheap/namecheap.go#L205-L221 | train |
go-acme/lego | providers/dns/namecheap/namecheap.go | newChallenge | func newChallenge(domain, keyAuth string, tlds map[string]string) (*challenge, error) {
domain = dns01.UnFqdn(domain)
parts := strings.Split(domain, ".")
// Find the longest matching TLD.
longest := -1
for i := len(parts); i > 0; i-- {
t := strings.Join(parts[i-1:], ".")
if _, found := tlds[t]; found {
longest = i - 1
}
}
if longest < 1 {
return nil, fmt.Errorf("invalid domain name %q", domain)
}
tld := strings.Join(parts[longest:], ".")
sld := parts[longest-1]
var host string
if longest >= 1 {
host = strings.Join(parts[:longest-1], ".")
}
fqdn, value := dns01.GetRecord(domain, keyAuth)
return &challenge{
domain: domain,
key: "_acme-challenge." + host,
keyFqdn: fqdn,
keyValue: value,
tld: tld,
sld: sld,
host: host,
}, nil
} | go | func newChallenge(domain, keyAuth string, tlds map[string]string) (*challenge, error) {
domain = dns01.UnFqdn(domain)
parts := strings.Split(domain, ".")
// Find the longest matching TLD.
longest := -1
for i := len(parts); i > 0; i-- {
t := strings.Join(parts[i-1:], ".")
if _, found := tlds[t]; found {
longest = i - 1
}
}
if longest < 1 {
return nil, fmt.Errorf("invalid domain name %q", domain)
}
tld := strings.Join(parts[longest:], ".")
sld := parts[longest-1]
var host string
if longest >= 1 {
host = strings.Join(parts[:longest-1], ".")
}
fqdn, value := dns01.GetRecord(domain, keyAuth)
return &challenge{
domain: domain,
key: "_acme-challenge." + host,
keyFqdn: fqdn,
keyValue: value,
tld: tld,
sld: sld,
host: host,
}, nil
} | [
"func",
"newChallenge",
"(",
"domain",
",",
"keyAuth",
"string",
",",
"tlds",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"challenge",
",",
"error",
")",
"{",
"domain",
"=",
"dns01",
".",
"UnFqdn",
"(",
"domain",
")",
"\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"domain",
",",
"\"",
"\"",
")",
"\n\n",
"// Find the longest matching TLD.",
"longest",
":=",
"-",
"1",
"\n",
"for",
"i",
":=",
"len",
"(",
"parts",
")",
";",
"i",
">",
"0",
";",
"i",
"--",
"{",
"t",
":=",
"strings",
".",
"Join",
"(",
"parts",
"[",
"i",
"-",
"1",
":",
"]",
",",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"found",
":=",
"tlds",
"[",
"t",
"]",
";",
"found",
"{",
"longest",
"=",
"i",
"-",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"longest",
"<",
"1",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"domain",
")",
"\n",
"}",
"\n\n",
"tld",
":=",
"strings",
".",
"Join",
"(",
"parts",
"[",
"longest",
":",
"]",
",",
"\"",
"\"",
")",
"\n",
"sld",
":=",
"parts",
"[",
"longest",
"-",
"1",
"]",
"\n\n",
"var",
"host",
"string",
"\n",
"if",
"longest",
">=",
"1",
"{",
"host",
"=",
"strings",
".",
"Join",
"(",
"parts",
"[",
":",
"longest",
"-",
"1",
"]",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"fqdn",
",",
"value",
":=",
"dns01",
".",
"GetRecord",
"(",
"domain",
",",
"keyAuth",
")",
"\n\n",
"return",
"&",
"challenge",
"{",
"domain",
":",
"domain",
",",
"key",
":",
"\"",
"\"",
"+",
"host",
",",
"keyFqdn",
":",
"fqdn",
",",
"keyValue",
":",
"value",
",",
"tld",
":",
"tld",
",",
"sld",
":",
"sld",
",",
"host",
":",
"host",
",",
"}",
",",
"nil",
"\n",
"}"
] | // newChallenge builds a challenge record from a domain name, a challenge
// authentication key, and a map of available TLDs. | [
"newChallenge",
"builds",
"a",
"challenge",
"record",
"from",
"a",
"domain",
"name",
"a",
"challenge",
"authentication",
"key",
"and",
"a",
"map",
"of",
"available",
"TLDs",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/namecheap/namecheap.go#L225-L260 | train |
go-acme/lego | certificate/certificates.go | NewCertifier | func NewCertifier(core *api.Core, resolver resolver, options CertifierOptions) *Certifier {
return &Certifier{
core: core,
resolver: resolver,
options: options,
}
} | go | func NewCertifier(core *api.Core, resolver resolver, options CertifierOptions) *Certifier {
return &Certifier{
core: core,
resolver: resolver,
options: options,
}
} | [
"func",
"NewCertifier",
"(",
"core",
"*",
"api",
".",
"Core",
",",
"resolver",
"resolver",
",",
"options",
"CertifierOptions",
")",
"*",
"Certifier",
"{",
"return",
"&",
"Certifier",
"{",
"core",
":",
"core",
",",
"resolver",
":",
"resolver",
",",
"options",
":",
"options",
",",
"}",
"\n",
"}"
] | // NewCertifier creates a Certifier. | [
"NewCertifier",
"creates",
"a",
"Certifier",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/certificate/certificates.go#L77-L83 | train |
go-acme/lego | certificate/certificates.go | Obtain | func (c *Certifier) Obtain(request ObtainRequest) (*Resource, error) {
if len(request.Domains) == 0 {
return nil, errors.New("no domains to obtain a certificate for")
}
domains := sanitizeDomain(request.Domains)
if request.Bundle {
log.Infof("[%s] acme: Obtaining bundled SAN certificate", strings.Join(domains, ", "))
} else {
log.Infof("[%s] acme: Obtaining SAN certificate", strings.Join(domains, ", "))
}
order, err := c.core.Orders.New(domains)
if err != nil {
return nil, err
}
authz, err := c.getAuthorizations(order)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
c.deactivateAuthorizations(order)
return nil, err
}
err = c.resolver.Solve(authz)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
c.deactivateAuthorizations(order)
return nil, err
}
log.Infof("[%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", "))
failures := make(obtainError)
cert, err := c.getForOrder(domains, order, request.Bundle, request.PrivateKey, request.MustStaple)
if err != nil {
for _, auth := range authz {
failures[challenge.GetTargetedDomain(auth)] = err
}
}
// Do not return an empty failures map, because
// it would still be a non-nil error value
if len(failures) > 0 {
return cert, failures
}
return cert, nil
} | go | func (c *Certifier) Obtain(request ObtainRequest) (*Resource, error) {
if len(request.Domains) == 0 {
return nil, errors.New("no domains to obtain a certificate for")
}
domains := sanitizeDomain(request.Domains)
if request.Bundle {
log.Infof("[%s] acme: Obtaining bundled SAN certificate", strings.Join(domains, ", "))
} else {
log.Infof("[%s] acme: Obtaining SAN certificate", strings.Join(domains, ", "))
}
order, err := c.core.Orders.New(domains)
if err != nil {
return nil, err
}
authz, err := c.getAuthorizations(order)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
c.deactivateAuthorizations(order)
return nil, err
}
err = c.resolver.Solve(authz)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
c.deactivateAuthorizations(order)
return nil, err
}
log.Infof("[%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", "))
failures := make(obtainError)
cert, err := c.getForOrder(domains, order, request.Bundle, request.PrivateKey, request.MustStaple)
if err != nil {
for _, auth := range authz {
failures[challenge.GetTargetedDomain(auth)] = err
}
}
// Do not return an empty failures map, because
// it would still be a non-nil error value
if len(failures) > 0 {
return cert, failures
}
return cert, nil
} | [
"func",
"(",
"c",
"*",
"Certifier",
")",
"Obtain",
"(",
"request",
"ObtainRequest",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"if",
"len",
"(",
"request",
".",
"Domains",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"domains",
":=",
"sanitizeDomain",
"(",
"request",
".",
"Domains",
")",
"\n\n",
"if",
"request",
".",
"Bundle",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"domains",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"domains",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"order",
",",
"err",
":=",
"c",
".",
"core",
".",
"Orders",
".",
"New",
"(",
"domains",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"authz",
",",
"err",
":=",
"c",
".",
"getAuthorizations",
"(",
"order",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// If any challenge fails, return. Do not generate partial SAN certificates.",
"c",
".",
"deactivateAuthorizations",
"(",
"order",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"c",
".",
"resolver",
".",
"Solve",
"(",
"authz",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// If any challenge fails, return. Do not generate partial SAN certificates.",
"c",
".",
"deactivateAuthorizations",
"(",
"order",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"domains",
",",
"\"",
"\"",
")",
")",
"\n\n",
"failures",
":=",
"make",
"(",
"obtainError",
")",
"\n",
"cert",
",",
"err",
":=",
"c",
".",
"getForOrder",
"(",
"domains",
",",
"order",
",",
"request",
".",
"Bundle",
",",
"request",
".",
"PrivateKey",
",",
"request",
".",
"MustStaple",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"for",
"_",
",",
"auth",
":=",
"range",
"authz",
"{",
"failures",
"[",
"challenge",
".",
"GetTargetedDomain",
"(",
"auth",
")",
"]",
"=",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Do not return an empty failures map, because",
"// it would still be a non-nil error value",
"if",
"len",
"(",
"failures",
")",
">",
"0",
"{",
"return",
"cert",
",",
"failures",
"\n",
"}",
"\n",
"return",
"cert",
",",
"nil",
"\n",
"}"
] | // Obtain tries to obtain a single certificate using all domains passed into it.
//
// This function will never return a partial certificate.
// If one domain in the list fails, the whole certificate will fail. | [
"Obtain",
"tries",
"to",
"obtain",
"a",
"single",
"certificate",
"using",
"all",
"domains",
"passed",
"into",
"it",
".",
"This",
"function",
"will",
"never",
"return",
"a",
"partial",
"certificate",
".",
"If",
"one",
"domain",
"in",
"the",
"list",
"fails",
"the",
"whole",
"certificate",
"will",
"fail",
"."
] | 29c63545ce6fffd8289c55c39d81c4fde993533d | https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/certificate/certificates.go#L89-L137 | train |
Subsets and Splits