AnalogJ / lexicon

Manipulate DNS records on various DNS providers in a standardized way.
MIT License
1.48k stars 306 forks source link

Cpanel Support for Shared Hosting providers #254

Open clayshieh opened 6 years ago

clayshieh commented 6 years ago

I wrote a python library to interact with my shared hosting provider's dns settings which are exposed via cpanel here: https://github.com/clayshieh/PyCpanel

Haven't gotten around to cleaning it up to support WHM and API V1 yet but I think it would be a nice addition as a generic driver to lexicon so that it can support a number of providers that use cPanel (e.g. GoDaddy, Bluehost, HostGator, etc.,)

alexzorin commented 6 years ago

I think cPanel DNS is a great candidate because their API is actually documented and mostly stable.

One restriction is that the user's feature list must include the "Advanced Zone Editor", otherwise TXT records cannot be added. It might or might not be worth doing a preflight to check if the feature is present.

clayshieh commented 6 years ago

@alexzorin there's not really a way to check if the zone edit module is enabled on the user's feature list other than just sending the request and seeing if the response is successful. A weaker but reasonable assumption could be to use the fetchzone_records function in the Zoneedit module (refer to the get_records() method in my code) in the init function to check if the user has access to Zoneedit functions.

AnalogJ commented 6 years ago

yeah I'm with @alexzorin , this sounds like a great idea.

I don't personally use CPanel, so I won't be much help with the provider, but I'm more than happy to accept a PR.

Regarding a pre-flight check for this "Advanced Zone Editor" feature, you could use the authentication function to do this.

Should throw an error if authentication fails for any reason, of if the domain does not exist.

Basically if the feature isn't enabled, lexicon will just stop what it's doing and show the an error message. Now the thing to consider is if the CPanel API will return a nice error message stating that "Advanced Zone Editor" is missing, of if we need to explicitly catch the HTTP error and throw our own more explicit error stating the feature is not enabled.

AnalogJ commented 6 years ago

Hey @clayshieh Is this something you're still willing to work on? Is there anything I can do to help?

clayshieh commented 6 years ago

@AnalogJ this was on the back burner for a while. But I just took a look at integrating the Cpanel support and I need to make some modifications to my library to make it more compatible with Lexicon. Also, is there a common directory for files or do I need to register my module on pypi for it to be used in Lexicon?

AnalogJ commented 6 years ago

Hey @clayshieh It would need to be registered as a module on pypi.

AnalogJ commented 6 years ago

Hey @clayshieh Just wanted to follow up. Hows the CPanel provider work going? If your having issues creating a pypi project, and I walk you though the steps I used for lexicon

OdinVex commented 3 months ago

https://github.com/luponata/cPanel-UAPI-DNS-client

I'm not one for Python but I might give it a crack just to get CPanel providers working.

@AnalogJ, could you update the Namecheap provider to mean non-CPanel? It turns out Namecheap's DNS is rather...limited in more ways than I thought (record lengths, for example, non-integration of DNS management APIs...).