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:
@ -2,14 +2,14 @@
|
||||
name: CNAME
|
||||
parameters:
|
||||
- name
|
||||
- address
|
||||
- target
|
||||
- modifiers...
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
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 %}
|
||||
{% highlight js %}
|
||||
|
@ -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 %}
|
@ -141,6 +141,7 @@ function TXT(name, target) {
|
||||
|
||||
// MX(name,priority,target, recordModifiers...)
|
||||
function MX(name, priority, target) {
|
||||
checkArgs([_.isString, _.isNumber, _.isString], arguments, "MX expects (name, priority, target)")
|
||||
var mods = getModifiers(arguments,3)
|
||||
return function(d) {
|
||||
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...)
|
||||
function NS(name, target) {
|
||||
var mods = getModifiers(arguments,2)
|
||||
|
@ -67,21 +67,17 @@ func TestParsedFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestErrors(t *testing.T) {
|
||||
files, err := ioutil.ReadDir(errorDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
tests := []struct{ desc, text string }{
|
||||
{"old dsp style", `D("foo.com","reg","dsp")`},
|
||||
{"MX no priority", `D("foo.com","reg",MX("@","test."))`},
|
||||
{"MX reversed", `D("foo.com","reg",MX("@","test.", 5))`},
|
||||
}
|
||||
for _, f := range files {
|
||||
if filepath.Ext(f.Name()) != ".js" {
|
||||
continue
|
||||
}
|
||||
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")
|
||||
}
|
||||
for _, tst := range tests {
|
||||
t.Run(tst.desc, func(t *testing.T) {
|
||||
if _, err := ExecuteJavascript(tst.text, true); err == nil {
|
||||
t.Fatal("Expected error but found none")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user