Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(cloudflare): support comment param #980

Merged
merged 3 commits into from
Jan 14, 2024
Merged

feat(cloudflare): support comment param #980

merged 3 commits into from
Jan 14, 2024

Conversation

ngc7331
Copy link
Contributor

@ngc7331 ngc7331 commented Jan 13, 2024

What does this PR do?

支持传递自定义参数comment来对 cloudflare 的 DNS 记录进行筛选,从而利用不同 comment 实现单域名多 IP 地址的效果

Motivation

#923,需要“单域名多 IP”的支持

Additional Notes

  • comment参数未指定时,行为和原先一致:忽略 DNS 记录的 comment,只匹配域名,且不会修改 comment
  • 如果需要匹配无 comment 的记录,可以传入空串,例如www:example.cn.eu.org?comment=
  • API 其实还支持.contains等更高级的匹配模式,但对于“单域名多 IP”这一目标来说还用不到,因此暂未实现

dns/cloudflare.go Outdated Show resolved Hide resolved
Co-authored-by: WaterLemons2k <[email protected]>
dns/cloudflare.go Outdated Show resolved Hide resolved
Copy link
Contributor

@WaterLemons2k WaterLemons2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

再次感谢澄清。

dns/cloudflare.go Outdated Show resolved Hide resolved
dns/cloudflare.go Outdated Show resolved Hide resolved
zoneID := result.Result[0].ID

var records CloudflareRecordsResp
// getDomains 最多更新前50条
err = cf.request(
"GET",
fmt.Sprintf(zonesAPI+"/%s/dns_records?type=%s&name=%s&per_page=50", zoneID, recordType, domain),
fmt.Sprintf(zonesAPI+"/%s/dns_records?type=%s&name=%s&per_page=50%s", zoneID, recordType, domain, comment),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

		`fmt.Sprintf(zonesAPI+"/%s/dns_records?type=%s&name=%s&per_page=50&comment=%s", zoneID, recordType, domain, domain.GetCustomParams().Get("comment")),`

上面那几行可以不要吧,一行搞定?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

		`fmt.Sprintf(zonesAPI+"/%s/dns_records?type=%s&name=%s&per_page=50&comment=%s", zoneID, recordType, domain, domain.GetCustomParams().Get("comment")),`

上面那几行可以不要吧,一行搞定?

请参考 #980 (comment)cloudflare/cloudflare-go#1371

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@jeessy2 jeessy2 merged commit fe9f437 into jeessy2:master Jan 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants