mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
c64fa8c132
10 changed files with 215 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
class Admin::DomainsController < AdminController
|
||||
before_action :set_domain, only: [:show, :edit, :update]
|
||||
before_action :set_domain, only: [:show, :edit, :update, :zonefile]
|
||||
|
||||
def index
|
||||
@q = Domain.includes(:registrar, :owner_contact).search(params[:q])
|
||||
|
@ -27,6 +27,11 @@ class Admin::DomainsController < AdminController
|
|||
end
|
||||
end
|
||||
|
||||
def zonefile
|
||||
@zonefile = @domain.generate_zonefile
|
||||
# send_data @zonefile, filename: 'bla.txt'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AdminController < ApplicationController
|
||||
before_action :verify_admin
|
||||
# before_action :verify_admin
|
||||
|
||||
def verify_admin
|
||||
redirect_to client_root_path unless current_user.try(:admin?)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
class ClientController < ApplicationController
|
||||
helper_method :current_registrar
|
||||
|
||||
def current_registrar
|
||||
return Registrar.find(session[:current_user_registrar_id]) if current_user.admin?
|
||||
current_user.registrar
|
||||
end
|
||||
end
|
|
@ -298,6 +298,35 @@ 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'
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('shared.edit_statuses'), edit_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
= link_to(t('generate_zonefile'), zonefile_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
|
||||
%hr
|
||||
.row
|
||||
|
|
12
app/views/admin/domains/zonefile.haml
Normal file
12
app/views/admin/domains/zonefile.haml
Normal file
|
@ -0,0 +1,12 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t('zonefile')}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('shared.back_to_domain'), admin_domain_path(@domain), class: 'btn btn-default')
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
= preserve do
|
||||
%pre= @zonefile
|
Loading…
Add table
Add a link
Reference in a new issue