mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Merge branch 'master' into 2143-add-an-exception-for-DNSSEC-in-the-registry-lock
This commit is contained in:
commit
4b80ed5699
149 changed files with 550 additions and 593 deletions
|
@ -58,7 +58,7 @@ class Ability
|
|||
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw }
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw }
|
||||
can(:view_full_info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
|
||||
can(:check, Epp::Contact)
|
||||
can(:create, Epp::Contact)
|
||||
|
|
|
@ -39,4 +39,3 @@ class AccountActivity < ApplicationRecord
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
module Actions
|
||||
class ContactDelete
|
||||
attr_reader :contact
|
||||
attr_reader :new_attributes
|
||||
attr_reader :legal_document
|
||||
attr_reader :ident
|
||||
attr_reader :user
|
||||
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
|
||||
|
||||
def initialize(contact, legal_document = nil)
|
||||
@legal_document = legal_document
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
module Actions
|
||||
class ContactUpdate
|
||||
attr_reader :contact
|
||||
attr_reader :new_attributes
|
||||
attr_reader :legal_document
|
||||
attr_reader :ident
|
||||
attr_reader :user
|
||||
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
|
||||
|
||||
def initialize(contact, new_attributes, legal_document, ident, user)
|
||||
@contact = contact
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
module Actions
|
||||
class DomainTransfer
|
||||
attr_reader :domain
|
||||
attr_reader :transfer_code
|
||||
attr_reader :legal_document
|
||||
attr_reader :ident
|
||||
attr_reader :user
|
||||
attr_reader :domain, :transfer_code, :legal_document, :ident, :user
|
||||
|
||||
def initialize(domain, transfer_code, user)
|
||||
@domain = domain
|
||||
|
|
|
@ -44,6 +44,7 @@ class ApiUser < User
|
|||
after_initialize :set_defaults
|
||||
def set_defaults
|
||||
return unless new_record?
|
||||
|
||||
self.active = true unless saved_change_to_active?
|
||||
end
|
||||
|
||||
|
@ -76,7 +77,7 @@ class ApiUser < User
|
|||
end
|
||||
|
||||
def linked_with?(another_api_user)
|
||||
another_api_user.identity_code == self.identity_code
|
||||
another_api_user.identity_code == identity_code
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,8 +2,7 @@ module BalanceAutoReloadTypes
|
|||
class Threshold
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :amount
|
||||
attr_accessor :threshold
|
||||
attr_accessor :amount, :threshold
|
||||
|
||||
validates :amount, numericality: { greater_than_or_equal_to: :min_amount }
|
||||
validates :threshold, numericality: { greater_than_or_equal_to: 0 }
|
||||
|
@ -22,4 +21,4 @@ module BalanceAutoReloadTypes
|
|||
self.class.name.demodulize.underscore
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,8 @@ module Billing
|
|||
|
||||
validates :price, :valid_from, :operation_category, :duration, presence: true
|
||||
validates :operation_category, inclusion: { in: Proc.new { |price| price.class.operation_categories } }
|
||||
validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } }, if: :should_validate_duration?
|
||||
validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } },
|
||||
if: :should_validate_duration?
|
||||
|
||||
alias_attribute :effect_time, :valid_from
|
||||
alias_attribute :expire_time, :valid_to
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Billing
|
||||
class ReferenceNo
|
||||
REGEXP = /\A\d{2,20}\z/.freeze
|
||||
MULTI_REGEXP = /(\d{2,20})/.freeze
|
||||
REGEXP = /\A\d{2,20}\z/
|
||||
MULTI_REGEXP = /(\d{2,20})/
|
||||
|
||||
def self.generate
|
||||
base = Base.generate
|
||||
|
|
|
@ -8,7 +8,7 @@ class BlockedDomain < ApplicationRecord
|
|||
|
||||
|
||||
class << self
|
||||
def by_domain name
|
||||
def by_domain(name)
|
||||
where(name: name)
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ class BlockedDomain < ApplicationRecord
|
|||
|
||||
def generate_json
|
||||
h = HashWithIndifferentAccess.new
|
||||
h[:name] = self.name
|
||||
h[:name] = name
|
||||
h[:status] = ['Blocked']
|
||||
h
|
||||
end
|
||||
|
|
|
@ -67,9 +67,7 @@ class Certificate < ApplicationRecord
|
|||
|
||||
@cached_status = SIGNED
|
||||
|
||||
if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc
|
||||
@cached_status = EXPIRED
|
||||
end
|
||||
@cached_status = EXPIRED if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc
|
||||
|
||||
crl = OpenSSL::X509::CRL.new(File.open("#{ENV['crl_dir']}/crl.pem").read)
|
||||
return @cached_status unless crl.revoked.map(&:serial).include?(parsed_crt.serial)
|
||||
|
@ -83,10 +81,11 @@ class Certificate < ApplicationRecord
|
|||
csr_file.rewind
|
||||
|
||||
crt_file = Tempfile.new('client_crt')
|
||||
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \
|
||||
-cert #{ENV['ca_cert_path']} \
|
||||
-extensions usr_cert -notext -md sha256 \
|
||||
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
|
||||
_out, err, _st = Open3.capture3('openssl', 'ca', '-config', ENV['openssl_config_path'],
|
||||
'-keyfile', ENV['ca_key_path'], '-cert', ENV['ca_cert_path'],
|
||||
'-extensions', 'usr_cert', '-notext', '-md sha256',
|
||||
'-in', csr_file.path, '-out', crt_file.path, '-key', ENV['ca_key_password'],
|
||||
'-batch')
|
||||
|
||||
if err.match?(/Data Base Updated/)
|
||||
crt_file.rewind
|
||||
|
@ -103,7 +102,7 @@ class Certificate < ApplicationRecord
|
|||
end
|
||||
logger.error(err)
|
||||
puts "Certificate sign issue: #{err.inspect}" if Rails.env.test?
|
||||
return false
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -112,7 +111,8 @@ class Certificate < ApplicationRecord
|
|||
crt_file.write(crt)
|
||||
crt_file.rewind
|
||||
|
||||
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \
|
||||
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \
|
||||
-keyfile #{ENV['ca_key_path']} \
|
||||
-cert #{ENV['ca_cert_path']} \
|
||||
-revoke #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
|
||||
|
||||
|
@ -134,7 +134,7 @@ class Certificate < ApplicationRecord
|
|||
class << self
|
||||
def tostdout(message)
|
||||
time = Time.zone.now.utc
|
||||
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
|
||||
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
|
||||
end
|
||||
|
||||
def update_crl
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class CertificationRequest
|
||||
extend ActiveModel::Translation
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,7 @@ module Contact::Archivable
|
|||
end
|
||||
|
||||
def archive(verified: false, notify: true, extra_log: false)
|
||||
unless verified
|
||||
raise 'Contact cannot be archived' unless archivable?(post: true)
|
||||
end
|
||||
raise 'Contact cannot be archived' if !verified && !archivable?(post: true)
|
||||
|
||||
notify_registrar_about_archivation if notify
|
||||
write_to_registrar_log if extra_log
|
||||
|
@ -35,9 +33,7 @@ module Contact::Archivable
|
|||
end
|
||||
|
||||
def inactive?
|
||||
if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
|
||||
return true
|
||||
end
|
||||
return true if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
|
||||
|
||||
Version::DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago
|
||||
end
|
||||
|
@ -47,7 +43,7 @@ module Contact::Archivable
|
|||
end
|
||||
|
||||
def log(msg)
|
||||
@log ||= Logger.new(STDOUT)
|
||||
@log ||= Logger.new($stdout)
|
||||
@log.info(msg)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ module Domain::Expirable
|
|||
def expirable?
|
||||
return false if expire_time > Time.zone.now
|
||||
|
||||
if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_date.present?
|
||||
return false
|
||||
end
|
||||
return false if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_date.present?
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -5,6 +5,9 @@ module Domain::ForceDelete
|
|||
DomainStatus::SERVER_RENEW_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||
|
||||
HOLD_STATUSES = [DomainStatus::SERVER_HOLD,
|
||||
DomainStatus::CLIENT_HOLD].freeze
|
||||
|
||||
included do
|
||||
store_accessor :force_delete_data,
|
||||
:force_delete_type,
|
||||
|
@ -15,11 +18,6 @@ module Domain::ForceDelete
|
|||
lambda {
|
||||
where("(force_delete_data->>'contact_notification_sent_date') is null")
|
||||
}
|
||||
|
||||
HOLD_STATUSES = [
|
||||
DomainStatus::SERVER_HOLD,
|
||||
DomainStatus::CLIENT_HOLD,
|
||||
].freeze
|
||||
end
|
||||
|
||||
class_methods do
|
||||
|
|
|
@ -121,7 +121,7 @@ module EppErrors
|
|||
err = { code: code, msg: t }
|
||||
val = check_for_status(code, obj, val)
|
||||
err[:value] = { val: val, obj: obj } if val.present?
|
||||
self.errors.add(:epp_errors, err)
|
||||
errors.add(:epp_errors, **err)
|
||||
end
|
||||
|
||||
def check_for_status(code, obj, val)
|
||||
|
|
|
@ -68,13 +68,10 @@ module Registrar::BookKeeping
|
|||
|
||||
def finalize_invoice_line(line, price:, activity:, duration:)
|
||||
yearly = price.duration.in_years.to_i >= 1
|
||||
|
||||
line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount
|
||||
line['description'] = description_in_language(price: price, yearly: yearly)
|
||||
|
||||
if duration.present?
|
||||
add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
|
||||
end
|
||||
add_product_timeframe(line: line, activity: activity, duration: duration) if duration.present? && (duration > 1)
|
||||
|
||||
line
|
||||
end
|
||||
|
|
|
@ -5,26 +5,25 @@ module UserEvents
|
|||
# EPP requires a server defined creator ID, which should be registrar code if we have one
|
||||
def cr_id
|
||||
# try this, rebuild user for registrar before searching history? really?
|
||||
registrar = self.creator.try(:registrar)
|
||||
registrar = creator.try(:registrar)
|
||||
if registrar.present? # Did creator return a kind of User that has a registrar?
|
||||
registrar.code
|
||||
else
|
||||
if self.versions.first.try(:object).nil?
|
||||
changes = self.versions.first.try(:object_changes)
|
||||
if versions.first.try(:object).nil?
|
||||
changes = versions.first.try(:object_changes)
|
||||
cr_registrar_id = changes['registrar_id'].second if changes.present?
|
||||
else
|
||||
# untested, expected never to execute
|
||||
cr_registrar_id = self.versions.first.object['registrar_id']
|
||||
cr_registrar_id = versions.first.object['registrar_id']
|
||||
end
|
||||
|
||||
if cr_registrar_id.present?
|
||||
Registrar.find(cr_registrar_id).code
|
||||
else
|
||||
# cr_id optional for domain, but required for contact; but we want something here anyway
|
||||
self.creator_str || self.registrar.code # Fallback
|
||||
creator_str || self.registrar.code # Fallback
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class Contact < ApplicationRecord
|
|||
include Contact::Archivable
|
||||
include EmailVerifable
|
||||
|
||||
belongs_to :original, class_name: self.name
|
||||
belongs_to :original, class_name: 'Contact'
|
||||
belongs_to :registrar, required: true
|
||||
has_many :domain_contacts
|
||||
has_many :domains, through: :domain_contacts
|
||||
|
@ -20,6 +20,7 @@ class Contact < ApplicationRecord
|
|||
has_many :actions, dependent: :destroy
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
|
||||
alias_attribute :kind, :ident_type
|
||||
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
||||
|
||||
|
@ -29,7 +30,7 @@ class Contact < ApplicationRecord
|
|||
}
|
||||
|
||||
NAME_REGEXP = /([\u00A1-\u00B3\u00B5-\u00BF\u0021-\u0026\u0028-\u002C\u003A-\u0040]|
|
||||
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x.freeze
|
||||
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x
|
||||
|
||||
validates :name, :email, presence: true
|
||||
validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }
|
||||
|
@ -43,9 +44,9 @@ class Contact < ApplicationRecord
|
|||
validate :correct_email_format, if: proc { |c| c.will_save_change_to_email? }
|
||||
|
||||
validates :code,
|
||||
uniqueness: { message: :epp_id_taken },
|
||||
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
||||
length: { maximum: 100, message: :too_long_contact_code }
|
||||
uniqueness: { message: :epp_id_taken },
|
||||
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
||||
length: { maximum: 100, message: :too_long_contact_code }
|
||||
validates_associated :identifier
|
||||
|
||||
validate :validate_html
|
||||
|
@ -164,7 +165,9 @@ class Contact < ApplicationRecord
|
|||
scope = all
|
||||
|
||||
# all contacts has state ok, so no need to filter by it
|
||||
scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") if states.delete(OK)
|
||||
if states.delete(OK)
|
||||
scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}")
|
||||
end
|
||||
scope = scope.linked if states.delete(LINKED)
|
||||
scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
|
||||
scope
|
||||
|
@ -385,7 +388,6 @@ class Contact < ApplicationRecord
|
|||
self.email = email.to_s.strip
|
||||
end
|
||||
|
||||
|
||||
# what we can do load firstly by registrant
|
||||
# if total is smaller than needed, the load more
|
||||
# we also need to sort by valid_to
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
class Contact
|
||||
class Address
|
||||
attr_reader :street
|
||||
attr_reader :zip
|
||||
attr_reader :city
|
||||
attr_reader :state
|
||||
attr_reader :country_code
|
||||
attr_reader :street, :zip, :city, :state, :country_code
|
||||
|
||||
def initialize(street, zip, city, state, country_code)
|
||||
@street = street
|
||||
|
@ -22,4 +18,4 @@ class Contact
|
|||
(country_code == other.country_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
class Contact::Ident
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :code
|
||||
attr_accessor :type
|
||||
attr_accessor :country_code
|
||||
attr_accessor :code, :type, :country_code
|
||||
|
||||
validates :code, presence: true
|
||||
validates :code, national_id: true, if: :national_id?
|
||||
|
|
|
@ -122,7 +122,7 @@ class CsyncRecord < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.log
|
||||
Rails.env.test? ? logger : Logger.new(STDOUT)
|
||||
Rails.env.test? ? logger : Logger.new($stdout)
|
||||
end
|
||||
|
||||
def validate_csync_action
|
||||
|
|
|
@ -34,10 +34,10 @@ module Depp
|
|||
org_name: params[:org_name],
|
||||
|
||||
# address
|
||||
street: params[:street],
|
||||
city: params[:city],
|
||||
zip: params[:zip],
|
||||
state: params[:state],
|
||||
street: params[:street],
|
||||
city: params[:city],
|
||||
zip: params[:zip],
|
||||
state: params[:state],
|
||||
country_code: params[:country_code]
|
||||
)
|
||||
end
|
||||
|
@ -61,10 +61,10 @@ module Depp
|
|||
org_name: res.css('postalInfo org').text,
|
||||
|
||||
# address
|
||||
street: res.css('postalInfo addr street').text,
|
||||
city: res.css('postalInfo addr city').text,
|
||||
zip: res.css('postalInfo addr pc').text,
|
||||
state: res.css('postalInfo addr sp').text,
|
||||
street: res.css('postalInfo addr street').text,
|
||||
city: res.css('postalInfo addr city').text,
|
||||
zip: res.css('postalInfo addr pc').text,
|
||||
state: res.css('postalInfo addr sp').text,
|
||||
country_code: res.css('postalInfo addr cc').text,
|
||||
|
||||
# authInfo
|
||||
|
@ -116,10 +116,11 @@ module Depp
|
|||
xml.with_indifferent_access
|
||||
end
|
||||
|
||||
def extract_disclosure_hash(cpd) # cpd = contact_params[:disclose]
|
||||
# cpd = contact_params[:disclose]
|
||||
def extract_disclosure_hash(cpd)
|
||||
return {} unless cpd
|
||||
cpd = cpd.delete_if { |k, v| v if v != '1' && k == 'flag' }
|
||||
cpd
|
||||
|
||||
cpd.delete_if { |k, v| v if v != '1' && k == 'flag' }
|
||||
end
|
||||
|
||||
def extract_info_disclosure(data)
|
||||
|
@ -147,7 +148,7 @@ module Depp
|
|||
id: { value: code },
|
||||
postalInfo: {
|
||||
name: { value: name },
|
||||
org: { value: org_name },
|
||||
org: { value: org_name },
|
||||
},
|
||||
voice: { value: phone },
|
||||
email: { value: email }
|
||||
|
@ -195,7 +196,7 @@ module Depp
|
|||
chg: {
|
||||
postalInfo: {
|
||||
name: { value: name },
|
||||
org: { value: org_name },
|
||||
org: { value: org_name },
|
||||
},
|
||||
voice: { value: phone },
|
||||
email: { value: email },
|
||||
|
@ -240,7 +241,7 @@ module Depp
|
|||
ident = ident_xml[:_anonymus].try(:first)
|
||||
when :update
|
||||
# detect if any ident has changed, nb! ident and self.ident is not always same
|
||||
if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code)
|
||||
unless ident == self.ident && ident == ident_type && ident_country_code == self.ident_country_code
|
||||
ident = ident_xml[:_anonymus].try(:first)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -109,11 +109,9 @@ module Depp
|
|||
period = params[:period].to_i.to_s
|
||||
period_unit = params[:period][-1].to_s
|
||||
|
||||
current_user.request(epp_xml.renew(
|
||||
name: { value: params[:domain_name] },
|
||||
curExpDate: { value: params[:cur_exp_date] },
|
||||
period: { value: period, attrs: { unit: period_unit } }
|
||||
))
|
||||
current_user.request(epp_xml.renew(name: { value: params[:domain_name] },
|
||||
curExpDate: { value: params[:cur_exp_date] },
|
||||
period: { value: period, attrs: { unit: period_unit } }))
|
||||
end
|
||||
|
||||
def transfer(params)
|
||||
|
|
|
@ -11,7 +11,7 @@ module Depp
|
|||
validate :validate_existance_in_server
|
||||
|
||||
def initialize(args = {})
|
||||
args.each { |k, v| send(k.to_s + '=', v) }
|
||||
args.each { |k, v| send("#{k}=", v) }
|
||||
end
|
||||
|
||||
def server
|
||||
|
@ -20,13 +20,13 @@ module Depp
|
|||
port = ENV['epp_port'] || '700'
|
||||
|
||||
@server_cache ||= Epp::Server.new({
|
||||
server: ENV['epp_hostname'],
|
||||
tag: tag,
|
||||
password: password,
|
||||
port: port,
|
||||
cert: OpenSSL::X509::Certificate.new(client_cert),
|
||||
key: OpenSSL::PKey::RSA.new(client_key)
|
||||
})
|
||||
server: ENV['epp_hostname'],
|
||||
tag: tag,
|
||||
password: password,
|
||||
port: port,
|
||||
cert: OpenSSL::X509::Certificate.new(client_cert),
|
||||
key: OpenSSL::PKey::RSA.new(client_key)
|
||||
})
|
||||
end
|
||||
|
||||
def request(xml)
|
||||
|
|
|
@ -20,7 +20,7 @@ module DNS
|
|||
def self.generate_zonefile(origin)
|
||||
filename = "#{origin}.zone"
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
|
||||
$stdout << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
|
||||
|
||||
zf = ActiveRecord::Base.connection.execute(
|
||||
"select generate_zonefile('#{origin}')"
|
||||
|
@ -28,7 +28,7 @@ module DNS
|
|||
|
||||
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
|
||||
$stdout << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
|
||||
end
|
||||
|
||||
def self.origins
|
||||
|
|
|
@ -24,7 +24,8 @@ class Dnskey < ApplicationRecord
|
|||
end
|
||||
}
|
||||
|
||||
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list
|
||||
# IANA numbers, single authority list
|
||||
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze
|
||||
PROTOCOLS = %w(3)
|
||||
FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK
|
||||
DS_DIGEST_TYPE = [1,2]
|
||||
|
@ -75,13 +76,15 @@ class Dnskey < ApplicationRecord
|
|||
def validate_flags
|
||||
return if flags.blank?
|
||||
return if FLAGS.include?(flags.to_s)
|
||||
|
||||
errors.add(:flags, :invalid, values: "Valid flags are: #{FLAGS.join(', ')}")
|
||||
end
|
||||
|
||||
def generate_digest
|
||||
return unless flags == 257 || flags == 256 # require ZoneFlag, but optional SecureEntryPoint
|
||||
|
||||
self.ds_alg = alg
|
||||
self.ds_digest_type = Setting.ds_digest_type if self.ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type)
|
||||
self.ds_digest_type = Setting.ds_digest_type if ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type)
|
||||
|
||||
flags_hex = self.class.int_to_hex(flags)
|
||||
protocol_hex = self.class.int_to_hex(protocol)
|
||||
|
@ -90,9 +93,10 @@ class Dnskey < ApplicationRecord
|
|||
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
|
||||
bin = self.class.hex_to_bin(hex)
|
||||
|
||||
if self.ds_digest_type == 1
|
||||
case ds_digest_type
|
||||
when 1
|
||||
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
|
||||
elsif self.ds_digest_type == 2
|
||||
when 2
|
||||
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
|
||||
end
|
||||
end
|
||||
|
@ -109,11 +113,11 @@ class Dnskey < ApplicationRecord
|
|||
|
||||
c = 0
|
||||
wire_format.each_byte.with_index do |b, i|
|
||||
if i.even?
|
||||
c += b << 8
|
||||
else
|
||||
c += b
|
||||
end
|
||||
c += if i.even?
|
||||
b << 8
|
||||
else
|
||||
b
|
||||
end
|
||||
end
|
||||
|
||||
self.ds_key_tag = ((c & 0xFFFF) + (c >> 16)) & 0xFFFF
|
||||
|
@ -146,21 +150,21 @@ class Dnskey < ApplicationRecord
|
|||
end
|
||||
|
||||
class << self
|
||||
def int_to_hex(s)
|
||||
s = s.to_s(16)
|
||||
s.prepend('0') if s.length.odd?
|
||||
def int_to_hex(num)
|
||||
num = num.to_s(16)
|
||||
num.prepend('0') if num.length.odd?
|
||||
end
|
||||
|
||||
def hex_to_bin(s)
|
||||
s.scan(/../).map(&:hex).pack('c*')
|
||||
def hex_to_bin(num)
|
||||
num.scan(/../).map(&:hex).pack('c*')
|
||||
end
|
||||
|
||||
def bin_to_hex(s)
|
||||
s.each_byte.map { |b| format('%02X', b) }.join
|
||||
def bin_to_hex(num)
|
||||
num.each_byte.map { |b| format('%02X', b) }.join
|
||||
end
|
||||
|
||||
def pub_key_base64?(pub)
|
||||
return unless pub&.is_a?(String)
|
||||
return unless pub.is_a?(String)
|
||||
|
||||
Base64.strict_encode64(Base64.strict_decode64(pub)) == pub
|
||||
rescue ArgumentError
|
||||
|
|
|
@ -13,9 +13,14 @@ class Domain < ApplicationRecord
|
|||
include Domain::Disputable
|
||||
include Domain::BulkUpdatable
|
||||
|
||||
attr_accessor :roles
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
attr_accessor :roles,
|
||||
:legal_document_id,
|
||||
:is_admin,
|
||||
:registrant_typeahead,
|
||||
:update_me,
|
||||
:epp_pending_update,
|
||||
:epp_pending_delete,
|
||||
:reserved_pw
|
||||
|
||||
alias_attribute :on_hold_time, :outzone_at
|
||||
alias_attribute :outzone_time, :outzone_at
|
||||
|
@ -27,16 +32,18 @@ class Domain < ApplicationRecord
|
|||
:admin_store_statuses_history
|
||||
|
||||
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
||||
# TODO: most inputs should be trimmed before validatation, probably some global logic?
|
||||
# TODO: most inputs should be trimmed before validation, probably some global logic?
|
||||
|
||||
belongs_to :registrar, required: true
|
||||
belongs_to :registrant, required: true
|
||||
# TODO: should we user validates_associated :registrant here?
|
||||
|
||||
has_many :admin_domain_contacts
|
||||
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true, reject_if: :admin_change_prohibited?
|
||||
accepts_nested_attributes_for :admin_domain_contacts,
|
||||
allow_destroy: true, reject_if: :admin_change_prohibited?
|
||||
has_many :tech_domain_contacts
|
||||
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true, reject_if: :tech_change_prohibited?
|
||||
accepts_nested_attributes_for :tech_domain_contacts,
|
||||
allow_destroy: true, reject_if: :tech_change_prohibited?
|
||||
|
||||
def registrant_change_prohibited?
|
||||
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
|
||||
|
@ -114,16 +121,12 @@ class Domain < ApplicationRecord
|
|||
validate :status_is_consistant
|
||||
def status_is_consistant
|
||||
has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
||||
unless has_error
|
||||
if (statuses & DELETE_STATUSES).any?
|
||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
end
|
||||
if !has_error && (statuses & DELETE_STATUSES).any?
|
||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
end
|
||||
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
||||
end
|
||||
|
||||
attr_accessor :is_admin
|
||||
|
||||
# Removed to comply new ForceDelete procedure
|
||||
# at https://github.com/internetee/registry/issues/1428#issuecomment-570561967
|
||||
#
|
||||
|
@ -204,12 +207,10 @@ class Domain < ApplicationRecord
|
|||
|
||||
def statuses_uniqueness
|
||||
return if statuses.uniq == statuses
|
||||
|
||||
errors.add(:statuses, :taken)
|
||||
end
|
||||
|
||||
attr_accessor :registrant_typeahead, :update_me,
|
||||
:epp_pending_update, :epp_pending_delete, :reserved_pw
|
||||
|
||||
self.ignored_columns = %w[legacy_id legacy_registrar_id legacy_registrant_id]
|
||||
|
||||
def subordinate_nameservers
|
||||
|
@ -350,10 +351,10 @@ class Domain < ApplicationRecord
|
|||
# find by internationalized domain name
|
||||
# internet domain name => ascii or puny, but db::domains.name is unicode
|
||||
def self.find_by_idn(name)
|
||||
domain = self.find_by_name name
|
||||
domain = find_by(name: name)
|
||||
if domain.blank? && name.include?('-')
|
||||
unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny
|
||||
domain = self.find_by_name unicode
|
||||
domain = find_by(name: unicode)
|
||||
end
|
||||
domain
|
||||
end
|
||||
|
@ -386,9 +387,7 @@ class Domain < ApplicationRecord
|
|||
return true unless Setting.days_to_renew_domain_before_expire != 0
|
||||
|
||||
# if you can renew domain at days_to_renew before domain expiration
|
||||
if (expire_time.to_date - Time.zone.today) + 1 > Setting.days_to_renew_domain_before_expire
|
||||
return false
|
||||
end
|
||||
return false if (expire_time.to_date - Time.zone.today) + 1 > Setting.days_to_renew_domain_before_expire
|
||||
|
||||
true
|
||||
end
|
||||
|
@ -431,9 +430,11 @@ class Domain < ApplicationRecord
|
|||
|
||||
def pending_update!
|
||||
return true if pending_update?
|
||||
|
||||
self.epp_pending_update = true # for epp
|
||||
|
||||
return true unless registrant_verification_asked?
|
||||
|
||||
pending_json_cache = pending_json
|
||||
token = registrant_verification_token
|
||||
asked_at = registrant_verification_asked_at
|
||||
|
@ -590,20 +591,19 @@ class Domain < ApplicationRecord
|
|||
# special handling for admin changing status
|
||||
def admin_status_update(update)
|
||||
update_unless_locked_by_registrant(update)
|
||||
|
||||
update_not_by_locked_statuses(update)
|
||||
# check for deleted status
|
||||
statuses.each do |s|
|
||||
unless update.include? s
|
||||
case s
|
||||
when DomainStatus::PENDING_DELETE
|
||||
self.delete_date = nil
|
||||
when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set
|
||||
self.outzone_at = Time.zone.now if force_delete_scheduled?
|
||||
when DomainStatus::EXPIRED # removal causes server hold to set
|
||||
self.outzone_at = self.expire_time + 15.day
|
||||
when DomainStatus::SERVER_HOLD # removal causes server hold to set
|
||||
self.outzone_at = nil
|
||||
when DomainStatus::PENDING_DELETE
|
||||
self.delete_date = nil
|
||||
when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set
|
||||
self.outzone_at = Time.zone.now if force_delete_scheduled?
|
||||
when DomainStatus::EXPIRED # removal causes server hold to set
|
||||
self.outzone_at = expire_time + 15.day
|
||||
when DomainStatus::SERVER_HOLD # removal causes server hold to set
|
||||
self.outzone_at = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,24 +103,24 @@ class DomainStatus < ApplicationRecord
|
|||
].freeze
|
||||
|
||||
UPDATE_PROHIBIT_STATES = [
|
||||
DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||
DomainStatus::CLIENT_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::PENDING_CREATE,
|
||||
DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE,
|
||||
DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER
|
||||
]
|
||||
DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||
DomainStatus::CLIENT_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::PENDING_CREATE,
|
||||
DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE,
|
||||
DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER
|
||||
].freeze
|
||||
|
||||
DELETE_PROHIBIT_STATES = [
|
||||
DomainStatus::CLIENT_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::PENDING_CREATE,
|
||||
DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER,
|
||||
DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE
|
||||
DomainStatus::CLIENT_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::PENDING_CREATE,
|
||||
DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER,
|
||||
DomainStatus::PENDING_UPDATE,
|
||||
DomainStatus::PENDING_DELETE
|
||||
].freeze
|
||||
|
||||
def epp_code_map
|
||||
|
@ -153,7 +153,6 @@ class DomainStatus < ApplicationRecord
|
|||
admin_statuses_map.map(&:second)
|
||||
end
|
||||
|
||||
|
||||
def admin_statuses_map
|
||||
admin_statuses = [
|
||||
['Hold', SERVER_HOLD],
|
||||
|
|
|
@ -98,8 +98,8 @@ class Epp::Contact < Contact
|
|||
return unless legal_document_data
|
||||
|
||||
legal_documents.create(
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -108,9 +108,9 @@ class Epp::Contact < Contact
|
|||
return unless legal_document_data
|
||||
|
||||
doc = LegalDocument.create(
|
||||
documentable_type: Contact,
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
documentable_type: Contact,
|
||||
document_type: legal_document_data[:type],
|
||||
body: legal_document_data[:body]
|
||||
)
|
||||
self.legal_documents = [doc]
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ class Epp::Domain < Domain
|
|||
return true if is_transfer || is_renewal
|
||||
return unless update_prohibited?
|
||||
|
||||
stat = (statuses & (DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first
|
||||
|
||||
stat = (statuses &
|
||||
(DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first
|
||||
add_epp_error('2304', 'status', stat, I18n.t(:object_status_prohibits_operation))
|
||||
throw(:abort)
|
||||
end
|
||||
|
@ -144,8 +144,8 @@ class Epp::Domain < Domain
|
|||
return
|
||||
end
|
||||
|
||||
if doc = attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call)
|
||||
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
|
||||
if doc = attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call) && doc&.persisted?
|
||||
frame.css("legalDocument").first.content = doc.path
|
||||
end
|
||||
|
||||
if Setting.request_confirmation_on_domain_deletion_enabled &&
|
||||
|
@ -174,7 +174,7 @@ class Epp::Domain < Domain
|
|||
|
||||
### RENEW ###
|
||||
|
||||
def renew(renewed_expire_time:, period:, unit:)
|
||||
def renew(renewed_expire_time, period, unit)
|
||||
@is_renewal = true
|
||||
|
||||
add_renew_epp_errors unless renewable?
|
||||
|
@ -216,7 +216,8 @@ class Epp::Domain < Domain
|
|||
return transfers.last if transfers.any?
|
||||
when 'request'
|
||||
return pending_transfer if pending_transfer
|
||||
return query_transfer(frame, current_user)
|
||||
|
||||
query_transfer(frame, current_user)
|
||||
when 'approve'
|
||||
return approve_transfer(frame, current_user) if pending_transfer
|
||||
when 'reject'
|
||||
|
@ -308,10 +309,12 @@ class Epp::Domain < Domain
|
|||
begin
|
||||
return if cur_exp_date.to_date == valid_to.to_date
|
||||
rescue
|
||||
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
||||
add_epp_error('2306', 'curExpDate', cur_exp_date,
|
||||
I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
||||
return
|
||||
end
|
||||
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
||||
add_epp_error('2306', 'curExpDate', cur_exp_date,
|
||||
I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
||||
end
|
||||
|
||||
### ABILITIES ###
|
||||
|
@ -323,10 +326,10 @@ class Epp::Domain < Domain
|
|||
return false
|
||||
end
|
||||
|
||||
begin
|
||||
if (statuses & [DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any?
|
||||
errors.add(:base, :domain_status_prohibits_operation)
|
||||
return false
|
||||
end if (statuses & [DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any?
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -2,4 +2,4 @@ class Iban
|
|||
def self.max_length
|
||||
34
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class InactiveContacts
|
|||
end
|
||||
|
||||
def log(msg)
|
||||
@log ||= Logger.new(STDOUT)
|
||||
@log ||= Logger.new($stdout)
|
||||
@log.info(msg)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,22 +12,26 @@ class Invoice < ApplicationRecord
|
|||
has_many :payment_orders
|
||||
|
||||
accepts_nested_attributes_for :items
|
||||
|
||||
scope :all_columns, ->{select("invoices.*")}
|
||||
scope :sort_due_date_column, ->{all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
|
||||
# rubocop:disable Layout/LineLength
|
||||
# rubocop:disable Style/MultilineBlockLayout
|
||||
scope :all_columns, -> { select("invoices.*") }
|
||||
scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
|
||||
(invoices.cancelled_at + interval '100 year') ELSE
|
||||
invoices.due_date END AS sort_due_date")}
|
||||
scope :sort_by_sort_due_date_asc, ->{sort_due_date_column.order("sort_due_date ASC")}
|
||||
scope :sort_by_sort_due_date_desc, ->{sort_due_date_column.order("sort_due_date DESC")}
|
||||
scope :sort_receipt_date_column, ->{all_columns.includes(:account_activity).references(:account_activity).select(%Q{
|
||||
invoices.due_date END AS sort_due_date")
|
||||
}
|
||||
scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") }
|
||||
scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") }
|
||||
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%(
|
||||
CASE WHEN account_activities.created_at is not null THEN account_activities.created_at
|
||||
WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year'
|
||||
ELSE NULL END AS sort_receipt_date })}
|
||||
scope :sort_by_sort_receipt_date_asc, ->{sort_receipt_date_column.order("sort_receipt_date ASC")}
|
||||
scope :sort_by_sort_receipt_date_desc, ->{sort_receipt_date_column.order("sort_receipt_date DESC")}
|
||||
ELSE NULL END AS sort_receipt_date ))
|
||||
}
|
||||
scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") }
|
||||
scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") }
|
||||
|
||||
scope :overdue, -> { unpaid.non_cancelled.where('due_date < ?', Time.zone.today) }
|
||||
|
||||
# rubocop:enable Layout/LineLength
|
||||
# rubocop:enable Style/MultilineBlockLayout
|
||||
validates :due_date, :currency, :seller_name,
|
||||
:seller_iban, :buyer_name, :items, presence: true
|
||||
|
||||
|
@ -38,7 +42,7 @@ class Invoice < ApplicationRecord
|
|||
attribute :vat_rate, ::Type::VatRate.new
|
||||
|
||||
def set_invoice_number
|
||||
last_no = Invoice.order(number: :desc).limit(1).pluck(:number).first
|
||||
last_no = Invoice.order(number: :desc).limit(1).pick(:number)
|
||||
|
||||
if last_no && last_no >= Setting.invoice_number_min.to_i
|
||||
self.number = last_no + 1
|
||||
|
@ -91,8 +95,8 @@ class Invoice < ApplicationRecord
|
|||
read_attribute(:total)
|
||||
end
|
||||
|
||||
def each
|
||||
items.each { |item| yield item }
|
||||
def each(&block)
|
||||
items.each(&block)
|
||||
end
|
||||
|
||||
def as_pdf
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Invoice
|
||||
class EInvoiceGenerator
|
||||
attr_reader :invoice
|
||||
attr_reader :payable
|
||||
attr_reader :invoice, :payable
|
||||
|
||||
def initialize(invoice, payable)
|
||||
@invoice = invoice
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Invoice
|
||||
class VatRateCalculator
|
||||
attr_reader :registry
|
||||
attr_reader :registrar
|
||||
attr_reader :registry, :registrar
|
||||
|
||||
def initialize(registry: Registry.current, registrar:)
|
||||
@registry = registry
|
||||
|
@ -16,4 +15,4 @@ class Invoice
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,7 +65,6 @@ class LegalDocument < ApplicationRecord
|
|||
true
|
||||
end
|
||||
|
||||
|
||||
def self.remove_duplicates
|
||||
start = Time.zone.now.to_f
|
||||
Rails.logger.info '-----> Removing legal documents duplicates'
|
||||
|
@ -84,7 +83,8 @@ class LegalDocument < ApplicationRecord
|
|||
File.delete(new_legal.path) if File.exist?(new_legal.path)
|
||||
new_legal.update(path: orig_legal.path)
|
||||
count += 1
|
||||
Rails.logger.info "File #{new_legal.path} has been removed by Domain #{new_legal.documentable_id}. Document id: #{new_legal.id}"
|
||||
Rails.logger.info "File #{new_legal.path} has been removed by Domain "\
|
||||
"#{new_legal.documentable_id}. Document id: #{new_legal.id}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -107,7 +107,8 @@ class LegalDocument < ApplicationRecord
|
|||
File.delete(new_legal.path) if File.exist?(new_legal.path)
|
||||
new_legal.update(path: orig_legal.path)
|
||||
count += 1
|
||||
Rails.logger.info "File #{new_legal.path} has been removed by Contact #{new_legal.documentable_id}. Document id: #{new_legal.id}"
|
||||
Rails.logger.info "File #{new_legal.path} has been removed by Contact "\
|
||||
"#{new_legal.documentable_id}. Document id: #{new_legal.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,18 +38,18 @@ class Nameserver < ApplicationRecord
|
|||
|
||||
def epp_code_map
|
||||
{
|
||||
'2302' => [
|
||||
[:hostname, :taken, { value: { obj: 'hostAttr', val: {'hostName': hostname} } }]
|
||||
],
|
||||
'2005' => [
|
||||
[:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }],
|
||||
[:hostname, :puny_to_long, { value: { obj: 'hostAttr', val: hostname } }],
|
||||
[:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }],
|
||||
[:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }]
|
||||
],
|
||||
'2003' => [
|
||||
%i[base ip_required],
|
||||
]
|
||||
'2302' => [
|
||||
[:hostname, :taken, { value: { obj: 'hostAttr', val: { 'hostName': hostname } } }]
|
||||
],
|
||||
'2005' => [
|
||||
[:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }],
|
||||
[:hostname, :puny_to_long, { value: { obj: 'hostAttr', val: hostname } }],
|
||||
[:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }],
|
||||
[:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }]
|
||||
],
|
||||
'2003' => [
|
||||
%i[base ip_required],
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -63,11 +63,10 @@ class Nameserver < ApplicationRecord
|
|||
end
|
||||
|
||||
class << self
|
||||
def from_hash_params params
|
||||
def from_hash_params(params)
|
||||
params = params.with_indifferent_access
|
||||
rel = all
|
||||
rel = rel.where(hostname: params[:hostname])
|
||||
rel
|
||||
rel.where(hostname: params[:hostname])
|
||||
end
|
||||
|
||||
def hostnames
|
||||
|
|
|
@ -23,7 +23,7 @@ class PaymentOrder < ApplicationRecord
|
|||
supported = []
|
||||
|
||||
PAYMENT_METHODS.each do |method|
|
||||
class_name = ('PaymentOrders::' + method.camelize).constantize
|
||||
class_name = "PaymentOrders::#{method.camelize}".constantize
|
||||
raise(NoMethodError, class_name) unless class_name < PaymentOrder
|
||||
|
||||
supported << class_name
|
||||
|
@ -33,7 +33,7 @@ class PaymentOrder < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.new_with_type(type:, invoice:)
|
||||
channel = ('PaymentOrders::' + type.camelize).constantize
|
||||
channel = "PaymentOrders::#{type.camelize}".constantize
|
||||
|
||||
PaymentOrder.new(type: channel, invoice: invoice)
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ class PaymentOrder < ApplicationRecord
|
|||
|
||||
def self.supported_method?(name, shortname: false)
|
||||
some_class = if shortname
|
||||
('PaymentOrders::' + name.camelize).constantize
|
||||
"PaymentOrders::#{name.camelize}".constantize
|
||||
else
|
||||
name.constantize
|
||||
end
|
||||
|
|
|
@ -104,9 +104,8 @@ module PaymentOrders
|
|||
|
||||
def sign(data)
|
||||
private_key = OpenSSL::PKey::RSA.new(File.read(seller_certificate))
|
||||
signed_data = private_key.sign(OpenSSL::Digest::SHA1.new, data)
|
||||
signed_data = Base64.encode64(signed_data).gsub(/\n|\r/, '')
|
||||
signed_data
|
||||
signed_data = private_key.sign(OpenSSL::Digest.new('SHA1'), data)
|
||||
Base64.encode64(signed_data).gsub(/\n|\r/, '')
|
||||
end
|
||||
|
||||
def calc_mac(fields)
|
||||
|
@ -122,7 +121,7 @@ module PaymentOrders
|
|||
|
||||
def verify_mac(data, mac)
|
||||
bank_public_key = OpenSSL::X509::Certificate.new(File.read(bank_certificate)).public_key
|
||||
bank_public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(mac), data)
|
||||
bank_public_key.verify(OpenSSL::Digest.new('SHA1'), Base64.decode64(mac), data)
|
||||
end
|
||||
|
||||
def prepend_size(value)
|
||||
|
|
|
@ -28,7 +28,7 @@ class Registrar < ApplicationRecord
|
|||
validates :vat_rate, absence: true, if: :vat_liable_locally?
|
||||
validates :vat_rate, absence: true, if: -> { vat_liable_in_foreign_country? && vat_no? }
|
||||
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
|
||||
allow_nil: true
|
||||
allow_nil: true
|
||||
|
||||
attribute :vat_rate, ::Type::VatRate.new
|
||||
after_initialize :set_defaults
|
||||
|
@ -105,7 +105,7 @@ class Registrar < ApplicationRecord
|
|||
.deliver_later(wait: 1.minute)
|
||||
end
|
||||
|
||||
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable)
|
||||
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
||||
|
||||
invoice
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
class Registry
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :vat_rate
|
||||
attr_accessor :vat_country
|
||||
attr_accessor :vat_rate, :vat_country
|
||||
|
||||
def self.current
|
||||
vat_rate = Setting.registry_vat_prc.to_d * 100
|
||||
|
@ -10,4 +9,4 @@ class Registry
|
|||
|
||||
new(vat_rate: vat_rate, vat_country: vat_country)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ class ReservedDomain < ApplicationRecord
|
|||
end
|
||||
|
||||
def fill_empty_passwords
|
||||
regenerate_password if self.password.blank?
|
||||
regenerate_password if password.blank?
|
||||
end
|
||||
|
||||
def regenerate_password
|
||||
|
|
|
@ -8,7 +8,7 @@ class User < ApplicationRecord
|
|||
self.ignored_columns = %w[legacy_id]
|
||||
|
||||
def id_role_username
|
||||
"#{self.id}-#{self.class}: #{self.username}"
|
||||
"#{id}-#{self.class}: #{username}"
|
||||
end
|
||||
|
||||
def self.from_omniauth(omniauth_hash)
|
||||
|
|
|
@ -54,12 +54,8 @@ class WhiteIp < ApplicationRecord
|
|||
|
||||
def ids_including(ip)
|
||||
ipv4 = ipv6 = []
|
||||
if check_ip4(ip).present?
|
||||
ipv4 = select { |white_ip| check_ip4(white_ip.ipv4) === check_ip4(ip) }
|
||||
end
|
||||
if check_ip6(ip).present?
|
||||
ipv6 = select { |white_ip| check_ip6(white_ip.ipv6) === check_ip6(ip) }
|
||||
end
|
||||
ipv4 = select { |white_ip| check_ip4(white_ip.ipv4) === check_ip4(ip) } if check_ip4(ip).present?
|
||||
ipv6 = select { |white_ip| check_ip6(white_ip.ipv6) === check_ip6(ip) } if check_ip6(ip).present?
|
||||
(ipv4 + ipv6).pluck(:id).flatten.uniq
|
||||
end
|
||||
# rubocop:enable Style/CaseEquality
|
||||
|
|
|
@ -28,7 +28,7 @@ class WhoisRecord < ApplicationRecord
|
|||
end
|
||||
|
||||
status_map = {
|
||||
'ok' => 'ok (paid and in zone)'
|
||||
'ok' => 'ok (paid and in zone)'
|
||||
}
|
||||
|
||||
registrant = domain.registrant
|
||||
|
@ -75,7 +75,7 @@ class WhoisRecord < ApplicationRecord
|
|||
h[:nameservers] = domain.nameservers.hostnames.uniq.select(&:present?)
|
||||
h[:nameservers_changed] = domain.nameservers.pluck(:updated_at).max.try(:to_s, :iso8601)
|
||||
|
||||
h[:dnssec_keys] = domain.dnskeys.map{|key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
|
||||
h[:dnssec_keys] = domain.dnskeys.map { |key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
|
||||
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue