mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Merge pull request #859 from internetee/remove-lib-from-autoload-path
Remove `lib` folder from autoload path
This commit is contained in:
commit
2828f8ca72
14 changed files with 57 additions and 58 deletions
|
@ -1,5 +1,4 @@
|
|||
class EppController < ApplicationController
|
||||
include Iptable
|
||||
layout false
|
||||
protect_from_forgery with: :null_session
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
@ -359,12 +358,6 @@ class EppController < ApplicationController
|
|||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
|
||||
def iptables_counter_update
|
||||
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'
|
||||
return if current_user.blank?
|
||||
counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
|
||||
end
|
||||
|
||||
def resource
|
||||
name = self.class.to_s.sub("Epp::","").sub("Controller","").underscore.singularize
|
||||
instance_variable_get("@#{name}")
|
||||
|
@ -407,4 +400,26 @@ class EppController < ApplicationController
|
|||
timeout = 5.minutes
|
||||
epp_session.updated_at < (Time.zone.now - timeout)
|
||||
end
|
||||
|
||||
def iptables_counter_update
|
||||
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'
|
||||
return if current_user.blank?
|
||||
counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
|
||||
end
|
||||
|
||||
def counter_update(registrar_code, ip)
|
||||
counter_proc = "/proc/net/xt_recent/#{registrar_code}"
|
||||
|
||||
begin
|
||||
File.open(counter_proc, 'a') do |f|
|
||||
f.puts "+#{ip}"
|
||||
end
|
||||
rescue Errno::ENOENT => e
|
||||
logger.error "IPTABLES COUNTER UPDATE: cannot open #{counter_proc}: #{e}"
|
||||
rescue Errno::EACCES => e
|
||||
logger.error "IPTABLES COUNTER UPDATE: no permission #{counter_proc}: #{e}"
|
||||
rescue IOError => e
|
||||
logger.error "IPTABLES COUNTER UPDATE: cannot write #{ip} to #{counter_proc}: #{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
40
app/models/sorted_country.rb
Normal file
40
app/models/sorted_country.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
class SortedCountry
|
||||
class << self
|
||||
include ActionView::Helpers
|
||||
|
||||
def all_options(selected = nil)
|
||||
quick_options = options_for_select(quick_list, selected: selected)
|
||||
|
||||
# no double select
|
||||
selected = quick_list.map(&:second).include?(selected) ? '' : selected
|
||||
|
||||
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
|
||||
selected: selected, disabled: ['---'])
|
||||
quick_options + all_options
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def quick_list
|
||||
@quick_list ||=
|
||||
[
|
||||
%w[Estonia' EE],
|
||||
%w[Finland FI],
|
||||
%w[Latvia LV],
|
||||
%w[Lithuania LT],
|
||||
['Russian Federation', 'RU'],
|
||||
%w[Sweden SE],
|
||||
['United States', 'US']
|
||||
]
|
||||
end
|
||||
|
||||
def all_sorted
|
||||
@all_sorted ||= Country.all.sort_by(&:name)
|
||||
end
|
||||
|
||||
def all_sorted_truncated
|
||||
@all_sorted_truncated ||=
|
||||
all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue