Skip to content

Commit

Permalink
fix: 🔥 fix timeout and parsing dot
Browse files Browse the repository at this point in the history
  • Loading branch information
titigmr committed Aug 18, 2024
1 parent 0c95c72 commit 9f1a1f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contribute/midaas-ws/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create(response: Response, request: Request, domaine: str, type: str, valeur
valeur += "."
key = f"{domaine}./{type}/{valeur}"
updated_data = data | {key: {"type": type,
"valeur": valeur,
"value": valeur,
"ttl": TTL.ttl}}
json.dump(updated_data, f)
logger.info(f"Zone content : {updated_data}")
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Config struct {
Host string `envconfig:"API_SERVER_HOST" default:"0.0.0.0"`
}
Options struct {
ReadTimeout time.Duration `envconfig:"API_READ_TIMEOUT" default:"3s"`
WriteTimeout time.Duration `envconfig:"API_WRITE_TIMEOUT" default:"3s"`
ReadTimeout time.Duration `envconfig:"API_READ_TIMEOUT" default:"10s"`
WriteTimeout time.Duration `envconfig:"API_WRITE_TIMEOUT" default:"10s"`
LogLevel string `envconfig:"API_LOG_LEVEL" default:"INFO"`
}
Provider struct {
Expand Down
10 changes: 8 additions & 2 deletions midaas/midaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,17 @@ func (p *midaasProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, err
return nil, err
}

// Remove final dot in CNAME records
typeValue := fmt.Sprint(v["type"])
targetValue := fmt.Sprint(v["value"])
if typeValue == "CNAME" {
targetValue = strings.TrimSuffix(targetValue, ".")
}
// Create Endpoint object
e := endpoint.Endpoint{DNSName: strings.Split(index, "./")[0],
Targets: endpoint.Targets([]string{formatResponse(fmt.Sprint(v["value"]), 0)}),
Targets: endpoint.Targets([]string{formatResponse(targetValue, 0)}),
RecordTTL: endpoint.TTL(intTTL),
RecordType: fmt.Sprint(v["type"])}
RecordType: typeValue}

log.WithFields(log.Fields{"DNSName": e.DNSName,
"Targets": e.Targets,
Expand Down

0 comments on commit 9f1a1f0

Please sign in to comment.