mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge branch 'master' of github.com:internetee/registry
Conflicts: db/schema.rb
This commit is contained in:
commit
907ef1edf7
33 changed files with 629 additions and 288 deletions
|
@ -27,11 +27,6 @@ class Admin::DomainsController < AdminController
|
|||
end
|
||||
end
|
||||
|
||||
def zonefile
|
||||
@zonefile = @domain.generate_zonefile
|
||||
# send_data @zonefile, filename: 'bla.txt'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
|
|
30
app/controllers/admin/zonefile_settings_controller.rb
Normal file
30
app/controllers/admin/zonefile_settings_controller.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
class Admin::ZonefileSettingsController < ApplicationController
|
||||
before_action :set_zonefile_setting, only: [:update, :edit]
|
||||
def index
|
||||
@zonefile_settings = ZonefileSetting.all
|
||||
end
|
||||
|
||||
def edit
|
||||
@zonefile_setting = ZonefileSetting.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
if @zonefile_setting.update(zonefile_setting_params)
|
||||
flash[:notice] = I18n.t('shared.record_updated')
|
||||
redirect_to admin_zonefile_settings_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_update_record')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_zonefile_setting
|
||||
@zonefile_setting = ZonefileSetting.find(params[:id])
|
||||
end
|
||||
|
||||
def zonefile_setting_params
|
||||
params.require(:zonefile_setting).permit(:ttl, :refresh, :retry, :expire, :minimum_ttl, :email)
|
||||
end
|
||||
end
|
|
@ -2,44 +2,19 @@ class Admin::ZonefilesController < ApplicationController
|
|||
# TODO: Refactor this
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def index
|
||||
zf = Zonefile.new
|
||||
end
|
||||
|
||||
zf.origin = 'ee.'
|
||||
zf.ttl = '43200'
|
||||
def create
|
||||
if ZonefileSetting.pluck(:origin).include?(params[:origin])
|
||||
|
||||
zf.soa[:primary_ns] = 'ns.tld.ee.'
|
||||
zf.soa[:email] = 'hostmaster.eestiinternet.ee.'
|
||||
zf.soa[:origin] = 'ee.'
|
||||
zf.soa[:refresh] = '3600'
|
||||
zf.soa[:retry] = '900'
|
||||
zf.soa[:expire] = '1209600'
|
||||
zf.soa[:minimumTTL] = '3600'
|
||||
zf.new_serial
|
||||
@zonefile = ActiveRecord::Base.connection.execute(
|
||||
"select generate_zonefile('#{params[:origin]}')"
|
||||
)[0]['generate_zonefile']
|
||||
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'b.tld.ee.' }
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'e.tld.ee.' }
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'ee.aso.ee.' }
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'ns.ut.ee.' }
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'ns.tld.ee.' }
|
||||
zf.ns << { name: 'ee.', class: 'IN', host: 'sunic.sunet.se.' }
|
||||
|
||||
zf.a << { name: 'b.tld.ee.', class: 'IN', host: '194.146.106.110' }
|
||||
zf.a4 << { name: 'b.tld.ee.', class: 'IN', host: '2001:67c:1010:28::53' }
|
||||
zf.a << { name: 'e.tld.ee.', class: 'IN', host: '204.61.216.36' }
|
||||
zf.a4 << { name: 'e.tld.ee.', class: 'IN', host: '2001:678:94:53::53' }
|
||||
zf.a << { name: 'ee.aso.ee.', class: 'IN', host: '213.184.51.122' }
|
||||
zf.a4 << { name: 'ee.aso.ee.', class: 'IN', host: '2a02:88:0:21::2' }
|
||||
zf.a << { name: 'ns.ut.ee.', class: 'IN', host: '193.40.5.99' }
|
||||
zf.a << { name: 'ns.tld.ee.', class: 'IN', host: '195.43.87.10' }
|
||||
zf.a << { name: 'sunic.sunet.se.', class: 'IN', host: '192.36.125.2' }
|
||||
zf.a4 << { name: 'sunic.sunet.se.', class: 'IN', host: '2001:6b0:7::2' }
|
||||
|
||||
Nameserver.all.includes(:domain).each do |x|
|
||||
zf.ns << { name: "#{x.domain_name}.", class: 'IN', host: "#{x.hostname}." }
|
||||
zf.a << { name: "#{x.hostname}.", class: 'IN', host: x.ipv4 } if x.ipv4.present?
|
||||
zf.a4 << { name: "#{x.hostname}.", class: 'IN', host: x.ipv6 } if x.ipv6.present?
|
||||
send_data @zonefile, filename: "#{params[:origin]}.txt"
|
||||
else
|
||||
flash[:alert] = 'Origin not supported'
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
@zonefile = zf.generate
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,10 @@ class SessionsController < Devise::SessionsController
|
|||
# TODO: Create ID Card login here:
|
||||
# this is just testing config
|
||||
# if Rails.env.development? || Rails.env.test?
|
||||
@user = User.find_by(username: 'gitlab') if params[:gitlab]
|
||||
@user = User.first if params[:user1]
|
||||
@user = User.second if params[:user2]
|
||||
|
||||
return redirect_to :back, alert: 'No user' if @user.blank?
|
||||
|
||||
session[:current_user_registrar_id] = Registrar.first.id if @user.admin?
|
||||
|
||||
|
|
2
app/models/cached_nameserver.rb
Normal file
2
app/models/cached_nameserver.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class CachedNameserver < ActiveRecord::Base
|
||||
end
|
|
@ -2,4 +2,10 @@ class Country < ActiveRecord::Base
|
|||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
class << self
|
||||
def estonia
|
||||
find_by(iso: 'EE')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -306,35 +306,6 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def generate_zonefile
|
||||
zf = Zonefile.new
|
||||
zf.ttl = '3600'
|
||||
zf.origin = "#{name}."
|
||||
ns = nameservers.first
|
||||
zf.soa[:primary_ns] = "#{ns.hostname}."
|
||||
zf.soa[:email] = 'hostmaster.internet.ee'
|
||||
zf.soa[:origin] = "#{name}."
|
||||
zf.soa[:refresh] = '10800'
|
||||
zf.soa[:retry] = '3600'
|
||||
zf.soa[:expire] = '604800'
|
||||
zf.soa[:minimumTTL] = '3600'
|
||||
|
||||
nameservers.each do |x|
|
||||
zf.ns << { name: "#{name}.", class: 'IN', host: "#{x.hostname}." }
|
||||
end
|
||||
|
||||
dnskeys.each do |x|
|
||||
zf.ds << { name: "#{name}.", ttl: '86400', class: 'IN', key_tag: x.ds_key_tag, algorithm: x.ds_alg,
|
||||
digest_type: x.ds_digest_type, digest: x.ds_digest }
|
||||
|
||||
zf.dnskey << { name: "#{name}.", ttl: '86400', class: 'IN', flag: x.flags,
|
||||
protocol: x.protocol, algorithm: x.alg, public_key: x.public_key }
|
||||
end
|
||||
|
||||
zf.new_serial
|
||||
zf.generate
|
||||
end
|
||||
|
||||
class << self
|
||||
def convert_period_to_time(period, unit)
|
||||
return period.to_i.days if unit == 'd'
|
||||
|
|
|
@ -10,6 +10,10 @@ class Nameserver < ActiveRecord::Base
|
|||
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
||||
# rubocop: enable Metrics/LineLength
|
||||
|
||||
# caching
|
||||
after_commit :clear_cache
|
||||
after_commit :create_cache, on: [:create, :update]
|
||||
|
||||
# archiving
|
||||
has_paper_trail class_name: 'NameserverVersion'
|
||||
after_destroy :domain_version
|
||||
|
@ -52,6 +56,16 @@ class Nameserver < ActiveRecord::Base
|
|||
domain.create_version if domain
|
||||
end
|
||||
|
||||
def create_cache
|
||||
CachedNameserver.create(snapshot)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
logger.info('Nameserver already exists in cache; not caching')
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
CachedNameserver.find_by(snapshot).try(:delete)
|
||||
end
|
||||
|
||||
def to_s
|
||||
hostname
|
||||
end
|
||||
|
|
7
app/models/zonefile_setting.rb
Normal file
7
app/models/zonefile_setting.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class ZonefileSetting < ActiveRecord::Base
|
||||
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
|
||||
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
||||
def to_s
|
||||
origin
|
||||
end
|
||||
end
|
|
@ -16,6 +16,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
|||
|
||||
class << self
|
||||
def validate_format(value)
|
||||
return true if value == 'ee'
|
||||
return true unless value
|
||||
value = value.mb_chars.downcase.strip
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t('shared.domain_history')} for " + @name.to_s
|
||||
= "#{t(:domain_history)} for " + @name.to_s
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
%tbody
|
||||
- @settings.each do |x|
|
||||
%tr
|
||||
%td= t("shared.#{x.var}")
|
||||
%td= t("#{x.var}")
|
||||
- if [TrueClass, FalseClass].include?(x.value.class)
|
||||
%td
|
||||
= hidden_field_tag("[settings][#{x.var}]", '')
|
||||
|
|
50
app/views/admin/zonefile_settings/edit.haml
Normal file
50
app/views/admin/zonefile_settings/edit.haml
Normal file
|
@ -0,0 +1,50 @@
|
|||
%h2= t('zonefile_settings')
|
||||
%hr
|
||||
= form_for [:admin, @zonefile_setting], html: { class: 'form-horizontal' } do |f|
|
||||
.row
|
||||
.col-md-12
|
||||
#domain-statuses
|
||||
.errors
|
||||
- if f.object.errors.any?
|
||||
- f.object.errors.full_messages.each do |x|
|
||||
= x
|
||||
%br
|
||||
- if f.object.errors.any?
|
||||
%hr
|
||||
.form-group
|
||||
= f.label :origin, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :origin, class: 'form-control', disabled: true
|
||||
|
||||
.form-group
|
||||
= f.label :ttl, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :ttl, class: 'form-control'
|
||||
|
||||
.form-group
|
||||
= f.label :refresh, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :refresh, class: 'form-control'
|
||||
|
||||
.form-group
|
||||
= f.label :retry, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :retry, class: 'form-control'
|
||||
.form-group
|
||||
= f.label :expire, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :expire, class: 'form-control'
|
||||
|
||||
.form-group
|
||||
= f.label :minimum_ttl, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :minimum_ttl, class: 'form-control'
|
||||
|
||||
.form-group
|
||||
= f.label :email, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= f.text_field :email, class: 'form-control'
|
||||
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
%button.btn.btn-primary=t('shared.save')
|
20
app/views/admin/zonefile_settings/index.haml
Normal file
20
app/views/admin/zonefile_settings/index.haml
Normal file
|
@ -0,0 +1,20 @@
|
|||
.row
|
||||
.col-sm-12
|
||||
%h2.text-center-xs= t('zonefile_settings')
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-10'}
|
||||
= t('origin')
|
||||
%th{class: 'col-xs-2'}
|
||||
= t('action')
|
||||
%tbody
|
||||
- @zonefile_settings.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, edit_admin_zonefile_setting_path(x))
|
||||
%td
|
||||
= link_to(t('generate_zonefile'), admin_zonefiles_path(origin: x.origin), method: 'post', class: 'btn btn-xs btn-primary')
|
|
@ -23,38 +23,28 @@
|
|||
= link_to APP_CONFIG['app_name'], root_path, class: 'navbar-brand'
|
||||
.navbar-collapse.collapse
|
||||
%ul.nav.navbar-nav
|
||||
%li
|
||||
= link_to t('shared.domains'), admin_domains_path
|
||||
%li
|
||||
= link_to t('shared.contacts'), admin_contacts_path
|
||||
%li
|
||||
= link_to t('shared.registrars'), admin_registrars_path
|
||||
%li= link_to t('shared.domains'), admin_domains_path
|
||||
%li= link_to t('shared.contacts'), admin_contacts_path
|
||||
%li= link_to t('shared.registrars'), admin_registrars_path
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
= t('shared.settings')
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
%li.dropdown-header= t('shared.system')
|
||||
%li
|
||||
= link_to t('shared.settings'), admin_settings_path
|
||||
%li
|
||||
= link_to t('zonefile'), admin_zonefiles_path
|
||||
%li= link_to t('shared.settings'), admin_settings_path
|
||||
%li= link_to t('zonefile'), admin_zonefile_settings_path
|
||||
%li= link_to t(:domains_history), admin_domain_versions_path
|
||||
%li= link_to t(:background_jobs), admin_delayed_jobs_path
|
||||
|
||||
%li.divider
|
||||
%li.dropdown-header= t('shared.users')
|
||||
%li
|
||||
= link_to t('shared.epp_users'), admin_epp_users_path
|
||||
%li
|
||||
= link_to t('shared.users'), admin_users_path
|
||||
|
||||
%li
|
||||
= link_to t('shared.domains_history'), admin_domain_versions_path
|
||||
|
||||
%li
|
||||
= link_to t('shared.jobs'), admin_delayed_jobs_path
|
||||
|
||||
%li= link_to t(:admin_users), admin_users_path
|
||||
%li= link_to t(:epp_users), admin_epp_users_path
|
||||
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li= link_to t('shared.log_out', user: current_user), '/logout'
|
||||
|
||||
/ /.nav-collapse
|
||||
.container
|
||||
- display = (flash.empty?) ? 'none' : 'block'
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
%li
|
||||
= link_to t('shared.domains_history'), client_domain_versions_path
|
||||
= link_to t(:domains_history'), client_domain_versions_path
|
||||
%li
|
||||
= link_to t('shared.contacts_history'), client_contact_versions_path
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}/
|
||||
%meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}/
|
||||
%meta{:content => "Full stack top-level domain (TLD) management.", :name => "description"}/
|
||||
%meta{:content => "Gitlab LTD", :name => "author"}/
|
||||
%meta{:content => "Gitlab Ltd", :name => "author"}/
|
||||
= csrf_meta_tags
|
||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||
= stylesheet_link_tag 'login', media: 'all', 'data-turbolinks-track' => true
|
||||
|
@ -22,5 +22,8 @@
|
|||
%hr
|
||||
/ TODO: Refactor this when ID card login is done
|
||||
- if can? :create, :admin_session
|
||||
= button_to 'ID card (gitlab)', 'sessions',
|
||||
class: 'btn btn-lg btn-primary btn-block', name: 'gitlab'
|
||||
= button_to 'ID card (user1)', 'sessions',
|
||||
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
|
||||
= button_to 'ID card (user2)', 'sessions',
|
||||
class: 'btn btn-lg btn-primary btn-block', name: 'user2'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue