Skip to content

Commit

Permalink
update info for blocked domains
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Oct 18, 2024
1 parent 38ac9c8 commit f6fe63b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 19 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.0.2
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM internetee/ruby:3.0.2

RUN apt-get update -y > /dev/null
RUN apt-get install whois -y > /dev/null
RUN mkdir -p /opt/webapps/app/tmp/pids
# RUN apt-get update -y > /dev/null
# RUN apt-get install whois -y > /dev/null
WORKDIR /opt/webapps/app

RUN mkdir -p /opt/webapps/app/tmp/pids
RUN touch /opt/webapps/app/tmp/pids/.keep

COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ group :development do
end

group :development, :test do
gem 'minitest'
gem 'minitest', '~> 5.16.3' # Обновлено до последней версии
gem 'simplecov', '0.17.1', require: false # CC last supported v0.17
end
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ DEPENDENCIES
dotenv
eventmachine (~> 1.2.7)
mina (~> 1.2.4)
minitest
minitest (~> 5.16.3)
pg (~> 1.4.0)
pry (~> 0.14.1)
rubocop
simplecov (= 0.17.1)
simpleidn (~> 0.2.1)

BUNDLED WITH
2.2.17
2.5.22
38 changes: 29 additions & 9 deletions lib/whois_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,23 @@ def receive_data(data)
return
end

name = data.strip
name = name.downcase
name = data.strip.downcase
name = SimpleIDN.to_unicode(name)
whois_record = WhoisRecord.find_by(name: name)

if whois_record
logger.info "#{ip}: requested: #{data} [searched by: #{name}; Record found with id: #{whois_record.try(:id)}]"
send_data whois_record.unix_body

# Add special handling for .ee second-level domains
if %w[pri.ee fie.ee med.ee com.ee].include?(name)
logger.info "#{ip}: requested: #{data} [searched by: #{name}; Special .ee second-level domain]"
send_data special_ee_domain_msg(name)
else
logger.info "#{ip}: requested: #{data} [searched by: #{name}; No record found]"
provide_data_body(name)
whois_record = WhoisRecord.find_by(name: name)

if whois_record
logger.info "#{ip}: requested: #{data} [searched by: #{name}; Record found with id: #{whois_record.try(:id)}]"
send_data whois_record.unix_body
else
logger.info "#{ip}: requested: #{data} [searched by: #{name}; No record found]"
provide_data_body(name)
end
end
close_connection_after_writing
end
Expand Down Expand Up @@ -107,6 +113,20 @@ def footer_msg
"\n\nEstonia .ee Top Level Domain WHOIS server\n" \
"More information at http://internet.ee\n"
end

def special_ee_domain_msg(domain)
<<~MSG
Estonia .ee Top Level Domain WHOIS server
Domain:
name: #{domain}
status: Blocked
Estonia .ee Top Level Domain WHOIS server
More information at http://internet.ee
MSG
end
end

EventMachine.run do
Expand Down
2 changes: 2 additions & 0 deletions log/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*
*/
!.gitignore
tmp/pids/
.DS_Store
21 changes: 21 additions & 0 deletions test/models/whois_record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,25 @@ def test_disputed_record_is_inactive_if_unregistered
assert !@whois_record.active?
end

def test_special_ee_second_level_domains
special_domains = %w[pri.ee fie.ee med.ee com.ee]
special_domains.each do |domain|
@whois_record = WhoisRecord.new(name: domain, json: { name: domain, status: ['Blocked'] })

expected_output = <<~OUTPUT
Estonia .ee Top Level Domain WHOIS server
Domain:
name: #{domain}
status: Blocked
Estonia .ee Top Level Domain WHOIS server
More information at http://internet.ee
OUTPUT

assert_equal expected_output, @whois_record.unix_body
end
end

end
3 changes: 0 additions & 3 deletions tmp/pids/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions tmp/pids/whois_server.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit f6fe63b

Please sign in to comment.