1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

adding mx and cname

This commit is contained in:
Craig Peterson
2017-04-11 23:02:57 -06:00
parent ff6c4289fa
commit fc0cac7d29
4 changed files with 50 additions and 17 deletions

View File

@ -2,14 +2,14 @@
name: CNAME name: CNAME
parameters: parameters:
- name - name
- address - target
- modifiers... - modifiers...
--- ---
CNAME adds a CNAME record to the domain. The name should be the relative label for the domain. CNAME adds a CNAME record to the domain. The name should be the relative label for the domain.
Using `@` or `*` for CNAME records is not recommended, as different providers support them differently. Using `@` or `*` for CNAME records is not recommended, as different providers support them differently.
Adress should be a string representing the CNAME target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`. Target should be a string representing the CNAME target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% include startExample.html %} {% include startExample.html %}
{% highlight js %} {% highlight js %}

View File

@ -0,0 +1,25 @@
---
name: MX
parameters:
- name
- priority
- target
- modifiers...
---
MX adds an MX record to the domain.
Priority should be a number.
Target should be a string representing the MX target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% include startExample.html %}
{% highlight js %}
D("example.com", REGISTRAR, DnsProvider(R53),
MX("@", 5, "mail"), // mx example.com -> mail.example.com
MX("sub", 10, "mail.foo.com.")
);
{%endhighlight%}
{% include endExample.html %}

View File

@ -141,6 +141,7 @@ function TXT(name, target) {
// MX(name,priority,target, recordModifiers...) // MX(name,priority,target, recordModifiers...)
function MX(name, priority, target) { function MX(name, priority, target) {
checkArgs([_.isString, _.isNumber, _.isString], arguments, "MX expects (name, priority, target)")
var mods = getModifiers(arguments,3) var mods = getModifiers(arguments,3)
return function(d) { return function(d) {
mods.push(priority); mods.push(priority);
@ -148,6 +149,17 @@ function MX(name, priority, target) {
} }
} }
function checkArgs(checks, args, desc){
if (args.length < checks.length){
throw(desc)
}
for (var i = 0; i< checks.length; i++){
if (!checks[i](args[i])){
throw(desc+" - argument "+i+" is not correct type")
}
}
}
// NS(name,target, recordModifiers...) // NS(name,target, recordModifiers...)
function NS(name, target) { function NS(name, target) {
var mods = getModifiers(arguments,2) var mods = getModifiers(arguments,2)

View File

@ -67,21 +67,17 @@ func TestParsedFiles(t *testing.T) {
} }
func TestErrors(t *testing.T) { func TestErrors(t *testing.T) {
files, err := ioutil.ReadDir(errorDir) tests := []struct{ desc, text string }{
if err != nil { {"old dsp style", `D("foo.com","reg","dsp")`},
t.Fatal(err) {"MX no priority", `D("foo.com","reg",MX("@","test."))`},
{"MX reversed", `D("foo.com","reg",MX("@","test.", 5))`},
} }
for _, f := range files { for _, tst := range tests {
if filepath.Ext(f.Name()) != ".js" { t.Run(tst.desc, func(t *testing.T) {
continue if _, err := ExecuteJavascript(tst.text, true); err == nil {
} t.Fatal("Expected error but found none")
t.Log(f.Name(), "------") }
content, err := ioutil.ReadFile(filepath.Join(errorDir, f.Name())) })
if err != nil {
t.Fatal(err)
}
if _, err = ExecuteJavascript(string(content), true); err == nil {
t.Fatal("Expected error but found none")
}
} }
} }