mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +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
|
@ -1,3 +0,0 @@
|
||||||
class Zonefile < ActiveRecord::Base
|
|
||||||
|
|
||||||
end
|
|
|
@ -221,7 +221,7 @@ en:
|
||||||
refresh: 'Refresh'
|
refresh: 'Refresh'
|
||||||
retry: 'Retry'
|
retry: 'Retry'
|
||||||
expire: 'Expire'
|
expire: 'Expire'
|
||||||
minimum_ttl: 'Minimum ttl'
|
minimum_ttl: 'Minimum TTL'
|
||||||
email: 'E-Mail'
|
email: 'E-Mail'
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
|
@ -420,12 +420,6 @@ en:
|
||||||
zonefile: 'Zonefile'
|
zonefile: 'Zonefile'
|
||||||
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
||||||
required_parameter_missing_choice: 'Required parameter missing: %{param_1} or %{param_2}'
|
required_parameter_missing_choice: 'Required parameter missing: %{param_1} or %{param_2}'
|
||||||
zonefile_ttl: 'Zonefile TTL'
|
|
||||||
zonefile_refresh: 'Zonefile refresh'
|
|
||||||
zonefile_retry: 'Zonefile retry'
|
|
||||||
zonefile_expire: 'Zonefile expire'
|
|
||||||
zonefile_minimum_ttl: 'Zonefile minimum TTL'
|
|
||||||
zonefile_email: 'Zonefile e-mail'
|
|
||||||
transfer_wait_time: 'Transfer wait time'
|
transfer_wait_time: 'Transfer wait time'
|
||||||
ns_min_count: 'Nameserver minimum count'
|
ns_min_count: 'Nameserver minimum count'
|
||||||
ns_max_count: 'Nameserver maximum count'
|
ns_max_count: 'Nameserver maximum count'
|
||||||
|
|
|
@ -8,6 +8,7 @@ class CreateZonefileSetting < ActiveRecord::Migration
|
||||||
t.integer :expire
|
t.integer :expire
|
||||||
t.integer :minimum_ttl
|
t.integer :minimum_ttl
|
||||||
t.string :email
|
t.string :email
|
||||||
|
t.string :master_nameserver
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
@ -20,7 +21,19 @@ class CreateZonefileSetting < ActiveRecord::Migration
|
||||||
retry: 900,
|
retry: 900,
|
||||||
expire: 1209600,
|
expire: 1209600,
|
||||||
minimum_ttl: 3600,
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,14 +45,26 @@ class AddEeDomainObjects < ActiveRecord::Migration
|
||||||
admin_contacts: [c],
|
admin_contacts: [c],
|
||||||
registrar: r
|
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
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
def down
|
def down
|
||||||
Domain.find_by(name: 'ee').destroy
|
Domain.find_by(name: 'ee').destroy
|
||||||
|
Domain.find_by(name: 'pri.ee').destroy
|
||||||
EppUser.find_by(username: 'testeis').destroy
|
EppUser.find_by(username: 'testeis').destroy
|
||||||
Contact.find_by(name: 'EIS').destroy
|
Contact.find_by(name: 'EIS').destroy
|
||||||
Registrar.find_by(name: 'EIS').destroy
|
Registrar.find_by(name: 'EIS').destroy
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,17 +6,29 @@ class AddZonefileProcedure < ActiveRecord::Migration
|
||||||
RETURNS text AS $$
|
RETURNS text AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
zone_header text := concat('$ORIGIN ', i_origin, '.');
|
zone_header text := concat('$ORIGIN ', i_origin, '.');
|
||||||
tmp text := '';
|
include_filter varchar := '';
|
||||||
|
exclude_filter varchar := '';
|
||||||
ns_records text := '';
|
ns_records text := '';
|
||||||
a_records text := '';
|
a_records text := '';
|
||||||
a4_records text := '';
|
a4_records text := '';
|
||||||
ds_records text := '';
|
ds_records text := '';
|
||||||
BEGIN
|
BEGIN
|
||||||
|
-- define filters
|
||||||
|
include_filter = '%' || i_origin;
|
||||||
|
|
||||||
|
-- for %.%.%
|
||||||
|
IF i_origin ~ '\.' THEN
|
||||||
|
exclude_filter := '';
|
||||||
|
-- for %.%
|
||||||
|
ELSE
|
||||||
|
exclude_filter = '%.%.' || i_origin;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- zonefile header
|
-- zonefile header
|
||||||
SELECT concat(
|
SELECT concat(
|
||||||
format('%-10s', '$ORIGIN'), i_origin, '.', chr(10),
|
format('%-10s', '$ORIGIN'), i_origin, '.', chr(10),
|
||||||
format('%-10s', '$TTL'), zf.ttl, chr(10), 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', '2014111210'), '; serial number', chr(10),
|
||||||
format('%-17s', ''), format('%-12s', zf.refresh), '; refresh, seconds', chr(10),
|
format('%-17s', ''), format('%-12s', zf.refresh), '; refresh, seconds', chr(10),
|
||||||
format('%-17s', ''), format('%-12s', zf.retry), '; retry, 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', ''), format('%-12s', zf.minimum_ttl), '; minimum TTL, seconds', chr(10),
|
||||||
format('%-17s', ''), ')'
|
format('%-17s', ''), ')'
|
||||||
) FROM zonefile_settings zf WHERE i_origin = zf.origin INTO zone_header;
|
) FROM zonefile_settings zf WHERE i_origin = zf.origin INTO zone_header;
|
||||||
|
RAISE NOTICE '%', include_filter;
|
||||||
-- ns records
|
-- ns records
|
||||||
SELECT array_to_string(
|
SELECT array_to_string(
|
||||||
array(
|
array(
|
||||||
SELECT concat(d.name, '. IN NS ', ns.hostname, '.')
|
SELECT concat(d.name, '. IN NS ', ns.hostname, '.')
|
||||||
FROM domains d
|
FROM domains d
|
||||||
JOIN nameservers ns ON ns.domain_id = d.id
|
JOIN nameservers ns ON ns.domain_id = d.id
|
||||||
WHERE d.name LIKE '%' || i_origin
|
WHERE d.name LIKE include_filter
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE d.name
|
CASE d.name
|
||||||
WHEN i_origin THEN 1
|
WHEN i_origin THEN 1
|
||||||
|
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20141121093125) do
|
ActiveRecord::Schema.define(version: 20141114130737) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -335,16 +335,4 @@ ActiveRecord::Schema.define(version: 20141121093125) do
|
||||||
|
|
||||||
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
|
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
|
||||||
|
|
||||||
create_table "zonefile_settings", force: true do |t|
|
|
||||||
t.string "origin"
|
|
||||||
t.integer "ttl"
|
|
||||||
t.integer "refresh"
|
|
||||||
t.integer "retry"
|
|
||||||
t.integer "expire"
|
|
||||||
t.integer "minimum_ttl"
|
|
||||||
t.string "email"
|
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,13 +78,4 @@ Setting.ns_max_count = 11
|
||||||
|
|
||||||
Setting.transfer_wait_time = 0
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
# rubocop: disable Style/NumericLiterals
|
|
||||||
Setting.zonefile_ttl = 43200
|
|
||||||
Setting.zonefile_refresh = 3600
|
|
||||||
Setting.zonefile_retry = 900
|
|
||||||
Setting.zonefile_expire = 1209600
|
|
||||||
Setting.zonefile_minimum_ttl = 3600
|
|
||||||
Setting.zonefile_email = 'hostmaster.eestiinternet.ee'
|
|
||||||
# rubocop: enable Style/NumericLiterals
|
|
||||||
|
|
||||||
# Setting.whois_enabled = true only uncomment this if you wish whois
|
# Setting.whois_enabled = true only uncomment this if you wish whois
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue