mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 23:42:04 +02:00
Refactor, spacing in zone file
This commit is contained in:
parent
ac4b63f390
commit
4caa0ef903
7 changed files with 45 additions and 38 deletions
|
@ -8,6 +8,7 @@ class CreateZonefileSetting < ActiveRecord::Migration
|
|||
t.integer :expire
|
||||
t.integer :minimum_ttl
|
||||
t.string :email
|
||||
t.string :master_nameserver
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
@ -20,7 +21,19 @@ class CreateZonefileSetting < ActiveRecord::Migration
|
|||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee'
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee'
|
||||
})
|
||||
|
||||
ZonefileSetting.create({
|
||||
origin: 'pri.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,14 +45,26 @@ class AddEeDomainObjects < ActiveRecord::Migration
|
|||
admin_contacts: [c],
|
||||
registrar: r
|
||||
)
|
||||
|
||||
pri = Domain.new(
|
||||
name: 'pri.ee',
|
||||
valid_to: Date.new(9999, 1, 1),
|
||||
period: 1,
|
||||
period_unit: 'y',
|
||||
owner_contact: c,
|
||||
admin_contacts: [c],
|
||||
registrar: r
|
||||
)
|
||||
|
||||
pri.save(validate: false)
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def down
|
||||
Domain.find_by(name: 'ee').destroy
|
||||
Domain.find_by(name: 'pri.ee').destroy
|
||||
EppUser.find_by(username: 'testeis').destroy
|
||||
Contact.find_by(name: 'EIS').destroy
|
||||
Registrar.find_by(name: 'EIS').destroy
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,17 +6,29 @@ class AddZonefileProcedure < ActiveRecord::Migration
|
|||
RETURNS text AS $$
|
||||
DECLARE
|
||||
zone_header text := concat('$ORIGIN ', i_origin, '.');
|
||||
tmp text := '';
|
||||
include_filter varchar := '';
|
||||
exclude_filter varchar := '';
|
||||
ns_records text := '';
|
||||
a_records text := '';
|
||||
a4_records text := '';
|
||||
ds_records text := '';
|
||||
BEGIN
|
||||
-- define filters
|
||||
include_filter = '%' || i_origin;
|
||||
|
||||
-- for %.%.%
|
||||
IF i_origin ~ '\.' THEN
|
||||
exclude_filter := '';
|
||||
-- for %.%
|
||||
ELSE
|
||||
exclude_filter = '%.%.' || i_origin;
|
||||
END IF;
|
||||
|
||||
-- zonefile header
|
||||
SELECT concat(
|
||||
format('%-10s', '$ORIGIN'), i_origin, '.', chr(10),
|
||||
format('%-10s', '$TTL'), zf.ttl, chr(10), chr(10),
|
||||
format('%-10s', i_origin || '.'), 'IN SOA ', 'ns.tld.ee', '. ', zf.email, '. (', chr(10),
|
||||
format('%-10s', i_origin || '.'), 'IN SOA ', zf.master_nameserver, '. ', zf.email, '. (', chr(10),
|
||||
format('%-17s', ''), format('%-12s', '2014111210'), '; serial number', chr(10),
|
||||
format('%-17s', ''), format('%-12s', zf.refresh), '; refresh, seconds', chr(10),
|
||||
format('%-17s', ''), format('%-12s', zf.retry), '; retry, seconds', chr(10),
|
||||
|
@ -24,14 +36,14 @@ class AddZonefileProcedure < ActiveRecord::Migration
|
|||
format('%-17s', ''), format('%-12s', zf.minimum_ttl), '; minimum TTL, seconds', chr(10),
|
||||
format('%-17s', ''), ')'
|
||||
) FROM zonefile_settings zf WHERE i_origin = zf.origin INTO zone_header;
|
||||
|
||||
RAISE NOTICE '%', include_filter;
|
||||
-- ns records
|
||||
SELECT array_to_string(
|
||||
array(
|
||||
SELECT concat(d.name, '. IN NS ', ns.hostname, '.')
|
||||
FROM domains d
|
||||
JOIN nameservers ns ON ns.domain_id = d.id
|
||||
WHERE d.name LIKE '%' || i_origin
|
||||
WHERE d.name LIKE include_filter
|
||||
ORDER BY
|
||||
CASE d.name
|
||||
WHEN i_origin THEN 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue