-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Fixes #490 - Add support for Namecheap #501
base: master
Are you sure you want to change the base?
Conversation
Link to Issue #490 |
3a51a14
to
2817068
Compare
@@ -85,6 +86,7 @@ public override void Configure(IFunctionsHostBuilder builder) | |||
dnsProviders.TryAdd(options.Gandi, o => new GandiProvider(o)); | |||
dnsProviders.TryAdd(options.GoDaddy, o => new GoDaddyProvider(o)); | |||
dnsProviders.TryAdd(options.GoogleDns, o => new GoogleDnsProvider(o)); | |||
dnsProviders.TryAdd(options.Namecheap, o => new NamecheapProvider(o, HttpClientFactory.Create(), HttpClientFactory.Create())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpClient should be instantiated inside the Provider. Implementation uniformity with other Providers is important.
public const string GetHostsCommand = "namecheap.domains.dns.getHosts"; | ||
public const string SetHostsCommand = "namecheap.domains.dns.setHosts"; | ||
|
||
public NamecheapProvider(NamecheapOptions options, HttpClient namecheapHttpClient, HttpClient ipfyOrgHttpClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with other Providers, the implementation of the IDnsProvider interface should be separated from the DNS API implementation class.
This is necessary for implementation consistency as well as to be resilient to future API changes.
|
||
var ipFyResponse = await response.Content.ReadAsAsync<IpfyResponse>(); | ||
|
||
return ipFyResponse.Ip; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure Functions do not always match the Outbound IP between each request. Therefore, there is a possibility of unintended behavior when the obtained Outbound IP changes.
An implemenation for Namecheap.
I've deployed and used it for three of my own domains now and it works fine.
Since I can't send PRs for the wiki, this is the documentation that should be added about configuration of the Namecheap provider:
Namecheap
App settings
Acmebot:Namecheap:ApiKey
Acmebot:Namecheap:ApiKey
Example API Token configuration
Navigate to https://ap.www.namecheap.com/settings/tools/apiaccess/
Client IP addresses must be whitelisted in your Namecheap account to be able to call the API. For Azure Function apps, this is a bit tricky, because you don't know which IP address the function app uses until it has tried and got rejected.
To find the IP address, you'll have to look at the Application Insights Performance view and look for logs on GetZones. There you should find an entry for api.namecheap.com GET /xml.response and the Path contains the ClientIp=nn.nnn.nn.nnn parameter showing the IP address that was used.
You have to go to your Namecheap profile page and whitelist this IP address.
But there's no guarantee that the function app uses the same IP address when it renews the certificates some months later.