dnscontrol icon indicating copy to clipboard operation
dnscontrol copied to clipboard

Support SRV records for Namecheap

Open BrainStone opened this issue 5 months ago • 10 comments

Is your feature request related to a problem? Please describe. Currently Namecheap doesn't support SRV records.

Describe the solution you'd like Namecheap supporting SRV records

Describe alternatives you've considered n/a

Additional context It appears there are endpoints from namecheap to manage SRV records, which don't seem to be publically documented, but they appear to exist.
In a support chat I have been dropped this gem:

https://api.sandbox.namecheap.com/xml.response?ApiUser=Username&ApiKey=APIKey&UserName=Username&ClientIp=IPAddress&Command=namecheap.domains.dns.setsrvrecords&SRVCount=1&SLD=somellcdomain&TLD=llc&Service1=_tcp&Protocol1=_test&Priority1=0&Target1=sadfas.comd.faa&Weight1=1&Port1=1 namecheap.domains.dns.getsrvrecords should be used to check the records. https://api.sandbox.namecheap.com/xml.response?ApiUser=Username&ApiKey=APIKey&UserName=Username&ClientIp=IPAddress&Command=namecheap.domains.dns.getsrvrecords&SLD=somellcdomain&TLD=llc

To me that appears to be functionality to manage SRV records. The one issue I saw was that they are squashing the host part into the protocol part, but nothing some dirty code couldn't solve.

BrainStone avatar Jul 23 '25 00:07 BrainStone

CC @willpower232

tlimoncelli avatar Jul 23 '25 14:07 tlimoncelli

Command=namecheap.domains.dns.setsrvrecords Command=namecheap.domains.dns.getsrvrecords

It looks like this API uses a different command than the other types of record because of course it does.

The namecheap provider wraps around this library https://github.com/billputer/go-namecheap which hasn't been updated for a few years although it seems the developer is still active on github.

I expect I'll have to fork, copy paste some bits, and then build in to dnscontrol to give it a go.

willpower232 avatar Jul 23 '25 14:07 willpower232

Yeah it was a real battle getting these secret sauce undocumented endpoints from support.

A PR on the original repo doesn't sound like a bad idea. And considering the API has been basically unchanged for ages (at least the publically documented part) I'm not surprised the library hasn't been updated.

BrainStone avatar Jul 23 '25 15:07 BrainStone

I imagine we'll end up having to swap my fork in permanently but can always try a PR.

The namecheap api is truly a ✨ gift ✨ that maybe one day I'll be able to figure out.

Image

willpower232 avatar Jul 23 '25 15:07 willpower232

It's a beauty indeed! Every time I've touched it, I've been marveling at the fact that it's working despite being built from popsicle sticks and duct tape and having documentation like cryptid.

Anyways I'm not here to complain. I wish I could help you, but go and I aren't friends really. And after having gotten a headache from reading the code (I'll admit I was dehydrated), I think I'll keep my fingers off. Nonetheless, I do appreciate your work a lot.

BrainStone avatar Jul 23 '25 15:07 BrainStone

One thing I just noticed and that may be worth noting is that this namecheap.domains.dns.setsrvrecords works pretty much exactly like the namecheap.domains.dns.getsrvrecords endpoint in that you need to provide ALL records at once.

I haven't tested it yet because I don't have a domain to play with or a playground account, but most likely you can just send JSON post data with all the records in there.

BrainStone avatar Jul 26 '25 12:07 BrainStone

Any updates on this? Something I can possibly help with?

BrainStone avatar Sep 07 '25 23:09 BrainStone

I'd offer to help but I don't have a test account on Namecheap. Maybe @willpower232 can help?

tlimoncelli avatar Sep 08 '25 15:09 tlimoncelli

I should be able to have a look in a couple of weekends time 🤞

As I said, will probably have to fork and update the third party library to deal with the extra requests but if you wanted to give it a whirl, you can sign up for a sandbox account and grab a domain there without risking your real life infrastructure https://www.namecheap.com/support/knowledgebase/article.aspx/763/63/what-is-sandbox/

Unfortunately their API is IP address allowlisting only and their rate limits make running the tests challenging so its difficult to include in CI.

willpower232 avatar Sep 10 '25 08:09 willpower232

hello, I have had a day

https://github.com/willpower232/go-namecheap/compare/master...srv-records

https://github.com/willpower232/dnscontrol/compare/main...srv-records

Now this is great and all but I was completely derailed by Namecheaps API at the end there.

For whatever reason, they don't use obviously unique XML tags for the SRV records and go-namecheap is entirely based on being able to unmarshal the XML so that means that currently the go-namecheap library will never be able to unmarshal the set response.

Thankfully that is mostly pointless in dnscontrol's universe so I simply commented it out for now and then ran the integration tests at which point I discovered that their empty response is also radically different.

<?xml version="1.0" encoding="utf-8"?>
<ApiResponse Status="OK" xmlns="http://api.namecheap.com/xml.response">
    <Errors/>
    <Warnings/>
    <RequestedCommand>namecheap.domains.dns.getsrvrecords</RequestedCommand>
    <CommandResponse Type="namecheap.domains.dns.getSrvRecords"/>
    <Server>Server -151154064</Server>
    <GMTTimeDifference>--4:00</GMTTimeDifference>
    <ExecutionTime>0.285</ExecutionTime>
</ApiResponse>

As soon as the integration tests emptied the test zone, the code segfaulted I presume because it couldn't unmarshal the response as it was missing the Result element inside the CommandResponse element.

Image

You can see the response struct here namecheap.go

I don't know enough go to know if it is possible to include attribute values in the unmarshaling because you'll notice there is a Type attribute on the CommandResponse element but I think I have to leave this for now.

willpower232 avatar Sep 28 '25 14:09 willpower232