This project will let you manage programmatically your domains in cdmon.com
It runs Chrome in headless mode and does what you'd do manually. There is no dark magic nor obscure hacks.
Any Python 3.x (+3.2 recommended) with PIP and Chrome (headless)
A very basic usage example:
from cdmon import CDMON
cdmon = CDMON()
cdmon.login()
cdmon.work_on("foo.com")
cdmon.create_record("TXT", {
"redirect_type": "custom",
"subdomain": "bar",
"value": "123456789"
})
cdmon.work_on("mydomain.com")
cdmon.change_record("A", "www", "127.0.0.1")
cdmon.change_record("A", "mailcow", "1.2.3.4")
cdmon.change_record("TXT", "@", "v=spf1 ...")
cdmon.work_on("xyz.com")
cdmon.delete_record("TXT", "bar")
cdmon.terminate()
Keep in mind the library uses environment variables to get the login data.
You'll need to provide those, creating a .env
file or by any other means.
USERNAME=
PASSWORD=
TIMEOUT=10
DEBUG=True
NETDEBUG=True
USERNAME
- The username / email you use to login in cdmon.comPASSWORD
- The passwordTIMEOUT
- Make Selenium timeout after that amount of time (in seconds). Default10
.DEBUG
- If set toTrue
it will show Chrome's UI. DefaultFalse
.NETDEBUG
- If set toTrue
it will showurllib
debug to stdout. DefaultFalse
.
From pypi!
pip3 install cdmon_automator
You must call this method before doing any other work, in order to let the library know on which domain you want to do the work on.
record_type
- The type of the record you're trying to create. It can be
TXT
SPF
A
AAAA
CNAME
MX
SRV
NS
values
- A hash containing specific data for the type of record you're
trying to create. Not all records need/use the same (amount of) variables. Use
the following list to make sure to use the correct data.
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
value
- The value of the record.
Examples:
-
Create a TXT record for the domain itself, with the value
foo bar xyz
cdmon.create_record("TXT", { "redirect_type": "@", "value": "foo bar xyz" })
-
Create a TXT record for
test.mydomain.com
, with the valuehi
cdmon.create_record("TXT", { "redirect_type": "custom", "subdomain": "test", "value": "hi" })
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
destination
- The IP you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
Examples:
-
Create an A record for the domain itself, pointing to
127.0.0.1
cdmon.create_record("A", { "redirect_type": "@", "destination": "127.0.0.1" })
-
Create an AAAA record for the domain
test.mydomain.com
, pointing to127.0.0.1
cdmon.create_record("AAAA", { "redirect_type": "custom", "subdomain": "test", "destination": "127.0.0.1" })
-
Create a CNAME record for the domain itself, pointing to
www.mydomain.com
cdmon.create_record("CNAME", { "redirect_type": "@", "destination": "www.mydomain.com" })
-
Create an NS record for the domain
test.mydomain.com
, pointing tomydomain.com
cdmon.create_record("NS", { "redirect_type": "custom", "subdomain": "test", "destination": "mydomain.com" })
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
destination
- The destination you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
priority
- The priority of the record.
weight
- The weight of the record.
port
- The port of the record.
Examples:
-
Create a SRV record for the domain itself, pointing to
foobar.com 5 800 22
cdmon.create_record("SRV", { "redirect_type": "@", "destination": "foobar.com" "priority": "5", "weight": "800", "port": "22" })
-
Create an SRV record for the domain
mail.mydomain.com
, pointing tosmtp.foo.bar 10 200 465
cdmon.create_record("SRV", { "redirect_type": "custom", "subdomain": "mail", "destination": "foobar.com" "priority": "10", "weight": "200", "port": "465" })
subdomain
- The subdomain.
destination
- The destination you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
priority
- The priority of the record.
Example:
-
Create an MX record for the domain
mail.mydomain.com
, pointing tofoobar.com 10
cdmon.create_record("MX", { "redirect_type": "custom", "subdomain": "mail", "destination": "foobar.com" "priority": "10" })
This method will let you update the fields of a record. values
has the same
rules as the values
from the create_record
method.
Note that you can't update the subdomain of the record, only the rest of the fields. This is how cdmon.com works.
This method will let you delete a record. Note that the search is based on
the type and the name (subdomain), which means that it's error prone in
situations where multiple records of the same type and on the same subdomain
exist, for example, multiple TXT
records on the @
domain.
Will close/quit Chrome.