5
5
"errors"
6
6
"fmt"
7
7
"strconv"
8
+ "time"
8
9
9
10
"github.com/nrdcg/porkbun"
10
11
log "github.com/sirupsen/logrus"
@@ -68,11 +69,11 @@ func getRecords(ctx context.Context, domain, host string, client *porkbun.Client
68
69
return & ipv4Record , & ipv6Record , nil
69
70
}
70
71
71
- func getPorkbunClients (credentials map [string ]PorkbunCredentials ) (map [string ]* porkbun.Client , error ) {
72
+ func getPorkbunClients (credentials map [string ]PorkbunCredentials , timeout time. Duration ) (map [string ]* porkbun.Client , error ) {
72
73
clients := make (map [string ]* porkbun.Client )
73
74
74
75
for key , credential := range credentials {
75
- client , err := getPorkbunClient (credential , key )
76
+ client , err := getPorkbunClient (credential , key , timeout )
76
77
if err != nil {
77
78
connectionErrorsTotal .Inc ()
78
79
log .Errorf ("Error getting client for credentials '%s': %v" , key , err )
@@ -83,9 +84,9 @@ func getPorkbunClients(credentials map[string]PorkbunCredentials) (map[string]*p
83
84
return clients , nil
84
85
}
85
86
86
- func getPorkbunClient (credentials PorkbunCredentials , credentialsName string ) (* porkbun.Client , error ) {
87
+ func getPorkbunClient (credentials PorkbunCredentials , credentialsName string , timeout time. Duration ) (* porkbun.Client , error ) {
87
88
client := porkbun .New (credentials .PorkbunSecretKey , credentials .PorkbunAPIKey )
88
-
89
+ client . HTTPClient . Timeout = timeout
89
90
ctx := context .Background ()
90
91
91
92
yourIP , err := client .Ping (ctx )
0 commit comments