mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-11-10 17:26:10 +08:00
import_transform can define ttl as third parameter (#5)
This commit is contained in:
parent
03d30b02c7
commit
dd538e6693
5 changed files with 74 additions and 40 deletions
|
@ -176,10 +176,13 @@ function format_tt(transform_table) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPORT_TRANSFORM(translation_table, domain)
|
// IMPORT_TRANSFORM(translation_table, domain)
|
||||||
function IMPORT_TRANSFORM(translation_table, domain) {
|
function IMPORT_TRANSFORM(translation_table, domain,ttl) {
|
||||||
return function(d) {
|
return function(d) {
|
||||||
addRecord(d, "IMPORT_TRANSFORM", "@", domain, [
|
var rec = addRecord(d, "IMPORT_TRANSFORM", "@", domain, [
|
||||||
{'transform_table': format_tt(translation_table)}])
|
{'transform_table': format_tt(translation_table)}])
|
||||||
|
if (ttl){
|
||||||
|
rec.ttl = ttl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +234,7 @@ function addRecord(d,type,name,target,mods) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.records.push(rec);
|
d.records.push(rec);
|
||||||
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ip conversion functions from http://stackoverflow.com/a/8105740/121660
|
//ip conversion functions from http://stackoverflow.com/a/8105740/121660
|
||||||
|
|
4
js/parse_tests/007-importTransformTTL.js
Normal file
4
js/parse_tests/007-importTransformTTL.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
var TRANSFORM_INT = [
|
||||||
|
{low: "0.0.0.0", high: "1.1.1.1", newBase: "2.2.2.2" }
|
||||||
|
]
|
||||||
|
D("foo.com","reg",IMPORT_TRANSFORM(TRANSFORM_INT,"foo2.com",60))
|
23
js/parse_tests/007-importTransformTTL.json
Normal file
23
js/parse_tests/007-importTransformTTL.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"registrars": [],
|
||||||
|
"dns_service_providers": [],
|
||||||
|
"domains": [
|
||||||
|
{
|
||||||
|
"name": "foo.com",
|
||||||
|
"registrar": "reg",
|
||||||
|
"dsps": [],
|
||||||
|
"records": [
|
||||||
|
{
|
||||||
|
"type": "IMPORT_TRANSFORM",
|
||||||
|
"name": "@",
|
||||||
|
"target": "foo2.com",
|
||||||
|
"ttl": 60,
|
||||||
|
"meta": {
|
||||||
|
"transform_table": "0.0.0.0 ~ 1.1.1.1 ~ 2.2.2.2 ~ "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keepunknown": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
71
js/static.go
71
js/static.go
|
@ -190,43 +190,44 @@ var _escData = map[string]*_escFile{
|
||||||
|
|
||||||
"/helpers.js": {
|
"/helpers.js": {
|
||||||
local: "js/helpers.js",
|
local: "js/helpers.js",
|
||||||
size: 6644,
|
size: 6729,
|
||||||
modtime: 0,
|
modtime: 0,
|
||||||
compressed: `
|
compressed: `
|
||||||
H4sIAAAJbogA/7RZb2/bvBF/709xE7BaWlQ5SZtskOth3pP2QbHaCRJ3C2AYBmPRNlP9A0k7zQLnsw9H
|
H4sIAAAJbogA/7RZfW/bvBH/35/iJmC1tKhykrbZINfDvCftg2K1WyTuFsAwDEaibbZ6A0k7zQLnsw9H
|
||||||
UhIl2U8SYM2LNCLvjr/7w7vj1dkICkJytpBOv9PZEg6LLF3CAJ46AACcrpiQnHARwnTmq7UoFXNB+ZYt
|
UhIl2U8SYO0faUTey+9eeDxenK2gICRnkXSGvd6OcIjybAUjeOgBAHC6ZkJywkUI84Wv1uJMLAXlOxbR
|
||||||
6Dzn2ZZFtLadJYSlaqGzMzIjuiSbWF6IXMAAprN+p7PcpAvJshRYyiQjMfsvdT19aA3BIRSvQNJEg9+7
|
ZcHzHYtpYztPCcvUQm9vZMZ0RbaJvBSFgBHMF8Neb7XNIsnyDFjGJCMJ+y91Pa20geAYimcgaaPB7/1Q
|
||||||
vgbZArSzII3pw3VxpJuShP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Vq7llNcG+dPdZDmUVcoBv3Cm5bYf9w
|
F4w4QJtfZlNVNgTI3Ax/RJdB2R5UxPDqFVgTnHqjfSdViC3exojRYu0y7jtL1YAGy1NnOvN8qpa3zBlK
|
||||||
ZnRwKlMfyrg3P1ies3T1J89pqrK3dEaBmbIUA2OMF5V6WQ7VLLasKQKWPEtgLWUe9npCksWPbEv5Ms4e
|
1fC0HgPfOAe8hzLLvMAwHhTc9cLhCc/k6GinOdlxr3+womDZ+k+e0zbl4P0bB2ZUU06do+ZcldNoqEsx
|
||||||
gkWW9EjvbyfHZ3/9eNw7OT05Pz/GHL5lpGC4J1siFpzlMiB32UYqnpjdccIfe3cxy028BWuZWJXwyo0y
|
K6Ae8FaXlIAVz1PYSFmEg4GQJPqR7yhfJfldEOXpgAz+dnb67q9vTwdn52cXF6dY03eMlAzfyY6IiLNC
|
||||||
6XWsGQ8MIMpkIPKYSbcbdOuDXFf9HEXT45n3l9Ozc+8IP05mnvV1Wvv6MPMak9+i89gkxcFsiV9qAL5J
|
BuQ230rFk7BbTvj94DZhhcm/YCNT63r96sa59HrW4AhGEOcyEEXCpNsP+k0rXPXvJJ6fLry/nL+78E7w
|
||||||
I7pkKY08+78d1NlObZTfGN6htDZLukkaqTbS2fjPp2fnewrSB2x6/67yyPv3+j5UMhVEGBG5DpZxlnE8
|
42zhWV/nja83C681Ti7bmW1aKmYr/FJT9W0W0xXLaOzZf8tQup3G3wdaE0GU1mXJtmmr9Ma6Ov/5/N3F
|
||||||
s4d6VuFgSYcj6AZdOIKo3y5YEZrkfwEAAP//7nFu6fQZAAA=
|
gQvqDXbSf1d15fVrfT5qmQoiTIjcBKskzznqHKCddXpY0uEE+kEfTiAedi+wGF3yvwAAAP//w3EYSkka
|
||||||
|
AAA=
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ func transform_cname(target, old_domain, new_domain string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// import_transform imports the records of one zone into another, modifying records along the way.
|
// import_transform imports the records of one zone into another, modifying records along the way.
|
||||||
func import_transform(src_domain, dst_domain *models.DomainConfig, transforms []transform.IpConversion) error {
|
func import_transform(src_domain, dst_domain *models.DomainConfig, transforms []transform.IpConversion, ttl uint32) error {
|
||||||
// Read src_domain.Records, transform, and append to dst_domain.Records:
|
// Read src_domain.Records, transform, and append to dst_domain.Records:
|
||||||
// 1. Skip any that aren't A or CNAMEs.
|
// 1. Skip any that aren't A or CNAMEs.
|
||||||
// 2. Append dest_domainname to the end of the label.
|
// 2. Append dest_domainname to the end of the label.
|
||||||
|
@ -142,7 +142,9 @@ func import_transform(src_domain, dst_domain *models.DomainConfig, transforms []
|
||||||
rec2, _ := rec.Copy()
|
rec2, _ := rec.Copy()
|
||||||
rec2.Name = rec2.NameFQDN
|
rec2.Name = rec2.NameFQDN
|
||||||
rec2.NameFQDN = dnsutil.AddOrigin(rec2.Name, dst_domain.Name)
|
rec2.NameFQDN = dnsutil.AddOrigin(rec2.Name, dst_domain.Name)
|
||||||
rec2.TTL = 60
|
if ttl != 0 {
|
||||||
|
rec2.TTL = ttl
|
||||||
|
}
|
||||||
return rec2
|
return rec2
|
||||||
}
|
}
|
||||||
switch rec.Type {
|
switch rec.Type {
|
||||||
|
@ -222,7 +224,7 @@ func NormalizeAndValidateConfig(config *models.DNSConfig) (errs []error) {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = import_transform(config.FindDomain(rec.Target), domain, table)
|
err = import_transform(config.FindDomain(rec.Target), domain, table, rec.TTL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue